diff --git "a/data/train/cpp-004.jsonl" "b/data/train/cpp-004.jsonl" deleted file mode 100644--- "a/data/train/cpp-004.jsonl" +++ /dev/null @@ -1,196 +0,0 @@ -{"question_id": 2967, "task_id": "minimum-cost-to-make-array-equalindromic", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums having length n.\nYou are allowed to perform a special move any number of times (including zero) on nums. In one special move you perform the following steps in order:\n\nChoose an index i in the range [0, n - 1], and a positive integer x.\nAdd |nums[i] - x| to the total cost.\nChange the value of nums[i] to x.\n\nA palindromic number is a positive integer that remains the same when its digits are reversed. For example, 121, 2552 and 65756 are palindromic numbers whereas 24, 46, 235 are not palindromic numbers.\nAn array is considered equalindromic if all the elements in the array are equal to an integer y, where y is a palindromic number less than 109.\nReturn an integer denoting the minimum possible total cost to make nums equalindromic by performing any number of special moves.\n \nExample 1:\n\nInput: nums = [1,2,3,4,5]\nOutput: 6\nExplanation: We can make the array equalindromic by changing all elements to 3 which is a palindromic number. The cost of changing the array to [3,3,3,3,3] using 4 special moves is given by |1 - 3| + |2 - 3| + |4 - 3| + |5 - 3| = 6.\nIt can be shown that changing all elements to any palindromic number other than 3 cannot be achieved at a lower cost.\n\nExample 2:\n\nInput: nums = [10,12,13,14,15]\nOutput: 11\nExplanation: We can make the array equalindromic by changing all elements to 11 which is a palindromic number. The cost of changing the array to [11,11,11,11,11] using 5 special moves is given by |10 - 11| + |12 - 11| + |13 - 11| + |14 - 11| + |15 - 11| = 11.\nIt can be shown that changing all elements to any palindromic number other than 11 cannot be achieved at a lower cost.\n\nExample 3:\n\nInput: nums = [22,33,22,33,22]\nOutput: 22\nExplanation: We can make the array equalindromic by changing all elements to 22 which is a palindromic number. The cost of changing the array to [22,22,22,22,22] using 2 special moves is given by |33 - 22| + |33 - 22| = 22.\nIt can be shown that changing all elements to any palindromic number other than 22 cannot be achieved at a lower cost.\n\n \nConstraints:\n\n1 <= n <= 105\n1 <= nums[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [123, 121, 131, 141, 151]) == 48\n assert candidate(nums = [100000001, 200000002, 300000003, 400000004, 500000005]) == 600000006\n assert candidate(nums = [123456789, 987654321, 12345678, 87654321, 1234567, 7654321]) == 1177530865\n assert candidate(nums = [12321, 23432, 34543, 45654, 56765]) == 66666\n assert candidate(nums = [101, 202, 303, 404, 505]) == 606\n assert candidate(nums = [123, 456, 789, 101, 202]) == 1021\n assert candidate(nums = [100000000, 100000001, 100000002, 100000003, 100000004]) == 7\n assert candidate(nums = [111111111, 222222222, 333333333, 444444444, 555555555]) == 666666666\n assert candidate(nums = [8, 88, 888, 8888, 88888]) == 97680\n assert candidate(nums = [1, 2, 3, 4, 5]) == 6\n assert candidate(nums = [12321, 45654, 78987, 101101, 23432]) == 144335\n assert candidate(nums = [1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [100, 200, 300, 400, 500]) == 603\n assert candidate(nums = [123, 456, 789, 101112, 131415]) == 231950\n assert candidate(nums = [123, 321, 132, 213, 231, 312]) == 396\n assert candidate(nums = [12321, 45654, 78987, 1011101, 1213121]) == 2166247\n assert candidate(nums = [9, 11, 22, 33, 44]) == 57\n assert candidate(nums = [9, 9, 9, 9, 9]) == 0\n assert candidate(nums = [12321, 45654, 78987, 10101, 11111]) == 103429\n assert candidate(nums = [100000000, 99999999, 10000000, 9999999, 1000000]) == 189000001\n assert candidate(nums = [10, 12, 13, 14, 15]) == 11\n assert candidate(nums = [100000000, 200000000, 300000000, 400000000, 500000000]) == 600000003\n assert candidate(nums = [22, 33, 22, 33, 22]) == 22\n assert candidate(nums = [999999999, 999999998, 999999997, 999999996, 999999995]) == 10\n assert candidate(nums = [9, 99, 999, 9999, 99999]) == 109890\n assert candidate(nums = [123456789, 987654321, 123456789, 987654321, 123456789]) == 1728402596\n assert candidate(nums = [123, 456, 789, 101, 202, 303, 404, 505, 606, 707, 808, 909, 111, 222, 333, 444, 555, 666, 777, 888, 999]) == 5005\n assert candidate(nums = [1221, 2332, 3443, 4554, 5665, 6776, 7887, 8998, 9119]) == 21230\n assert candidate(nums = [123, 234, 345, 456, 567, 678, 789, 890, 901, 1012, 1213, 1314, 1415, 1516, 1617, 1718, 1819, 1920]) == 8561\n assert candidate(nums = [11111, 22222, 33333, 44444, 55555, 66666, 77777, 88888, 99999, 111111, 222222, 333333, 444444, 555555, 666666, 777777, 888888, 999999, 1000001, 1111111]) == 6388890\n assert candidate(nums = [100000000, 100000001, 100000002, 100000003, 100000004, 100000005]) == 11\n assert candidate(nums = [12345, 54321, 12345, 54321, 12345, 54321, 12345, 54321, 12345, 54321, 12345, 54321, 12345, 54321, 12345, 54321, 12345, 54321, 12345, 54321]) == 419760\n assert candidate(nums = [100000001, 200000002, 300000003, 400000004, 500000005, 600000006, 700000007, 800000008, 900000009]) == 2000000020\n assert candidate(nums = [100000000, 100000001, 100000002, 100000003, 100000004, 100000005, 100000006]) == 16\n assert candidate(nums = [100000000, 200000000, 300000000, 400000000, 500000000, 600000000, 700000000, 800000000, 900000000]) == 2000000005\n assert candidate(nums = [123456789, 987654321, 876543210, 765432109, 654321098, 543210987]) == 1308640766\n assert candidate(nums = [1001, 2002, 3003, 4004, 5005, 6006, 7007, 8008, 9009, 10001]) == 25016\n assert candidate(nums = [1111, 2222, 3333, 4444, 5555, 6666, 7777, 8888, 9999, 100001]) == 116666\n assert candidate(nums = [100000000, 200000000, 300000000, 400000000, 500000000]) == 600000003\n assert candidate(nums = [1001, 2002, 3003, 4004, 5005, 6006, 7007, 8008, 9009, 10101, 11111, 12212, 13331, 14441, 15551, 16661, 17771, 18881, 19991]) == 94905\n assert candidate(nums = [111, 222, 333, 444, 555, 666, 777, 888, 999, 1001]) == 2666\n assert candidate(nums = [123, 321, 456, 654, 789, 987, 1010, 1111, 2222, 3333]) == 6320\n assert candidate(nums = [100000001, 200000002, 300000003, 400000004, 500000005, 600000006, 700000007, 800000008, 900000009, 111111111, 222222222, 333333333, 444444444, 555555555, 666666666, 777777777, 888888888, 999999999]) == 4277777790\n assert candidate(nums = [123321, 213312, 321123, 432234, 543345, 654456, 765567, 876678, 987789, 110011]) == 2627834\n assert candidate(nums = [123, 234, 345, 456, 567, 678, 789, 890, 901, 1012, 2123, 3234, 4345, 5456, 6567, 7678, 8789, 9890]) == 44111\n assert candidate(nums = [111111111, 222222222, 333333333, 444444444, 555555555, 666666666, 777777777, 888888888, 999999999]) == 2222222220\n assert candidate(nums = [123456789, 123456788, 123456790, 123456791, 123456787, 123456779, 123456786, 123456792, 123456785, 123456793]) == 24670\n assert candidate(nums = [111111111, 111111112, 111111113, 111111114, 111111115, 111111116, 111111117, 111111118, 111111119, 111111120]) == 45\n assert candidate(nums = [121, 222, 333, 444, 555, 666, 777, 888, 999, 1001, 2002, 3003, 4004, 5005, 6006, 7007, 8008, 9009]) == 40040\n assert candidate(nums = [1234321, 4321234, 5678765, 8765678, 9876789, 123454321, 432151234, 567898765]) == 1113381111\n assert candidate(nums = [123321, 124421, 125521, 126621, 127721, 128821, 129921, 130031, 131131, 132231, 133331]) == 29040\n assert candidate(nums = [999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111, 100000000, 99999999, 88888888, 77777777, 66666666, 55555555]) == 4066666666\n assert candidate(nums = [999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 999999990]) == 45\n assert candidate(nums = [22, 33, 22, 33, 22, 22, 33, 22, 33, 22, 22, 33, 22, 33, 22, 22, 33, 22, 33, 22]) == 88\n assert candidate(nums = [1001, 2002, 3003, 4004, 5005, 6006, 7007, 8008, 9009, 10001]) == 25016\n assert candidate(nums = [1234321, 2345432, 3456543, 4567654, 5678765, 6789876, 7891098, 8910198, 9101109]) == 21088331\n assert candidate(nums = [123456789, 987654321, 111111111, 222222222, 333333333, 444444444, 555555555, 666666666, 777777777, 888888888]) == 2641975308\n assert candidate(nums = [10001, 20002, 30003, 40004, 50005, 60006, 70007, 80008, 90009, 10101, 11111, 12212, 13331, 14441, 15551, 16661, 17771, 18881, 19991, 20002, 21112, 22222, 23332, 24442, 25552]) == 356648\n assert candidate(nums = [987654321, 987654320, 987654319, 987654318, 987654317, 987654316, 987654315]) == 17297\n assert candidate(nums = [12321, 12321, 12321, 12321, 12321, 12321, 12321, 12321, 12321, 12321]) == 0\n assert candidate(nums = [111111, 222222, 333333, 444444, 555555, 666666, 777777, 888888, 999999, 1111111]) == 2777776\n assert candidate(nums = [123, 321, 231, 132, 111, 222, 333, 444, 555, 666]) == 1500\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 100\n assert candidate(nums = [98789, 87678, 76567, 65456, 54345, 43234, 32123, 21012, 10901, 98789]) == 265664\n assert candidate(nums = [123456789, 987654321, 123456789, 987654321, 123456789, 987654321, 123456789, 987654321]) == 3456790128\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1001]) == 2516\n assert candidate(nums = [12345678987654321, 98765432123456789, 87654321012345678, 76543210901234567, 65432109890123456]) == 340740252914814806\n assert candidate(nums = [100000000, 100000001, 100000002, 100000003, 100000004, 100000005, 100000006, 100000007, 100000008, 100000009]) == 37\n assert candidate(nums = [987654321, 876543218, 765432187, 654321876, 543218765, 432187654, 321876543, 218765432, 187654321]) == 2123471232\n assert candidate(nums = [111, 222, 333, 444, 555, 666, 777, 888, 999, 1111, 2222, 3333, 4444, 5555, 6666, 7777, 8888, 9999]) == 45000\n assert candidate(nums = [100001, 101001, 110111, 111111, 121212, 131313, 141414, 151515, 161616, 171717]) == 214139\n assert candidate(nums = [123210, 213210, 321230, 432340, 543450, 654560, 765670, 876780, 987890, 1098901]) == 2750361\n assert candidate(nums = [88888888, 77777777, 66666666, 55555555, 44444444, 33333333, 22222222, 11111111]) == 177777776\n assert candidate(nums = [999, 1001, 2002, 3003, 4004, 5005, 6006, 7007, 8008, 9009, 10001]) == 29022\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 50\n assert candidate(nums = [1221, 1331, 1441, 1551, 1661, 1771, 1881, 1991, 2002, 2112]) == 2552\n assert candidate(nums = [123, 132, 213, 231, 312, 321, 432, 423, 342, 324, 243, 234, 543, 534, 453, 435, 354, 345, 654, 645]) == 2343\n assert candidate(nums = [121, 131, 141, 151, 161, 171, 181, 191, 202, 212]) == 252\n assert candidate(nums = [987654321, 987654320, 987654319, 987654318, 987654317, 987654316, 987654315]) == 17297\n assert candidate(nums = [12321, 21321, 32123, 43234, 54345, 65456, 76567]) == 130603\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 56\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 25\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 1000\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205, 215, 225, 235, 245, 255, 265, 275, 285, 295, 305, 315, 325, 335, 345, 355, 365, 375, 385, 395]) == 4000\n assert candidate(nums = [12345, 54321, 67890, 90876, 12345, 54321, 67890, 90876]) == 184200\n assert candidate(nums = [12321, 45654, 78987, 10101, 11111, 98789, 1234321, 4567654, 112211]) == 5933788\n assert candidate(nums = [111111111, 222222222, 333333333, 444444444, 555555555, 666666666, 777777777]) == 1333333332\n assert candidate(nums = [11111111, 22222222, 33333333, 44444444, 55555555, 66666666, 77777777, 88888888, 99999999, 100000000]) == 266666665\n assert candidate(nums = [123456789, 123456788, 123456787, 123456786, 123456785, 123456784, 123456783, 123456782, 123456781, 123456780]) == 24635\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 100\n assert candidate(nums = [10001, 20002, 30003, 40004, 50005, 60006, 70007, 80008, 90009, 110011]) == 260026\n assert candidate(nums = [12321, 23432, 34543, 45654, 56765, 67876, 78987, 89098, 90109, 10101]) == 256784\n assert candidate(nums = [123456789, 987654321, 111222333, 333222111, 555555555]) == 1308530976\n assert candidate(nums = [1001, 2002, 3003, 4004, 5005, 6006, 7007, 8008, 9009]) == 20020\n assert candidate(nums = [1221, 2332, 3443, 4554, 5665, 6776, 7887, 8998, 10101, 20202, 30303, 40404, 50505, 60606, 70707, 80808, 90909, 111111, 222222, 333333]) == 1019729\n assert candidate(nums = [111, 222, 333, 444, 555, 666, 777, 888, 999, 1010]) == 2675\n assert candidate(nums = [1000000000, 999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111, 100000000, 99999999, 88888888, 77777777, 66666666, 55555555, 44444444, 33333333, 22222222, 11111111]) == 5400000000\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1001, 1111, 1221, 1331, 1441, 1551, 1661, 1771, 1881, 1991]) == 9414\n assert candidate(nums = [12345, 54321, 11111, 22222, 33333, 44444, 55555, 66666, 77777, 88888, 99999, 10101, 20202, 30303, 40404, 50505, 60606, 70707, 80808, 90909]) == 471266\n assert candidate(nums = [100000001, 200000002, 300000003, 400000004, 500000005, 600000006]) == 900000009\n assert candidate(nums = [111111, 222222, 333333, 444444, 555555, 666666, 777777, 888888, 999999, 1000001, 1100011, 1200021, 1300031, 1400041, 1500051]) == 5389047\n assert candidate(nums = [101010101, 202020202, 303030303, 404040404, 505050505, 606060606, 707070707, 808080808, 909090909]) == 2020202020\n assert candidate(nums = [999, 1001, 2002, 3003, 4004, 5005, 6006, 7007, 8008, 9009]) == 24026\n assert candidate(nums = [10001, 10001, 10001, 10001, 10001, 10001, 10001, 10001, 10001, 10001, 10001, 10001, 10001, 10001, 10001, 10001, 10001, 10001, 10001, 10001]) == 0\n assert candidate(nums = [12321, 23432, 34543, 45654, 56765, 67876, 78987]) == 133332\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 111, 222, 333, 444, 555, 666, 777, 888, 999, 1001, 1111]) == 5292\n assert candidate(nums = [111111111, 222222222, 333333333, 444444444, 555555555, 666666666, 777777777, 888888888, 999999999]) == 2222222220\n assert candidate(nums = [121, 131, 141, 151, 161, 171, 181, 191, 202, 212, 222, 232, 242, 252, 262, 272, 282, 292, 303]) == 909\n assert candidate(nums = [987654321, 876543210, 765432109, 654321098, 543210987, 432109876, 321098765, 210987654, 109876543, 98765432]) == 2654323455\n assert candidate(nums = [999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990]) == 45\n assert candidate(nums = [111111111, 222222222, 333333333, 444444444, 555555555, 666666666, 777777777, 888888888, 999999999, 1000000000]) == 2666666665\n assert candidate(nums = [123, 321, 231, 132, 312, 213, 456, 654, 564, 465]) == 1449\n assert candidate(nums = [1001, 2002, 3003, 4004, 5005, 6006, 7007, 8008, 9009, 11001]) == 26016\n assert candidate(nums = [123, 321, 456, 654, 789, 987, 10101]) == 10979\n assert candidate(nums = [99999999, 88888888, 77777777, 66666666, 55555555, 44444444, 33333333, 22222222, 11111111, 10101010]) == 267676765\n assert candidate(nums = [111, 222, 333, 444, 555, 666, 777, 888, 999, 1001, 2002, 3003, 4004, 5005]) == 13794\n assert candidate(nums = [1000000000, 999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111]) == 2666666665\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minimumCost", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "long long minimumCost(vector& nums) {", "container": "Solution", "callable": "minimumCost", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "long long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2968, "task_id": "apply-operations-to-maximize-frequency-score", "difficulty": "Hard", "problem_description": "You are given a 0-indexed integer array nums and an integer k.\nYou can perform the following operation on the array at most k times:\n\nChoose any index i from the array and increase or decrease nums[i] by 1.\n\nThe score of the final array is the frequency of the most frequent element in the array.\nReturn the maximum score you can achieve.\nThe frequency of an element is the number of occurences of that element in the array.\n \nExample 1:\n\nInput: nums = [1,2,6,4], k = 3\nOutput: 3\nExplanation: We can do the following operations on the array:\n- Choose i = 0, and increase the value of nums[0] by 1. The resulting array is [2,2,6,4].\n- Choose i = 3, and decrease the value of nums[3] by 1. The resulting array is [2,2,6,3].\n- Choose i = 3, and decrease the value of nums[3] by 1. The resulting array is [2,2,6,2].\nThe element 2 is the most frequent in the final array so our score is 3.\nIt can be shown that we cannot achieve a better score.\n\nExample 2:\n\nInput: nums = [1,4,4,2,4], k = 0\nOutput: 3\nExplanation: We cannot apply any operations so our score will be the frequency of the most frequent element in the original array, which is 3.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 109\n0 <= k <= 1014\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1000000000],k = 1000000000000) == 1\n assert candidate(nums = [1, 3, 3, 3, 7, 8, 9],k = 4) == 4\n assert candidate(nums = [1, 3, 5, 7, 9],k = 10) == 4\n assert candidate(nums = [1, 4, 4, 2, 4],k = 0) == 3\n assert candidate(nums = [5, 5, 5, 5, 5],k = 10) == 5\n assert candidate(nums = [1, 1000000000],k = 1000000000) == 2\n assert candidate(nums = [1000000000, 1000000000, 1000000000],k = 1000000000) == 3\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3],k = 4) == 7\n assert candidate(nums = [1, 2, 3],k = 2) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 0) == 10\n assert candidate(nums = [1, 2, 6, 4],k = 3) == 3\n assert candidate(nums = [1, 1000000000, 1, 1000000000],k = 1000000000) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 4\n assert candidate(nums = [1, 1, 1, 1, 1],k = 10) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 20) == 9\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 0) == 10\n assert candidate(nums = [10, 20, 30, 40, 50],k = 100) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 15) == 7\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 0) == 10\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 10) == 9\n assert candidate(nums = [1, 2, 3, 4, 5],k = 10) == 5\n assert candidate(nums = [1, 1000000000],k = 500000000) == 1\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],k = 0) == 10\n assert candidate(nums = [1000000000, 1, 1000000000, 1],k = 1000000000) == 3\n assert candidate(nums = [1, 3, 5, 7, 9],k = 25) == 5\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4],k = 5) == 8\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 1000) == 10\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],k = 50) == 15\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55],k = 250) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 1000) == 20\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 20) == 12\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 150) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 25) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 100) == 14\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],k = 20) == 15\n assert candidate(nums = [5, 5, 5, 10, 10, 15, 15, 15, 20, 20, 25],k = 30) == 8\n assert candidate(nums = [2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 5],k = 5) == 8\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5],k = 20) == 20\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 50) == 32\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 0) == 20\n assert candidate(nums = [1, 2, 2, 2, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],k = 20) == 15\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 100) == 21\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],k = 1000) == 91\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 20) == 6\n assert candidate(nums = [1, 3, 3, 3, 3, 3, 5, 5, 5, 5, 5],k = 20) == 11\n assert candidate(nums = [10, 10, 10, 20, 20, 30, 30, 30, 40, 40, 40, 50, 50, 50, 50],k = 200) == 15\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7],k = 25) == 17\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],k = 30) == 15\n assert candidate(nums = [1, 1000000000, 1000000000, 1000000000, 1],k = 1000000000) == 4\n assert candidate(nums = [1, 3, 3, 3, 3, 5, 5, 7, 9, 9, 11, 11, 13, 13, 15],k = 30) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 500) == 20\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 5],k = 15) == 12\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 500) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3],k = 10) == 15\n assert candidate(nums = [1, 1000000000, 2, 999999998, 3, 999999996, 4, 999999994],k = 1000000000) == 5\n assert candidate(nums = [1, 3, 3, 5, 5, 5, 7, 9, 11, 11],k = 15) == 8\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109],k = 50) == 10\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4],k = 15) == 14\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 1000) == 20\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 1000) == 10\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],k = 10000) == 20\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 50) == 10\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 50) == 20\n assert candidate(nums = [1, 1000000000, 500000000, 750000000, 250000000],k = 100000000000) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 100) == 20\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 0) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 1000) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 150) == 20\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 0) == 20\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6],k = 30) == 24\n assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50],k = 100) == 9\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000],k = 0) == 5\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 30) == 15\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000],k = 0) == 6\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 50) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 500) == 20\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 10\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9],k = 100) == 36\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 100) == 6\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 25) == 23\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8],k = 50) == 30\n assert candidate(nums = [1, 2, 6, 4, 8, 10, 3, 5, 7, 9],k = 15) == 7\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 10],k = 50) == 29\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10],k = 100) == 30\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 0) == 15\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995],k = 10000000000) == 6\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000],k = 1000000000000) == 10\n assert candidate(nums = [1, 1000000000],k = 1000000000) == 2\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5],k = 100) == 21\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2],k = 10) == 10\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 100) == 15\n assert candidate(nums = [1, 1000000000, 1, 1000000000, 1, 1000000000],k = 1500000000) == 4\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 3],k = 5) == 9\n assert candidate(nums = [5, 5, 5, 1, 1, 1, 1, 1, 1, 1],k = 10) == 9\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000],k = 1000000000) == 5\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000],k = 100000000000) == 4\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().maxFrequencyScore", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxFrequencyScore(vector& nums, long long k) {", "container": "Solution", "callable": "maxFrequencyScore", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "k", "type": "long long"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2970, "task_id": "count-the-number-of-incremovable-subarrays-i", "difficulty": "Easy", "problem_description": "You are given a 0-indexed array of positive integers nums.\nA subarray of nums is called incremovable if nums becomes strictly increasing on removing the subarray. For example, the subarray [3, 4] is an incremovable subarray of [5, 3, 4, 6, 7] because removing this subarray changes the array [5, 3, 4, 6, 7] to [5, 6, 7] which is strictly increasing.\nReturn the total number of incremovable subarrays of nums.\nNote that an empty array is considered strictly increasing.\nA subarray is a contiguous non-empty sequence of elements within an array.\n \nExample 1:\n\nInput: nums = [1,2,3,4]\nOutput: 10\nExplanation: The 10 incremovable subarrays are: [1], [2], [3], [4], [1,2], [2,3], [3,4], [1,2,3], [2,3,4], and [1,2,3,4], because on removing any one of these subarrays nums becomes strictly increasing. Note that you cannot select an empty subarray.\n\nExample 2:\n\nInput: nums = [6,5,7,8]\nOutput: 7\nExplanation: The 7 incremovable subarrays are: [5], [6], [5,7], [6,5], [5,7,8], [6,5,7] and [6,5,7,8].\nIt can be shown that there are only 7 incremovable subarrays in nums.\n\nExample 3:\n\nInput: nums = [8,7,6,6]\nOutput: 3\nExplanation: The 3 incremovable subarrays are: [8,7,6], [7,6,6], and [8,7,6,6]. Note that [8,7] is not an incremovable subarray because after removing [8,7] nums becomes [6,6], which is sorted in ascending order but not strictly increasing.\n\n \nConstraints:\n\n1 <= nums.length <= 50\n1 <= nums[i] <= 50\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 4, 3, 2, 1]) == 3\n assert candidate(nums = [6, 5, 7, 8]) == 7\n assert candidate(nums = [1, 3, 2, 4, 5]) == 11\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [1, 2, 2, 3, 4]) == 11\n assert candidate(nums = [1, 2, 2, 3]) == 8\n assert candidate(nums = [1, 2, 3, 4]) == 10\n assert candidate(nums = [1, 2]) == 3\n assert candidate(nums = [1, 1, 1, 1, 1]) == 3\n assert candidate(nums = [1, 2, 3, 5, 4, 6, 7]) == 19\n assert candidate(nums = [10, 20, 15, 25, 30]) == 11\n assert candidate(nums = [1, 2, 3, 2, 3, 4]) == 13\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 3\n assert candidate(nums = [2, 1]) == 3\n assert candidate(nums = [1, 2, 3, 4, 3]) == 8\n assert candidate(nums = [8, 7, 6, 6]) == 3\n assert candidate(nums = [1, 2, 3, 3, 4]) == 11\n assert candidate(nums = [10, 20, 15, 30, 25, 40]) == 9\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 8, 9, 10]) == 22\n assert candidate(nums = [5, 3, 4, 6, 7, 2, 3, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 17\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10]) == 22\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5]) == 7\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 25\n assert candidate(nums = [3, 5, 2, 8, 7, 10, 9, 11, 13, 12]) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9]) == 26\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 12\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 6, 6, 7]) == 9\n assert candidate(nums = [1, 2, 3, 5, 4, 6, 7, 8, 9]) == 29\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 71\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 3\n assert candidate(nums = [5, 10, 15, 20, 18, 25, 30, 35, 40]) == 29\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 21\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 1]) == 13\n assert candidate(nums = [10, 20, 30, 40, 50, 1, 2, 3, 4, 5]) == 11\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 12\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 14, 16, 18, 20, 19, 21, 23, 25, 24, 26, 28, 30]) == 45\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12]) == 6\n assert candidate(nums = [3, 1, 2, 1, 3, 4, 5, 6, 7]) == 12\n assert candidate(nums = [9, 1, 2, 3, 4, 5, 6, 7, 8, 10]) == 12\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4]) == 11\n assert candidate(nums = [1, 2, 3, 2, 1]) == 5\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10]) == 9\n assert candidate(nums = [1, 5, 3, 7, 9, 2, 11, 13, 12, 14]) == 9\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 6, 7, 8, 9, 10, 11]) == 46\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5]) == 25\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 26\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4]) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 51\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 12\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13]) == 9\n assert candidate(nums = [30, 20, 10, 20, 30, 40, 30, 20, 10]) == 3\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 55\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 4\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 4\n assert candidate(nums = [5, 6, 2, 7, 8, 10]) == 13\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 6\n assert candidate(nums = [5, 1, 2, 3, 4, 5, 6]) == 9\n assert candidate(nums = [3, 5, 6, 7, 8, 2, 3, 4, 5, 6]) == 15\n assert candidate(nums = [1, 2, 3, 6, 5, 4, 7, 8, 9, 10]) == 29\n assert candidate(nums = [10, 20, 15, 30, 25, 40, 10, 20, 30]) == 9\n assert candidate(nums = [3, 4, 3, 5, 6, 7, 8, 9, 10, 11, 12]) == 28\n assert candidate(nums = [1, 2, 3, 5, 4, 6, 7, 8, 10, 9, 11]) == 15\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 4, 5, 6]) == 22\n assert candidate(nums = [10, 20, 30, 25, 35, 40, 30, 45]) == 11\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 3\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 4\n assert candidate(nums = [2, 2, 2, 2, 2]) == 3\n assert candidate(nums = [10, 20, 30, 25, 40, 50, 15, 25, 35, 45]) == 17\n assert candidate(nums = [10, 20, 30, 25, 35, 40, 38, 45]) == 12\n assert candidate(nums = [3, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 38\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 6, 7, 8, 9, 10, 11]) == 43\n assert candidate(nums = [1, 5, 2, 6, 3, 7, 4, 8, 5, 9]) == 8\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4]) == 4\n assert candidate(nums = [1, 3, 5, 4, 6, 7, 8, 9]) == 23\n assert candidate(nums = [3, 2, 1, 4, 5, 6, 7, 8, 9, 10]) == 17\n assert candidate(nums = [5, 6, 7, 8, 9, 1, 2, 3, 4]) == 10\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 41\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41]) == 3\n assert candidate(nums = [20, 25, 15, 30, 35, 28, 40, 45, 50, 55, 60]) == 21\n assert candidate(nums = [1, 2, 3, 4, 3, 5, 6, 7, 8, 9, 10]) == 38\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 6, 7, 8, 9]) == 20\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 3, 4, 5, 6, 7, 8, 9]) == 42\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 21]) == 5\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 6, 5, 7, 8, 7, 9]) == 9\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7]) == 9\n assert candidate(nums = [1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 21\n assert candidate(nums = [1, 3, 5, 2, 4, 6, 7, 8, 9, 10]) == 29\n assert candidate(nums = [5, 4, 3, 2, 1]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 120\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 81\n assert candidate(nums = [1, 3, 5, 7, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 7\n assert candidate(nums = [10, 20, 15, 30, 25, 40, 35, 50]) == 9\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 92\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(nums = [1, 2, 3, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 6\n assert candidate(nums = [5, 4, 3, 2, 1, 6, 7, 8, 9]) == 11\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10]) == 28\n assert candidate(nums = [1, 3, 2, 4, 5, 3, 6, 7, 5, 8, 9, 7, 10, 11, 8]) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 45\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5]) == 36\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 10, 12, 14, 16]) == 34\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 66\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 4, 5]) == 18\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 4, 5]) == 18\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 26\n assert candidate(nums = [1, 3, 5, 7, 9, 10, 8, 11, 12]) == 26\n assert candidate(nums = [1, 2, 3, 4, 5, 3, 4, 5, 6, 7]) == 30\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2]) == 9\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 3\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 29\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 21\n assert candidate(nums = [1, 2, 3, 4, 5, 3, 4, 5]) == 18\n assert candidate(nums = [1, 3, 5, 7, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1]) == 7\n assert candidate(nums = [8, 9, 7, 10, 11, 12, 13, 6]) == 4\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().incremovableSubarrayCount", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int incremovableSubarrayCount(vector& nums) {", "container": "Solution", "callable": "incremovableSubarrayCount", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2971, "task_id": "find-polygon-with-the-largest-perimeter", "difficulty": "Medium", "problem_description": "You are given an array of positive integers nums of length n.\nA polygon is a closed plane figure that has at least 3 sides. The longest side of a polygon is smaller than the sum of its other sides.\nConversely, if you have k (k >= 3) positive real numbers a1, a2, a3, ..., ak where a1 <= a2 <= a3 <= ... <= ak and a1 + a2 + a3 + ... + ak-1 > ak, then there always exists a polygon with k sides whose lengths are a1, a2, a3, ..., ak.\nThe perimeter of a polygon is the sum of lengths of its sides.\nReturn the largest possible perimeter of a polygon whose sides can be formed from nums, or -1 if it is not possible to create a polygon.\n \nExample 1:\n\nInput: nums = [5,5,5]\nOutput: 15\nExplanation: The only possible polygon that can be made from nums has 3 sides: 5, 5, and 5. The perimeter is 5 + 5 + 5 = 15.\n\nExample 2:\n\nInput: nums = [1,12,1,2,5,50,3]\nOutput: 12\nExplanation: The polygon with the largest perimeter which can be made from nums has 5 sides: 1, 1, 2, 3, and 5. The perimeter is 1 + 1 + 2 + 3 + 5 = 12.\nWe cannot have a polygon with either 12 or 50 as the longest side because it is not possible to include 2 or more smaller sides that have a greater sum than either of them.\nIt can be shown that the largest possible perimeter is 12.\n\nExample 3:\n\nInput: nums = [5,5,50]\nOutput: -1\nExplanation: There is no possible way to form a polygon from nums, as a polygon has at least 3 sides and 50 > 5 + 5.\n\n \nConstraints:\n\n3 <= n <= 105\n1 <= nums[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 5, 1, 12, 3, 7]) == 38\n assert candidate(nums = [5, 5, 50]) == -1\n assert candidate(nums = [5, 5, 5]) == 15\n assert candidate(nums = [10, 5, 25, 25, 10]) == 75\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6]) == 21\n assert candidate(nums = [3, 6, 2, 3, 5, 4, 1]) == 24\n assert candidate(nums = [3, 6, 2, 3, 5, 10]) == 29\n assert candidate(nums = [10, 20, 30, 40, 50]) == 150\n assert candidate(nums = [1000000000, 1000000000, 1000000000]) == 3000000000\n assert candidate(nums = [1, 1, 1, 1, 1, 1]) == 6\n assert candidate(nums = [1000000000, 1000000000, 1000000000]) == 3000000000\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 30\n assert candidate(nums = [1, 12, 1, 2, 5, 50, 3]) == 12\n assert candidate(nums = [3, 6, 2, 3, 5, 4]) == 23\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [10, 5, 1, 1, 1, 1]) == 4\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 31\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 1050\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 5500\n assert candidate(nums = [1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 211\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == 21000\n assert candidate(nums = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144]) == 376\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 45\n assert candidate(nums = [3, 6, 12, 24, 48, 96, 192, 384, 768, 1536, 3072, 6144, 12288, 24576, 49152, 98304, 196608, 393216, 786432, 1572864]) == -1\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 5000000000\n assert candidate(nums = [1000000000, 900000000, 800000000, 700000000, 600000000, 500000000, 400000000, 300000000, 200000000, 100000000]) == 5500000000\n assert candidate(nums = [1000000000, 500000000, 300000000, 200000000, 100000000]) == 2100000000\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7]) == 84\n assert candidate(nums = [1000000000, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 9\n assert candidate(nums = [7, 10, 5, 8, 9, 6, 4, 2, 3, 1]) == 55\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 150\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81]) == 1810\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 465\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == 42\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == 165\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == -1\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == 625\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 120\n assert candidate(nums = [1, 2, 3, 6, 11, 20, 37, 68, 125, 230]) == 503\n assert candidate(nums = [100, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == 21000\n assert candidate(nums = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]) == 143\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1]) == 3000000001\n assert candidate(nums = [100, 200, 300, 400, 500]) == 1500\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 209\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 275\n assert candidate(nums = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 165\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 60\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 225\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == 240\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991]) == 9999999955\n assert candidate(nums = [3, 6, 2, 3, 5, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 33\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(nums = [50, 60, 70, 80, 90, 100, 110]) == 560\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 180\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 465\n assert candidate(nums = [2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22]) == 247\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 50, 150, 250, 350, 450, 550, 650, 750, 850, 950]) == 10500\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 110\n assert candidate(nums = [3, 6, 2, 3, 5, 4, 1, 8, 7, 9]) == 48\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 100\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150]) == 2325\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 32\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 7000000000\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 12000\n assert candidate(nums = [100, 200, 300, 400, 500, 600]) == 2100\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(nums = [1, 1000000000, 1000000000, 1000000000]) == 3000000001\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 209\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 780\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996]) == 4999999990\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 1200\n assert candidate(nums = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765]) == 17710\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(nums = [1, 2, 3, 4, 5, 100, 200, 300, 400, 500]) == 1515\n assert candidate(nums = [29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 225\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 1050\n assert candidate(nums = [50, 40, 30, 20, 10, 5, 3, 1]) == 159\n assert candidate(nums = [1, 2, 3, 6, 10, 18, 33, 59, 107, 198, 374, 699, 1302, 2441, 4537, 8380, 15619, 29036, 54256, 100901]) == 217982\n assert candidate(nums = [33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33]) == 660\n assert candidate(nums = [7, 10, 5, 8, 6, 9, 3, 4, 2, 1]) == 55\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 550\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 1050\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 20\n assert candidate(nums = [1, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 6000000001\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 1000\n assert candidate(nums = [7, 10, 14, 21, 28, 35, 42, 49, 56, 63]) == 325\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 5500\n assert candidate(nums = [1, 3, 2, 4, 5, 9, 7, 8, 6, 10]) == 55\n assert candidate(nums = [100000000, 200000000, 300000000, 400000000, 500000000, 600000000, 700000000, 800000000, 900000000, 1000000000]) == 5500000000\n assert candidate(nums = [1, 1000000000, 1, 1, 1, 1, 1, 1, 1, 1]) == 9\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().largestPerimeter", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "long long largestPerimeter(vector& nums) {", "container": "Solution", "callable": "largestPerimeter", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "long long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2972, "task_id": "count-the-number-of-incremovable-subarrays-ii", "difficulty": "Hard", "problem_description": "You are given a 0-indexed array of positive integers nums.\nA subarray of nums is called incremovable if nums becomes strictly increasing on removing the subarray. For example, the subarray [3, 4] is an incremovable subarray of [5, 3, 4, 6, 7] because removing this subarray changes the array [5, 3, 4, 6, 7] to [5, 6, 7] which is strictly increasing.\nReturn the total number of incremovable subarrays of nums.\nNote that an empty array is considered strictly increasing.\nA subarray is a contiguous non-empty sequence of elements within an array.\n \nExample 1:\n\nInput: nums = [1,2,3,4]\nOutput: 10\nExplanation: The 10 incremovable subarrays are: [1], [2], [3], [4], [1,2], [2,3], [3,4], [1,2,3], [2,3,4], and [1,2,3,4], because on removing any one of these subarrays nums becomes strictly increasing. Note that you cannot select an empty subarray.\n\nExample 2:\n\nInput: nums = [6,5,7,8]\nOutput: 7\nExplanation: The 7 incremovable subarrays are: [5], [6], [5,7], [6,5], [5,7,8], [6,5,7] and [6,5,7,8].\nIt can be shown that there are only 7 incremovable subarrays in nums.\n\nExample 3:\n\nInput: nums = [8,7,6,6]\nOutput: 3\nExplanation: The 3 incremovable subarrays are: [8,7,6], [7,6,6], and [8,7,6,6]. Note that [8,7] is not an incremovable subarray because after removing [8,7] nums becomes [6,6], which is sorted in ascending order but not strictly increasing.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 3, 2, 4, 5]) == 11\n assert candidate(nums = [6, 5, 7, 8]) == 7\n assert candidate(nums = [1, 3, 5, 4, 6, 7, 8]) == 19\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 8, 9, 10]) == 22\n assert candidate(nums = [1, 2, 2, 3]) == 8\n assert candidate(nums = [1, 1, 1, 1]) == 3\n assert candidate(nums = [2, 1]) == 3\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [1, 2, 3, 4]) == 10\n assert candidate(nums = [10, 9, 8, 7, 6, 5]) == 3\n assert candidate(nums = [1, 2, 3, 5, 4, 6, 7, 8, 9, 10]) == 34\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5]) == 7\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 55\n assert candidate(nums = [1, 3, 2]) == 5\n assert candidate(nums = [1, 2, 3, 5, 4, 6, 7, 8, 9]) == 29\n assert candidate(nums = [1, 1, 1, 1, 1]) == 3\n assert candidate(nums = [10, 20, 15, 25, 30]) == 11\n assert candidate(nums = [8, 7, 6, 6]) == 3\n assert candidate(nums = [1, 2]) == 3\n assert candidate(nums = [1, 2, 3, 2, 1]) == 5\n assert candidate(nums = [10, 20, 30, 40, 50, 15, 25, 35, 45, 55, 60, 65, 70]) == 44\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99]) == 1275\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10]) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1]) == 22\n assert candidate(nums = [1, 2, 3, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 11\n assert candidate(nums = [1, 2, 3, 4, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 88\n assert candidate(nums = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6, 11, 12]) == 27\n assert candidate(nums = [10, 20, 30, 40, 35, 50, 60, 70, 80, 90, 100]) == 39\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 176\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 21\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 91\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 32\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 71\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 66\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 140\n assert candidate(nums = [1, 2, 3, 4, 5, 3, 6, 7, 8, 9, 10]) == 39\n assert candidate(nums = [1000000000, 999999999, 1000000001, 1000000002, 1000000003, 999999998, 1000000004, 1000000005, 1000000006, 1000000007]) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1]) == 14\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 21\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 3\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 210\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 1, 2, 3, 4]) == 41\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6]) == 14\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 111\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 25]) == 56\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 2]) == 23\n assert candidate(nums = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 12\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1, 2, 3, 4, 5]) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 465\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 76\n assert candidate(nums = [1, 2, 3, 4, 5, 100, 3, 4, 5, 6, 7, 8, 9, 10]) == 49\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13, 14, 15]) == 13\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 63\n assert candidate(nums = [1, 2, 3, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 37\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 66\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 820\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 4\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 2, 4, 6, 8, 10, 12, 14]) == 44\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 1, 2, 3, 4]) == 14\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 19]) == 39\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 69\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 2, 3, 4, 5]) == 35\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5]) == 16\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 21\n assert candidate(nums = [10, 20, 10, 30, 20, 40, 30, 50, 40, 60, 50, 70, 60, 80, 70, 90, 80, 100, 90, 110]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 12\n assert candidate(nums = [1, 3, 5, 2, 4, 6, 7, 8, 10, 9]) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 3, 4, 5, 6, 7]) == 38\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 12\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 4\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 12, 13, 14, 15]) == 22\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4]) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 1]) == 16\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 122\n assert candidate(nums = [10, 1, 20, 2, 30, 3, 40, 4, 50, 5, 60, 6, 70, 7, 80, 8, 90, 9, 100, 10]) == 3\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4]) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 1]) == 42\n assert candidate(nums = [1, 3, 2, 4, 5, 3, 6, 7, 8, 9, 10]) == 20\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10]) == 26\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == 23\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 10, 20, 30, 40, 50]) == 115\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 3, 5, 7, 9, 11]) == 47\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10]) == 12\n assert candidate(nums = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 17\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 4, 3, 2, 1, 11, 12, 13, 14, 15]) == 67\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 76\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10]) == 56\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 45\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 4, 6, 8, 10, 1, 3, 5, 7, 9]) == 36\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 10, 9]) == 19\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 496\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 41\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 86\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 6, 7, 8, 9, 10, 11, 12]) == 49\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 325\n assert candidate(nums = [1, 3, 5, 7, 9, 8, 10, 12, 14, 16, 18, 17]) == 12\n assert candidate(nums = [20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58]) == 210\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 82\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 88\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 29\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 86\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == 26\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 66\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4]) == 31\n assert candidate(nums = [1, 10, 20, 30, 40, 50, 5, 6, 7, 8, 9, 10]) == 19\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 66\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6]) == 32\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 66\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 66\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 66\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 175\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3]) == 27\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 32\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 12\n assert candidate(nums = [10, 20, 30, 40, 50, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5]) == 36\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 66\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 1275\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 121\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6]) == 8\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 56\n assert candidate(nums = [5, 7, 9, 10, 6, 8, 11, 12, 13, 14]) == 30\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 11]) == 31\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 4, 6, 8, 10, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == 102\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1]) == 17\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 25, 35, 45, 55, 65, 75, 85, 95]) == 116\n assert candidate(nums = [1, 3, 2, 4, 5, 7, 6, 8, 9, 11, 10, 12, 13, 15, 14, 16, 17, 19, 18, 20]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 1]) == 32\n assert candidate(nums = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 83\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4]) == 27\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 26\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1]) == 22\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 21\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9]) == 23\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().incremovableSubarrayCount", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "long long incremovableSubarrayCount(vector& nums) {", "container": "Solution", "callable": "incremovableSubarrayCount", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "long long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2973, "task_id": "find-number-of-coins-to-place-in-tree-nodes", "difficulty": "Hard", "problem_description": "You are given an undirected tree with n nodes labeled from 0 to n - 1, and rooted at node 0. You are given a 2D integer array edges of length n - 1, where edges[i] = [ai, bi] indicates that there is an edge between nodes ai and bi in the tree.\nYou are also given a 0-indexed integer array cost of length n, where cost[i] is the cost assigned to the ith node.\nYou need to place some coins on every node of the tree. The number of coins to be placed at node i can be calculated as:\n\nIf size of the subtree of node i is less than 3, place 1 coin.\nOtherwise, place an amount of coins equal to the maximum product of cost values assigned to 3 distinct nodes in the subtree of node i. If this product is negative, place 0 coins.\n\nReturn an array coin of size n such that coin[i] is the number of coins placed at node i.\n \nExample 1:\n\n\nInput: edges = [[0,1],[0,2],[0,3],[0,4],[0,5]], cost = [1,2,3,4,5,6]\nOutput: [120,1,1,1,1,1]\nExplanation: For node 0 place 6 * 5 * 4 = 120 coins. All other nodes are leaves with subtree of size 1, place 1 coin on each of them.\n\nExample 2:\n\n\nInput: edges = [[0,1],[0,2],[1,3],[1,4],[1,5],[2,6],[2,7],[2,8]], cost = [1,4,2,3,5,7,8,-4,2]\nOutput: [280,140,32,1,1,1,1,1,1]\nExplanation: The coins placed on each node are:\n- Place 8 * 7 * 5 = 280 coins on node 0.\n- Place 7 * 5 * 4 = 140 coins on node 1.\n- Place 8 * 2 * 2 = 32 coins on node 2.\n- All other nodes are leaves with subtree of size 1, place 1 coin on each of them.\n\nExample 3:\n\n\nInput: edges = [[0,1],[0,2]], cost = [1,2,-2]\nOutput: [0,1,1]\nExplanation: Node 1 and 2 are leaves with subtree of size 1, place 1 coin on each of them. For node 0 the only possible product of cost is 2 * 1 * -2 = -4. Hence place 0 coins on node 0.\n\n \nConstraints:\n\n2 <= n <= 2 * 104\nedges.length == n - 1\nedges[i].length == 2\n0 <= ai, bi < n\ncost.length == n\n1 <= |cost[i]| <= 104\nThe input is generated such that edges represents a valid tree.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7]],cost = [3, 2, 1, -1, -2, -3, -4, -5]) == [60, 40, 6, 0, 1, 1, 1, 1]\n assert candidate(edges = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5], [2, 6]],cost = [1, 2, 3, 4, 5, -1, 6]) == [120, 120, 1, 0, 1, 1, 1]\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [3, 7]],cost = [1, -2, 3, -4, 5, -6, 7, -8]) == [336, 60, 1, 1, 1, 1, 1, 1]\n assert candidate(edges = [[0, 1], [0, 2], [0, 3]],cost = [1, -2, -3, -4]) == [12, 1, 1, 1]\n assert candidate(edges = [[0, 1], [0, 2]],cost = [1, 2, -2]) == [0, 1, 1]\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5]],cost = [1, 2, 3, 4, 5, 6]) == [120, 1, 1, 1, 1, 1]\n assert candidate(edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7]],cost = [1, 2, 3, 4, 5, 6, 7, 8]) == [336, 336, 90, 224, 1, 1, 1, 1]\n assert candidate(edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7]],cost = [3, 2, -1, 4, -5, 6, -7, 8]) == [280, 280, 30, 0, 1, 1, 1, 1]\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [1, 5], [2, 6], [2, 7], [2, 8]],cost = [1, 4, 2, 3, 5, 7, 8, -4, 2]) == [280, 140, 32, 1, 1, 1, 1, 1, 1]\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [3, 7]],cost = [10, 20, 30, 40, 50, 60, 70, 80]) == [336000, 60000, 1, 1, 1, 1, 1, 1]\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19], [9, 20], [9, 21], [10, 22], [10, 23], [11, 24], [11, 25]],cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]) == [15600, 15600, 4896, 9240, 15600, 1092, 1680, 2448, 3420, 4620, 6072, 7800, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],cost = [100, -100, 200, 300, -300, 400, 500, -500, 600, 700, 800]) == [336000000, 336000000, 40000000, 0, 0, 1, 1, 1, 1, 1, 1]\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19], [9, 20], [9, 21]],cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22]) == [9240, 2184, 4896, 9240, 660, 1092, 1680, 2448, 3420, 4620, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13]],cost = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8]) == [294, 294, 0, 50, 0, 147, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15]],cost = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16]) == [3120, 2002, 1680, 0, 660, 0, 1680, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]],cost = [10000, -9999, 9998, -9997, 9996, -9995, 9994, -9993, 9992, -9991, 9990, -9989, 9988, -9987, 9986]) == [999600030000, 999200189988, 998200869890, 998201009832, 0, 997202469340, 0, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [990, 990, 126, 288, 550, 1, 1, 1, 1, 1, 1]\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]],cost = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15]) == [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(edges = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5], [5, 6], [5, 7], [2, 8], [2, 9]],cost = [5, -5, 10, -10, 15, -15, 20, -20, 25, -25]) == [12500, 12500, 0, 6000, 1, 6000, 1, 1, 1, 1]\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]],cost = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50, 60, -60, 70, -70, 80]) == [336000, 336000, 336000, 336000, 336000, 336000, 336000, 336000, 336000, 336000, 336000, 336000, 0, 1, 1]\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [1, 6], [2, 7], [2, 8], [2, 9], [3, 10], [3, 11], [3, 12]],cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) == [1716, 210, 720, 1716, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19], [9, 20], [9, 21]],cost = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220]) == [9240000, 2184000, 4896000, 9240000, 660000, 1092000, 1680000, 2448000, 3420000, 4620000, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [1, 6], [2, 7], [2, 8], [3, 9], [3, 10], [4, 11], [4, 12], [5, 13], [5, 14], [6, 15], [6, 16], [7, 17], [7, 18], [8, 19], [8, 20], [9, 21], [9, 22], [10, 23], [10, 24], [11, 25], [11, 26], [12, 27], [12, 28]],cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == [21924, 4080, 7980, 13800, 21924, 1260, 1904, 2736, 3780, 5060, 6600, 8424, 10556, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [1, 6], [2, 7], [2, 8], [3, 9], [3, 10], [4, 11], [4, 12], [5, 13], [5, 14], [6, 15], [6, 16], [7, 17], [7, 18], [8, 19], [8, 20], [9, 21], [9, 22], [10, 23], [10, 24]],cost = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500, 600, -600, 700, -700, 800, -800, 900, -900, 1000, -1000, 1100, -1100, 1200, -1200, 1300, -1300]) == [1716000000, 504000000, 990000000, 1716000000, 0, 168000000, 0, 360000000, 0, 660000000, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17]],cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]) == [4896, 2184, 4896, 360, 660, 1092, 1680, 2448, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13]],cost = [5, -3, 2, 8, -7, 1, 4, -6, 9, 2, -8, 5, 3, -4]) == [504, 378, 160, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [1, 10], [1, 11], [2, 12], [2, 13], [3, 14], [3, 15], [4, 16], [4, 17], [5, 18], [5, 19], [6, 20], [6, 21], [7, 22], [7, 23], [8, 24], [8, 25], [9, 26], [9, 27]],cost = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, 2600, 2700, 2800, 2900]) == [19656000000, 264000000, 546000000, 960000000, 1530000000, 2280000000, 3234000000, 4416000000, 5850000000, 7560000000, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [5, 9], [5, 10]],cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [990, 360, 770, 288, 1, 660, 1, 1, 1, 1, 1]\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],cost = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11]],cost = [100, 50, 200, -10, -20, 300, 150, -5, -30, 25, 40, 60]) == [9000000, 9000000, 3600000, 7500, 15000, 720000, 1, 1, 1, 1, 1, 1]\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [2, 8], [3, 9], [3, 10], [3, 11], [4, 12], [4, 13], [5, 14], [5, 15], [6, 16], [6, 17], [7, 18], [7, 19], [8, 20], [8, 21]],cost = [2, 3, -2, 5, 6, -3, 1, -1, 4, -4, 7, 8, -5, -6, 9, 10, -7, -8, 11, 12, -9, -10, 13, 14, -11, -12]) == [1320, 540, 1080, 280, 180, 0, 56, 0, 360, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],cost = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == [100, 100, 100, 100, 100, 100, 100, 100, 1, 1]\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19], [9, 20], [9, 21]],cost = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15]],cost = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16]) == [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [1, 6], [2, 7], [2, 8], [3, 9], [3, 10], [4, 11], [4, 12], [5, 13], [5, 14], [6, 15], [6, 16], [7, 17], [7, 18], [8, 19], [8, 20], [9, 21], [9, 22], [10, 23], [10, 24]],cost = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500]) == [13800000000, 4080000000, 7980000000, 13800000000, 780000000, 1260000000, 1904000000, 2736000000, 3780000000, 5060000000, 6600000000, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]],cost = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24]],cost = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500, 600, -600, 700, -700, 800, -800, 900, -900, 1000, -1000, 1100, -1100, 1200, -1200, 1300, -1300, 1400, -1400]) == [1716000000, 1320000000, 1092000000, 720000000, 1320000000, 936000000, 0, 288000000, 0, 550000000, 0, 936000000, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]],cost = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1, 0, -1, -2, -4, -8]) == [125000000, 3875000, 116250, 2625, 0, 62, 480, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19], [9, 20], [9, 21], [10, 22], [10, 23], [11, 24], [11, 25]],cost = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, 2600]) == [15600000000, 15600000000, 4896000000, 9240000000, 15600000000, 1092000000, 1680000000, 2448000000, 3420000000, 4620000000, 6072000000, 7800000000, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],cost = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11]) == [880, 880, 0, 288, 0, 1, 1, 1, 1, 1, 1]\n assert candidate(edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23]],cost = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22, -23, -24]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10], [5, 11]],cost = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23]) == [9177, 4845, 6279, 1785, 1, 5313, 1, 1, 1, 1, 1, 1]\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],cost = [3, 1, 2, 5, -1, -2, -3, 7, 8, 6, 4]) == [336, 336, 12, 280, 0, 1, 1, 1, 1, 1, 1]\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15]],cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == [3360, 2184, 1920, 360, 660, 1092, 1680, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15]],cost = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16]) == [3360, 2184, 1920, 360, 0, 1092, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(edges = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5], [5, 6], [5, 7], [2, 8], [2, 9]],cost = [1, 2, 3, 4, -5, 6, -7, 8, 9, 10]) == [720, 720, 270, 280, 1, 0, 1, 1, 1, 1]\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]],cost = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20, 21]) == [7560, 7560, 7560, 7560, 7560, 7560, 7560, 7560, 7560, 7560, 7560, 7560, 7560, 7560, 7560, 7560, 7560, 7560, 0, 1, 1]\n"}, "metadata": {"canonical_parameter_names": ["edges", "cost"], "leetcode_dataset_entry_point": "Solution().placedCoins", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector placedCoins(vector>& edges, vector& cost) {", "container": "Solution", "callable": "placedCoins", "parameters": [{"name": "edges", "type": "vector>&"}, {"name": "cost", "type": "vector&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2974, "task_id": "minimum-number-game", "difficulty": "Easy", "problem_description": "You are given a 0-indexed integer array nums of even length and there is also an empty array arr. Alice and Bob decided to play a game where in every round Alice and Bob will do one move. The rules of the game are as follows:\n\nEvery round, first Alice will remove the minimum element from nums, and then Bob does the same.\nNow, first Bob will append the removed element in the array arr, and then Alice does the same.\nThe game continues until nums becomes empty.\n\nReturn the resulting array arr.\n \nExample 1:\n\nInput: nums = [5,4,2,3]\nOutput: [3,2,5,4]\nExplanation: In round one, first Alice removes 2 and then Bob removes 3. Then in arr firstly Bob appends 3 and then Alice appends 2. So arr = [3,2].\nAt the begining of round two, nums = [5,4]. Now, first Alice removes 4 and then Bob removes 5. Then both append in arr which becomes [3,2,5,4].\n\nExample 2:\n\nInput: nums = [2,5]\nOutput: [5,2]\nExplanation: In round one, first Alice removes 2 and then Bob removes 5. Then in arr firstly Bob appends and then Alice appends. So arr = [5,2].\n\n \nConstraints:\n\n2 <= nums.length <= 100\n1 <= nums[i] <= 100\nnums.length % 2 == 0\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [90, 100, 80, 70, 60, 50]) == [60, 50, 80, 70, 100, 90]\n assert candidate(nums = [100, 1, 99, 2, 98, 3]) == [2, 1, 98, 3, 100, 99]\n assert candidate(nums = [6, 2, 8, 4]) == [4, 2, 8, 6]\n assert candidate(nums = [10, 1, 3, 8, 7, 2]) == [2, 1, 7, 3, 10, 8]\n assert candidate(nums = [1, 2, 3, 4, 5, 6]) == [2, 1, 4, 3, 6, 5]\n assert candidate(nums = [10, 9, 8, 7, 6, 5]) == [6, 5, 8, 7, 10, 9]\n assert candidate(nums = [5, 4, 2, 3]) == [3, 2, 5, 4]\n assert candidate(nums = [4, 3, 2, 1, 6, 5]) == [2, 1, 4, 3, 6, 5]\n assert candidate(nums = [100, 1, 99, 2]) == [2, 1, 100, 99]\n assert candidate(nums = [2, 5]) == [5, 2]\n assert candidate(nums = [6, 4, 3, 2]) == [3, 2, 6, 4]\n assert candidate(nums = [1, 3, 2, 4]) == [2, 1, 4, 3]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19]\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140]) == [14, 7, 28, 21, 42, 35, 56, 49, 70, 63, 84, 77, 98, 91, 112, 105, 126, 119, 140, 133]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [2, 1, 4, 3, 6, 5, 8, 7, 10, 9]\n assert candidate(nums = [30, 20, 10, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == [20, 10, 40, 30, 60, 50, 80, 70, 100, 90, 120, 110, 140, 130, 160, 150, 180, 170, 200, 190]\n assert candidate(nums = [50, 40, 30, 20, 10, 1, 2, 3, 4, 5]) == [2, 1, 4, 3, 10, 5, 30, 20, 50, 40]\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19]\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11]\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56]) == [14, 7, 28, 21, 42, 35, 56, 49]\n assert candidate(nums = [41, 39, 37, 35, 33, 31, 29, 27]) == [29, 27, 33, 31, 37, 35, 41, 39]\n assert candidate(nums = [9, 1, 8, 2, 7, 3, 6, 4, 5, 10]) == [2, 1, 4, 3, 6, 5, 8, 7, 10, 9]\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19, 22, 21, 24, 23, 26, 25, 28, 27, 30, 29, 32, 31, 34, 33, 36, 35, 38, 37, 40, 39, 42, 41, 44, 43, 46, 45, 48, 47, 50, 49]\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == [92, 91, 94, 93, 96, 95, 98, 97, 100, 99]\n assert candidate(nums = [60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41]) == [42, 41, 44, 43, 46, 45, 48, 47, 50, 49, 52, 51, 54, 53, 56, 55, 58, 57, 60, 59]\n assert candidate(nums = [8, 7, 6, 5, 4, 3, 2, 1, 16, 15, 14, 13, 12, 11, 10, 9]) == [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15]\n assert candidate(nums = [42, 31, 25, 14, 19, 28, 37, 46, 5, 13]) == [13, 5, 19, 14, 28, 25, 37, 31, 46, 42]\n assert candidate(nums = [45, 67, 23, 89, 34, 12, 6, 8, 33, 55]) == [8, 6, 23, 12, 34, 33, 55, 45, 89, 67]\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19, 22, 21, 24, 23, 26, 25, 28, 27, 30, 29]\n assert candidate(nums = [23, 17, 5, 19, 11, 3, 29, 21, 7, 13, 25, 15]) == [5, 3, 11, 7, 15, 13, 19, 17, 23, 21, 29, 25]\n assert candidate(nums = [50, 20, 40, 30, 10, 60, 70, 80]) == [20, 10, 40, 30, 60, 50, 80, 70]\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6]) == [7, 6, 9, 8, 11, 10, 13, 12, 15, 14]\n assert candidate(nums = [50, 25, 75, 5, 100, 2, 70, 10, 80, 30, 60, 40]) == [5, 2, 25, 10, 40, 30, 60, 50, 75, 70, 100, 80]\n assert candidate(nums = [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]) == [22, 21, 24, 23, 26, 25, 28, 27, 30, 29, 32, 31]\n assert candidate(nums = [8, 6, 4, 2, 10, 12, 14, 16]) == [4, 2, 8, 6, 12, 10, 16, 14]\n assert candidate(nums = [8, 6, 10, 12, 4, 2, 14, 16]) == [4, 2, 8, 6, 12, 10, 16, 14]\n assert candidate(nums = [33, 32, 31, 30, 29, 28, 27, 26]) == [27, 26, 29, 28, 31, 30, 33, 32]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]\n assert candidate(nums = [1, 100, 50, 51, 99, 2, 49, 52, 48, 53]) == [2, 1, 49, 48, 51, 50, 53, 52, 100, 99]\n assert candidate(nums = [50, 25, 75, 100, 2, 52, 77, 74, 51, 76, 53, 78, 54, 79, 55, 80, 56, 81, 57, 82]) == [25, 2, 51, 50, 53, 52, 55, 54, 57, 56, 75, 74, 77, 76, 79, 78, 81, 80, 100, 82]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40]) == [10, 5, 20, 15, 30, 25, 40, 35]\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]) == [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == [2, 1, 4, 3, 6, 5, 8, 7, 10, 9]\n assert candidate(nums = [100, 1, 99, 2, 98, 3, 97, 4, 96, 5, 95, 6, 94, 7, 93, 8, 92, 9, 91, 10]) == [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 92, 91, 94, 93, 96, 95, 98, 97, 100, 99]\n assert candidate(nums = [100, 1, 99, 2, 98, 3, 97, 4]) == [2, 1, 4, 3, 98, 97, 100, 99]\n assert candidate(nums = [9, 1, 6, 8, 3, 7, 4, 5]) == [3, 1, 5, 4, 7, 6, 9, 8]\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == [92, 91, 94, 93, 96, 95, 98, 97, 100, 99]\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31]) == [32, 31, 34, 33, 36, 35, 38, 37, 40, 39, 42, 41, 44, 43, 46, 45, 48, 47, 50, 49]\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15]) == [16, 15, 18, 17, 20, 19, 22, 21, 24, 23, 26, 25, 28, 27, 30, 29]\n assert candidate(nums = [50, 20, 10, 30, 40, 60]) == [20, 10, 40, 30, 60, 50]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19]\n assert candidate(nums = [80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95]) == [81, 80, 83, 82, 85, 84, 87, 86, 89, 88, 91, 90, 93, 92, 95, 94]\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43]) == [44, 43, 46, 45, 48, 47, 50, 49]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19, 22, 21, 24, 23, 26, 25, 28, 27, 30, 29]\n assert candidate(nums = [9, 1, 8, 2, 7, 3, 6, 4, 5, 10]) == [2, 1, 4, 3, 6, 5, 8, 7, 10, 9]\n assert candidate(nums = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2]) == [4, 2, 8, 6, 12, 10, 16, 14, 20, 18]\n assert candidate(nums = [3, 3, 2, 2, 1, 1, 6, 6, 5, 5, 4, 4]) == [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(nums = [95, 85, 75, 65, 55, 45, 35, 25, 15, 5, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0]) == [5, 0, 15, 10, 25, 20, 35, 30, 45, 40, 55, 50, 65, 60, 75, 70, 85, 80, 95, 90]\n assert candidate(nums = [50, 40, 30, 20, 10, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60]) == [10, 10, 20, 20, 30, 30, 40, 40, 50, 50, 60, 60, 80, 70, 100, 90]\n assert candidate(nums = [100, 1, 99, 2, 98, 3, 97, 4, 96, 5, 95, 6, 94, 7, 93, 8, 92, 9, 91, 10]) == [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 92, 91, 94, 93, 96, 95, 98, 97, 100, 99]\n assert candidate(nums = [30, 25, 22, 20, 21, 23, 24, 26]) == [21, 20, 23, 22, 25, 24, 30, 26]\n assert candidate(nums = [50, 50, 40, 40, 30, 30, 20, 20, 10, 10]) == [10, 10, 20, 20, 30, 30, 40, 40, 50, 50]\n assert candidate(nums = [45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26]) == [27, 26, 29, 28, 31, 30, 33, 32, 35, 34, 37, 36, 39, 38, 41, 40, 43, 42, 45, 44]\n assert candidate(nums = [8, 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, 9]) == [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11]\n assert candidate(nums = [100, 1, 99, 2, 98, 3, 97, 4, 96, 5, 95, 6]) == [2, 1, 4, 3, 6, 5, 96, 95, 98, 97, 100, 99]\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == [2, 1, 4, 3, 6, 5, 8, 7, 10, 9]\n assert candidate(nums = [6, 1, 9, 4, 3, 8, 7, 2]) == [2, 1, 4, 3, 7, 6, 9, 8]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [1, 0, 3, 2, 5, 4, 7, 6, 9, 8]\n assert candidate(nums = [23, 45, 67, 12, 34, 56, 78, 89, 90, 10]) == [12, 10, 34, 23, 56, 45, 78, 67, 90, 89]\n assert candidate(nums = [9, 4, 1, 7, 3, 8, 2, 6, 5, 10]) == [2, 1, 4, 3, 6, 5, 8, 7, 10, 9]\n assert candidate(nums = [34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15]) == [16, 15, 18, 17, 20, 19, 22, 21, 24, 23, 26, 25, 28, 27, 30, 29, 32, 31, 34, 33]\n assert candidate(nums = [45, 23, 67, 89, 12, 34, 56, 78]) == [23, 12, 45, 34, 67, 56, 89, 78]\n assert candidate(nums = [34, 12, 78, 56, 32, 89, 21, 67]) == [21, 12, 34, 32, 67, 56, 89, 78]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19]\n assert candidate(nums = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10]) == [11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 21, 20, 23, 22, 25, 24]\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]\n assert candidate(nums = [6, 5, 4, 3, 2, 1]) == [2, 1, 4, 3, 6, 5]\n assert candidate(nums = [9, 1, 6, 3, 8, 4, 7, 2, 5, 10]) == [2, 1, 4, 3, 6, 5, 8, 7, 10, 9]\n assert candidate(nums = [6, 5, 4, 3, 2, 1, 12, 11, 10, 9, 8, 7]) == [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11]\n assert candidate(nums = [6, 1, 10, 3, 8, 5, 7, 2]) == [2, 1, 5, 3, 7, 6, 10, 8]\n assert candidate(nums = [9, 1, 6, 8, 3, 4, 7, 2]) == [2, 1, 4, 3, 7, 6, 9, 8]\n assert candidate(nums = [100, 1, 99, 2, 98, 3, 97, 4, 96, 5, 95, 6, 94, 7, 93, 8]) == [2, 1, 4, 3, 6, 5, 8, 7, 94, 93, 96, 95, 98, 97, 100, 99]\n assert candidate(nums = [21, 17, 19, 15, 16, 20, 18, 14]) == [15, 14, 17, 16, 19, 18, 21, 20]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]) == [4, 2, 8, 6, 12, 10, 16, 14, 20, 18, 24, 22]\n assert candidate(nums = [15, 10, 20, 5, 18, 13, 12, 8]) == [8, 5, 12, 10, 15, 13, 20, 18]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19, 22, 21, 24, 23, 26, 25, 28, 27, 30, 29]\n assert candidate(nums = [20, 15, 30, 10, 25, 5, 35, 50, 40, 45]) == [10, 5, 20, 15, 30, 25, 40, 35, 50, 45]\n assert candidate(nums = [50, 25, 75, 100, 12, 88, 63, 45, 37, 71, 19, 94]) == [19, 12, 37, 25, 50, 45, 71, 63, 88, 75, 100, 94]\n assert candidate(nums = [33, 66, 99, 22, 55, 88, 11, 44, 77, 100]) == [22, 11, 44, 33, 66, 55, 88, 77, 100, 99]\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().numberGame", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector numberGame(vector& nums) {", "container": "Solution", "callable": "numberGame", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2975, "task_id": "maximum-square-area-by-removing-fences-from-a-field", "difficulty": "Medium", "problem_description": "There is a large (m - 1) x (n - 1) rectangular field with corners at (1, 1) and (m, n) containing some horizontal and vertical fences given in arrays hFences and vFences respectively.\nHorizontal fences are from the coordinates (hFences[i], 1) to (hFences[i], n) and vertical fences are from the coordinates (1, vFences[i]) to (m, vFences[i]).\nReturn the maximum area of a square field that can be formed by removing some fences (possibly none) or -1 if it is impossible to make a square field.\nSince the answer may be large, return it modulo 109 + 7.\nNote: The field is surrounded by two horizontal fences from the coordinates (1, 1) to (1, n) and (m, 1) to (m, n) and two vertical fences from the coordinates (1, 1) to (m, 1) and (1, n) to (m, n). These fences cannot be removed.\n \nExample 1:\n\n\nInput: m = 4, n = 3, hFences = [2,3], vFences = [2]\nOutput: 4\nExplanation: Removing the horizontal fence at 2 and the vertical fence at 2 will give a square field of area 4.\n\nExample 2:\n\n\nInput: m = 6, n = 7, hFences = [2], vFences = [4]\nOutput: -1\nExplanation: It can be proved that there is no way to create a square field by removing fences.\n\n \nConstraints:\n\n3 <= m, n <= 109\n1 <= hFences.length, vFences.length <= 600\n1 < hFences[i] < m\n1 < vFences[i] < n\nhFences and vFences are unique.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(m = 4,n = 3,hFences = [2, 3],vFences = [2]) == 4\n assert candidate(m = 10,n = 10,hFences = [3, 7],vFences = [2, 8]) == 81\n assert candidate(m = 15,n = 12,hFences = [5, 10],vFences = [4, 8]) == 16\n assert candidate(m = 50,n = 50,hFences = [10, 20, 30],vFences = [10, 20, 30]) == 2401\n assert candidate(m = 20,n = 15,hFences = [4, 12],vFences = [5, 10]) == -1\n assert candidate(m = 10,n = 10,hFences = [3, 7],vFences = [3, 7]) == 81\n assert candidate(m = 8,n = 5,hFences = [2, 6],vFences = [2]) == 16\n assert candidate(m = 15,n = 15,hFences = [4, 6, 10],vFences = [4, 6, 10]) == 196\n assert candidate(m = 7,n = 8,hFences = [3],vFences = [3, 5]) == 16\n assert candidate(m = 9,n = 5,hFences = [2, 5, 8],vFences = [2, 3]) == 16\n assert candidate(m = 100,n = 100,hFences = [20, 40, 60, 80],vFences = [20, 40, 60, 80]) == 9801\n assert candidate(m = 12,n = 12,hFences = [3, 9],vFences = [3, 9]) == 121\n assert candidate(m = 9,n = 9,hFences = [5],vFences = [5]) == 64\n assert candidate(m = 15,n = 12,hFences = [5, 10],vFences = [3, 9]) == 81\n assert candidate(m = 8,n = 5,hFences = [2, 5],vFences = [2, 3]) == 16\n assert candidate(m = 6,n = 7,hFences = [2],vFences = [4]) == -1\n assert candidate(m = 1000000000,n = 1000000000,hFences = [100000000, 200000000, 300000000, 400000000, 500000000, 600000000, 700000000, 800000000, 900000000],vFences = [100000000, 200000000, 300000000, 400000000, 500000000, 600000000, 700000000, 800000000, 900000000]) == 64\n assert candidate(m = 100,n = 100,hFences = [20, 30, 40, 50],vFences = [15, 25, 35, 45]) == 9801\n assert candidate(m = 999999999,n = 999999999,hFences = [333333333, 666666666],vFences = [333333333, 666666666]) == 81\n assert candidate(m = 1000,n = 1000,hFences = [250, 500, 750],vFences = [250, 500, 750]) == 998001\n assert candidate(m = 200,n = 200,hFences = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190],vFences = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190]) == 39601\n assert candidate(m = 500,n = 500,hFences = [50, 150, 250, 350, 450],vFences = [75, 125, 175, 225, 275, 325, 375, 425, 475]) == 249001\n assert candidate(m = 8,n = 12,hFences = [2, 4, 6, 7],vFences = [3, 5, 9, 11]) == 49\n assert candidate(m = 100,n = 100,hFences = [10, 20, 30, 40, 50],vFences = [15, 25, 35, 45, 55]) == 9801\n assert candidate(m = 800,n = 600,hFences = [100, 300, 500, 700],vFences = [120, 240, 360, 480]) == -1\n assert candidate(m = 10000,n = 10000,hFences = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000],vFences = [500, 1500, 2500, 3500, 4500, 5500, 6500, 7500, 8500, 9500]) == 99980001\n assert candidate(m = 1000000000,n = 1000000000,hFences = [100000, 200000, 300000],vFences = [150000, 250000, 350000]) == 64\n assert candidate(m = 1200,n = 800,hFences = [240, 480, 720, 960],vFences = [160, 320, 480, 640]) == 230400\n assert candidate(m = 3000,n = 2000,hFences = [750, 1500, 2250],vFences = [500, 1000, 1500]) == 2250000\n assert candidate(m = 50,n = 30,hFences = [5, 10, 15, 20, 25, 30, 35, 40, 45],vFences = [3, 6, 9, 12, 15, 18, 21, 24, 27]) == 841\n assert candidate(m = 999,n = 999,hFences = [100, 200, 300, 400, 500, 600, 700, 800, 900],vFences = [100, 200, 300, 400, 500, 600, 700, 800, 900]) == 996004\n assert candidate(m = 1200,n = 900,hFences = [150, 300, 450, 600, 750, 900],vFences = [200, 400, 600, 800]) == 808201\n assert candidate(m = 2000,n = 3000,hFences = [500, 1000, 1500],vFences = [750, 1500, 2250]) == 2250000\n assert candidate(m = 1000,n = 1000,hFences = [150, 350, 550, 750, 950],vFences = [150, 350, 550, 750, 950]) == 998001\n assert candidate(m = 150,n = 150,hFences = [10, 20, 30, 40, 50],vFences = [15, 30, 45, 60, 75]) == 22201\n assert candidate(m = 10,n = 20,hFences = [2, 3, 5, 7],vFences = [4, 8, 12, 16]) == 64\n assert candidate(m = 500,n = 300,hFences = [50, 150, 250, 350, 450],vFences = [100, 200, 250, 300]) == 62001\n assert candidate(m = 1000,n = 1000,hFences = [200, 300, 400, 500, 600, 700, 800, 900],vFences = [100, 200, 300, 400, 500, 600, 700, 800]) == 998001\n assert candidate(m = 600,n = 400,hFences = [100, 200, 300, 400, 500],vFences = [150, 250, 350]) == 159201\n assert candidate(m = 1000000,n = 1000000,hFences = [100000, 200000, 300000, 400000, 500000],vFences = [100000, 200000, 300000, 400000, 500000]) == 997993008\n assert candidate(m = 30,n = 18,hFences = [3, 6, 9, 12, 15, 18, 24, 27],vFences = [4, 8, 12, 16, 20, 24, 28]) == 729\n assert candidate(m = 750,n = 1000,hFences = [10, 20, 30, 40, 50, 60, 70, 80, 90],vFences = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 7921\n assert candidate(m = 20,n = 15,hFences = [3, 6, 12, 18],vFences = [4, 8, 14]) == 196\n assert candidate(m = 600,n = 900,hFences = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600],vFences = [60, 120, 180, 240, 300, 360, 420, 480, 540, 600, 660, 720]) == 358801\n assert candidate(m = 2000000000,n = 1000000000,hFences = [500000000, 1500000000, 1000000000],vFences = [250000000, 750000000, 500000000]) == 64\n assert candidate(m = 5000,n = 5000,hFences = [1000, 2000, 3000, 4000],vFences = [1200, 2200, 3200, 4200]) == 24990001\n assert candidate(m = 10000,n = 10000,hFences = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000],vFences = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000]) == 99980001\n assert candidate(m = 999,n = 999,hFences = [100, 200, 300, 400, 500, 600, 700, 800],vFences = [100, 200, 300, 400, 500, 600, 700, 800]) == 996004\n assert candidate(m = 800,n = 600,hFences = [50, 100, 150, 200, 250],vFences = [75, 125, 175, 225, 275]) == 40000\n assert candidate(m = 200,n = 150,hFences = [50, 100, 150],vFences = [30, 60, 90, 120]) == 22201\n assert candidate(m = 1000,n = 1000,hFences = [200, 400, 600, 800],vFences = [250, 500, 750]) == 998001\n assert candidate(m = 500,n = 300,hFences = [100, 200, 300, 400],vFences = [50, 150, 250, 290]) == 89401\n assert candidate(m = 2000,n = 3000,hFences = [200, 600, 1000, 1400, 1800],vFences = [300, 900, 1500, 2100, 2700]) == 3240000\n assert candidate(m = 999,n = 999,hFences = [333, 666],vFences = [333, 666]) == 996004\n assert candidate(m = 123456789,n = 987654321,hFences = [12345678, 24691356, 37037034],vFences = [9876543, 19753086, 29629629]) == -1\n assert candidate(m = 1000,n = 1000,hFences = [50, 150, 250, 350, 450, 550, 650, 750, 850, 950],vFences = [50, 150, 250, 350, 450, 550, 650, 750, 850, 950]) == 998001\n assert candidate(m = 500,n = 500,hFences = [100, 150, 200, 250, 300],vFences = [50, 100, 150, 200, 250]) == 249001\n assert candidate(m = 800,n = 900,hFences = [50, 150, 250, 350, 450],vFences = [60, 160, 260, 360, 460]) == 160000\n assert candidate(m = 700,n = 500,hFences = [70, 140, 210, 280, 350, 420, 490, 560, 630],vFences = [50, 100, 150, 200, 250, 300, 350, 400, 450]) == 122500\n assert candidate(m = 1000000000,n = 1000000000,hFences = [200, 300, 400],vFences = [200, 300, 400]) == 64\n assert candidate(m = 500,n = 500,hFences = [100, 200, 300, 400],vFences = [100, 200, 300, 400]) == 249001\n assert candidate(m = 1200,n = 900,hFences = [150, 300, 450, 600, 750, 900],vFences = [180, 360, 540, 720, 900]) == 808201\n assert candidate(m = 500000000,n = 500000000,hFences = [250000000],vFences = [250000000]) == 250000022\n assert candidate(m = 50,n = 30,hFences = [10, 20, 30, 40],vFences = [5, 15, 25, 35, 45]) == 1600\n assert candidate(m = 100,n = 100,hFences = [10, 30, 50, 70, 90],vFences = [10, 30, 50, 70, 90]) == 9801\n assert candidate(m = 123456789,n = 987654321,hFences = [12345678, 24691356, 37037034, 49382712, 61728390, 74074068, 86419746, 98765424],vFences = [9876543, 19753086, 29629629, 39506172, 49382715, 59259258, 69135801, 79012344, 88888887]) == -1\n assert candidate(m = 100,n = 100,hFences = [15, 25, 35, 45, 55, 65, 75, 85, 95],vFences = [15, 25, 35, 45, 55, 65, 75, 85, 95]) == 9801\n assert candidate(m = 1000000000,n = 2000000000,hFences = [250000000, 750000000, 500000000],vFences = [500000000, 1500000000, 1000000000]) == 64\n assert candidate(m = 100,n = 100,hFences = [10, 20, 30, 40, 50, 60, 70, 80, 90],vFences = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 9801\n assert candidate(m = 123456,n = 654321,hFences = [23456, 45678, 67890],vFences = [34567, 56789, 78901]) == 493817284\n assert candidate(m = 800,n = 400,hFences = [100, 300, 500, 700],vFences = [100, 200, 300]) == 90000\n assert candidate(m = 100,n = 100,hFences = [20, 40, 60, 80],vFences = [20, 40, 60, 80]) == 9801\n assert candidate(m = 999999999,n = 999999999,hFences = [100000001, 200000001, 300000001, 400000001, 500000001],vFences = [100000002, 200000002, 300000002, 400000002, 500000002]) == 81\n assert candidate(m = 1000000000,n = 1000000000,hFences = [500000000],vFences = [500000000]) == 64\n assert candidate(m = 1000,n = 1000,hFences = [200, 300, 400, 500, 600, 700, 800, 900],vFences = [150, 250, 350, 450, 550, 650, 750, 850]) == 998001\n assert candidate(m = 100,n = 200,hFences = [10, 20, 30, 40],vFences = [15, 25, 35, 45]) == 900\n assert candidate(m = 500,n = 500,hFences = [25, 50, 75, 100, 125, 150, 175, 200],vFences = [25, 50, 75, 100, 125, 150, 175, 200]) == 249001\n assert candidate(m = 500,n = 600,hFences = [150, 250, 350],vFences = [200, 300, 400, 500]) == 249001\n assert candidate(m = 120,n = 120,hFences = [24, 48, 72, 96],vFences = [24, 48, 72, 96]) == 14161\n assert candidate(m = 80,n = 80,hFences = [20, 40, 60],vFences = [20, 40, 60]) == 6241\n assert candidate(m = 20,n = 20,hFences = [4, 8, 12, 16],vFences = [4, 8, 12, 16]) == 361\n assert candidate(m = 20,n = 20,hFences = [4, 8, 12, 16],vFences = [5, 10, 15]) == 361\n assert candidate(m = 100,n = 100,hFences = [20, 40, 60, 80],vFences = [25, 50, 75]) == 9801\n assert candidate(m = 50,n = 50,hFences = [25, 35, 45],vFences = [10, 20, 30, 40, 50]) == 2401\n assert candidate(m = 897,n = 789,hFences = [123, 234, 345, 456, 567, 678, 789],vFences = [87, 174, 261, 348, 435, 522, 609]) == 620944\n assert candidate(m = 99,n = 99,hFences = [33, 66],vFences = [33, 66]) == 9604\n assert candidate(m = 500,n = 500,hFences = [100, 200, 300],vFences = [150, 250, 350]) == 249001\n assert candidate(m = 100,n = 100,hFences = [20, 30, 40, 50, 60, 70, 80, 90],vFences = [15, 25, 35, 45, 55, 65, 75, 85, 95]) == 9801\n assert candidate(m = 20,n = 20,hFences = [3, 7, 13, 17],vFences = [4, 8, 12, 16]) == 361\n assert candidate(m = 777,n = 777,hFences = [259, 518],vFences = [259, 518]) == 602176\n assert candidate(m = 50,n = 50,hFences = [10, 20, 30, 40],vFences = [10, 20, 30, 40]) == 2401\n assert candidate(m = 1024,n = 1024,hFences = [256, 512, 768],vFences = [256, 512, 768]) == 1046529\n assert candidate(m = 1000,n = 1000,hFences = [100, 200, 300, 400, 500, 600, 700, 800, 900],vFences = [50, 150, 250, 350, 450, 550, 650, 750, 850, 950]) == 998001\n assert candidate(m = 1000000,n = 500000,hFences = [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000],vFences = [50000, 150000, 250000, 350000, 450000, 550000, 650000, 750000, 850000, 950000]) == 999994337\n assert candidate(m = 1000,n = 1000,hFences = [100, 200, 300, 400, 500, 600, 700, 800, 900],vFences = [100, 200, 300, 400, 500, 600, 700, 800, 900]) == 998001\n assert candidate(m = 500000000,n = 500000000,hFences = [50000000, 100000000, 150000000, 200000000, 250000000, 300000000, 350000000, 400000000, 450000000, 499999990],vFences = [50000000, 100000000, 150000000, 200000000, 250000000, 300000000, 350000000, 400000000, 450000000, 499999990]) == 250000022\n assert candidate(m = 987654,n = 456789,hFences = [123456, 234567, 345678, 456789, 567890],vFences = [98765, 197530, 296295, 395060, 493825]) == 655275488\n assert candidate(m = 800,n = 600,hFences = [100, 200, 300, 400, 500, 600, 700],vFences = [125, 250, 375, 500, 625]) == 358801\n assert candidate(m = 75,n = 60,hFences = [15, 30, 45],vFences = [10, 20, 30, 40]) == 900\n assert candidate(m = 20,n = 15,hFences = [3, 7, 12],vFences = [4, 8, 11]) == 121\n assert candidate(m = 50,n = 40,hFences = [10, 20, 30, 40],vFences = [5, 15, 25, 35]) == 1521\n"}, "metadata": {"canonical_parameter_names": ["m", "n", "hFences", "vFences"], "leetcode_dataset_entry_point": "Solution().maximizeSquareArea", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maximizeSquareArea(int m, int n, vector& hFences, vector& vFences) {", "container": "Solution", "callable": "maximizeSquareArea", "parameters": [{"name": "m", "type": "int"}, {"name": "n", "type": "int"}, {"name": "hFences", "type": "vector&"}, {"name": "vFences", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2976, "task_id": "minimum-cost-to-convert-string-i", "difficulty": "Medium", "problem_description": "You are given two 0-indexed strings source and target, both of length n and consisting of lowercase English letters. You are also given two 0-indexed character arrays original and changed, and an integer array cost, where cost[i] represents the cost of changing the character original[i] to the character changed[i].\nYou start with the string source. In one operation, you can pick a character x from the string and change it to the character y at a cost of z if there exists any index j such that cost[j] == z, original[j] == x, and changed[j] == y.\nReturn the minimum cost to convert the string source to the string target using any number of operations. If it is impossible to convert source to target, return -1.\nNote that there may exist indices i, j such that original[j] == original[i] and changed[j] == changed[i].\n \nExample 1:\n\nInput: source = \"abcd\", target = \"acbe\", original = [\"a\",\"b\",\"c\",\"c\",\"e\",\"d\"], changed = [\"b\",\"c\",\"b\",\"e\",\"b\",\"e\"], cost = [2,5,5,1,2,20]\nOutput: 28\nExplanation: To convert the string \"abcd\" to string \"acbe\":\n- Change value at index 1 from 'b' to 'c' at a cost of 5.\n- Change value at index 2 from 'c' to 'e' at a cost of 1.\n- Change value at index 2 from 'e' to 'b' at a cost of 2.\n- Change value at index 3 from 'd' to 'e' at a cost of 20.\nThe total cost incurred is 5 + 1 + 2 + 20 = 28.\nIt can be shown that this is the minimum possible cost.\n\nExample 2:\n\nInput: source = \"aaaa\", target = \"bbbb\", original = [\"a\",\"c\"], changed = [\"c\",\"b\"], cost = [1,2]\nOutput: 12\nExplanation: To change the character 'a' to 'b' change the character 'a' to 'c' at a cost of 1, followed by changing the character 'c' to 'b' at a cost of 2, for a total cost of 1 + 2 = 3. To change all occurrences of 'a' to 'b', a total cost of 3 * 4 = 12 is incurred.\n\nExample 3:\n\nInput: source = \"abcd\", target = \"abce\", original = [\"a\"], changed = [\"e\"], cost = [10000]\nOutput: -1\nExplanation: It is impossible to convert source to target because the value at index 3 cannot be changed from 'd' to 'e'.\n\n \nConstraints:\n\n1 <= source.length == target.length <= 105\nsource, target consist of lowercase English letters.\n1 <= cost.length == original.length == changed.length <= 2000\noriginal[i], changed[i] are lowercase English letters.\n1 <= cost[i] <= 106\noriginal[i] != changed[i]\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(source = \"abcd\",target = \"abce\",original = ['a'],changed = ['e'],cost = [10000]) == -1\n assert candidate(source = \"aaaa\",target = \"bbbb\",original = ['a', 'c'],changed = ['c', 'b'],cost = [1, 2]) == 12\n assert candidate(source = \"abc\",target = \"def\",original = ['a', 'b', 'c'],changed = ['d', 'e', 'f'],cost = [1, 1, 1]) == 3\n assert candidate(source = \"abcd\",target = \"acbe\",original = ['a', 'b', 'c', 'c', 'e', 'd'],changed = ['b', 'c', 'b', 'e', 'b', 'e'],cost = [2, 5, 5, 1, 2, 20]) == 28\n assert candidate(source = \"zzz\",target = \"aaa\",original = ['z', 'z', 'z'],changed = ['a', 'b', 'a'],cost = [2, 3, 1]) == 3\n assert candidate(source = \"aabbccddeeff\",target = \"zzzzyyyxxx\",original = ['a', 'b', 'c', 'd', 'e', 'f', 'z', 'y', 'x'],changed = ['z', 'y', 'x', 'z', 'y', 'x', 'a', 'b', 'c'],cost = [100, 200, 300, 400, 500, 600, 1, 2, 3]) == -1\n assert candidate(source = \"abcdefghijklmnopqrstuvwxyz\",target = \"zyxwvutsrqponmlkjihgfedcba\",original = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'],changed = ['z', 'y', 'x', 'w', 'v', 'u', 't', 's', 'r', 'q', 'p', 'o', 'n', 'm', 'l', 'k', 'j', 'i', 'h', 'g', 'f', 'e', 'd', 'c', 'b', 'a'],cost = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == -1\n assert candidate(source = \"hello\",target = \"ohell\",original = ['h', 'e', 'l', 'o'],changed = ['o', 'l', 'e', 'h'],cost = [10, 20, 30, 40]) == -1\n assert candidate(source = \"aaaaabbbbbcccc\",target = \"bbbbbccccddddd\",original = ['a', 'b', 'c', 'd'],changed = ['b', 'c', 'd', 'a'],cost = [1, 1, 1, 1]) == 15\n assert candidate(source = \"aaaaaaaaaa\",target = \"bbbbbbbbbb\",original = ['a', 'b'],changed = ['b', 'a'],cost = [1000000, 1000000]) == 10000000\n assert candidate(source = \"abcabcabc\",target = \"defdefdef\",original = ['a', 'b', 'c'],changed = ['d', 'e', 'f'],cost = [100, 200, 300]) == 1800\n assert candidate(source = \"abcdefghijklmnopqrstuvwxyz\",target = \"zyxwvutsrqponmlkjihgfedcba\",original = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'],changed = ['z', 'y', 'x', 'w', 'v', 'u', 't', 's', 'r', 'q', 'p', 'o', 'n', 'm', 'l', 'k', 'j', 'i', 'h', 'g', 'f', 'e', 'd', 'c', 'b', 'a'],cost = [26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 351\n assert candidate(source = \"hello\",target = \"world\",original = ['h', 'e', 'l', 'l', 'o', 'w', 'o', 'r', 'l', 'd'],changed = ['w', 'o', 'o', 'd', 'r', 'r', 'r', 'l', 'l', 'h'],cost = [7, 5, 1, 1, 6, 8, 4, 9, 2, 3]) == 31\n assert candidate(source = \"abcde\",target = \"edcba\",original = ['a', 'b', 'c', 'd', 'e'],changed = ['e', 'd', 'c', 'b', 'a'],cost = [5, 4, 3, 2, 1]) == 12\n assert candidate(source = \"abcabcabcabc\",target = \"abcabcabcabc\",original = ['a', 'b', 'c'],changed = ['b', 'c', 'a'],cost = [10, 20, 30]) == 0\n assert candidate(source = \"sourcestring\",target = \"targetstri\",original = ['s', 'o', 'u', 'r', 'c', 'e', 't', 'a', 'g', 'i', 'n'],changed = ['t', 'a', 'r', 'g', 'e', 't', 's', 'o', 'u', 'n', 'g'],cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 21\n assert candidate(source = \"aaaaaa\",target = \"bbbbbb\",original = ['a', 'a', 'a', 'a', 'a', 'a'],changed = ['b', 'c', 'd', 'e', 'f', 'g'],cost = [1, 10, 100, 1000, 10000, 100000]) == 6\n assert candidate(source = \"aaaaaaaaaa\",target = \"bbbbbbbbbb\",original = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],changed = ['b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'a'],cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(source = \"abcdefghij\",target = \"abcdefghij\",original = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],changed = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(source = \"aaabbbccc\",target = \"bbbaaaccb\",original = ['a', 'b', 'c'],changed = ['b', 'a', 'b'],cost = [1, 2, 3]) == 12\n assert candidate(source = \"abcdefghij\",target = \"abcdefghij\",original = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],changed = ['b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'a'],cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(source = \"zzzzzzzzzz\",target = \"aaaaaaaaaa\",original = ['z', 'a'],changed = ['a', 'z'],cost = [1000000, 1]) == 10000000\n assert candidate(source = \"abacabadabacaba\",target = \"zyxzyxzyxzyxzyx\",original = ['a', 'b', 'c'],changed = ['z', 'y', 'x'],cost = [1, 2, 3]) == -1\n assert candidate(source = \"aaaaaabbbbbccccc\",target = \"bbbbbaaaaaccccc\",original = ['a', 'b', 'c'],changed = ['b', 'c', 'a'],cost = [1, 2, 3]) == 27\n assert candidate(source = \"abcdabcdabcd\",target = \"dcbaabcddcba\",original = ['a', 'b', 'c', 'd'],changed = ['d', 'c', 'b', 'a'],cost = [1, 2, 3, 4]) == 20\n assert candidate(source = \"conversion\",target = \"converting\",original = ['v', 's', 'i'],changed = ['r', 't', 'n'],cost = [15, 25, 35]) == -1\n assert candidate(source = \"zzzzzzzzzzzzzzzzzzzz\",target = \"zzzzzzzzzzzzzzzzzzzz\",original = ['z'],changed = ['z'],cost = [1]) == 0\n assert candidate(source = \"aabbcc\",target = \"bbccdd\",original = ['a', 'b', 'c'],changed = ['b', 'c', 'd'],cost = [1, 1, 1]) == 6\n assert candidate(source = \"aaaaaabbbbb\",target = \"bbbaaaaab\",original = ['a', 'b'],changed = ['b', 'a'],cost = [1, 2]) == 7\n assert candidate(source = \"programming\",target = \"debugging\",original = ['p', 'r', 'o', 'g', 'a', 'm', 'd', 'e', 'b', 'u', 'i', 'n'],changed = ['d', 'e', 'b', 'u', 'g', 'g', 'i', 'n', 'g', 'p', 'r', 'o'],cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 171\n assert candidate(source = \"abcdefghijklmnopqrstuvwxyz\",target = \"zyxwvutsrqponmlkjihgfedcba\",original = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'],changed = ['z', 'y', 'x', 'w', 'v', 'u', 't', 's', 'r', 'q', 'p', 'o', 'n', 'm', 'l', 'k', 'j', 'i', 'h', 'g', 'f', 'e', 'd', 'c', 'b', 'a'],cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == -1\n assert candidate(source = \"abababab\",target = \"babababa\",original = ['a', 'b'],changed = ['b', 'a'],cost = [1, 1]) == 8\n assert candidate(source = \"aaaaaaaaaa\",target = \"bbbbbbbbbb\",original = ['a', 'b'],changed = ['b', 'a'],cost = [1, 10]) == 10\n assert candidate(source = \"example\",target = \"sample\",original = ['e', 'x', 'a', 'm', 'p', 'l'],changed = ['s', 'a', 'm', 'p', 'l', 'e'],cost = [1000, 2000, 3000, 4000, 5000, 6000]) == 21000\n assert candidate(source = \"abcdefghij\",target = \"ghijklmnop\",original = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],changed = ['g', 'h', 'i', 'j', 'a', 'b', 'c', 'd', 'e', 'f'],cost = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == -1\n assert candidate(source = \"abcdefghijklmnopqrstuvwxyz\",target = \"abcdefghijklmnopqrstuvwxyza\",original = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'],changed = ['b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'a'],cost = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(source = \"mmmmmmmmmmmmmmmmmmmm\",target = \"nnnnnnnnnnnnnnnnnnnn\",original = ['m', 'n'],changed = ['n', 'm'],cost = [10, 1]) == 200\n assert candidate(source = \"abcde\",target = \"edcba\",original = ['a', 'b', 'c', 'd', 'e'],changed = ['e', 'd', 'c', 'b', 'a'],cost = [5, 5, 5, 5, 5]) == 20\n assert candidate(source = \"abacabadabacaba\",target = \"xyzxyzxyzxyzxyz\",original = ['a', 'b', 'c'],changed = ['x', 'y', 'z'],cost = [3, 4, 5]) == -1\n assert candidate(source = \"complexstring\",target = \"simpleststr\",original = ['c', 'o', 'm', 'p', 'l', 'e', 'x', 's', 't', 'r', 'i', 'n', 'g'],changed = ['s', 'i', 'm', 'p', 'l', 'e', 's', 't', 'r', 'i', 'n', 'g', 'c'],cost = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130]) == 1830\n assert candidate(source = \"abcdefghij\",target = \"abcdefghij\",original = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],changed = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],cost = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(source = \"aaaaa\",target = \"bbbbb\",original = ['a', 'a', 'a', 'a', 'a'],changed = ['b', 'b', 'b', 'b', 'b'],cost = [1, 2, 3, 4, 5]) == 5\n assert candidate(source = \"abcdefghijklmnopqrstuvwxyza\",target = \"abcdefghijklmnopqrstuvwxyzb\",original = ['a', 'z'],changed = ['b', 'a'],cost = [10, 20]) == 10\n assert candidate(source = \"testing\",target = \"success\",original = ['t', 'e', 's', 'i', 'n', 'c'],changed = ['s', 's', 'c', 's', 'c', 's'],cost = [10, 20, 30, 40, 50, 60]) == -1\n assert candidate(source = \"zzzzzzzzzzzzzzzzzzzz\",target = \"aaaaaaaaaaaaaaaaaaaa\",original = ['z'],changed = ['a'],cost = [1]) == 20\n assert candidate(source = \"abcdef\",target = \"fedcba\",original = ['a', 'b', 'c', 'd', 'e', 'f'],changed = ['f', 'e', 'd', 'c', 'b', 'a'],cost = [1, 2, 3, 4, 5, 6]) == 21\n assert candidate(source = \"abcdefg\",target = \"hijklmn\",original = ['a', 'b', 'c', 'd', 'e', 'f', 'g'],changed = ['h', 'i', 'j', 'k', 'l', 'm', 'n'],cost = [1, 1, 1, 1, 1, 1, 1]) == 7\n assert candidate(source = \"abcdabcdabcd\",target = \"zzzzzzzzzzzz\",original = ['a', 'b', 'c', 'd'],changed = ['z', 'z', 'z', 'z'],cost = [1, 2, 3, 4]) == 30\n assert candidate(source = \"hello\",target = \"world\",original = ['h', 'e', 'l', 'o', 'w', 'r', 'd'],changed = ['w', 'r', 'l', 'r', 'h', 'o', 'l'],cost = [1, 2, 3, 4, 5, 6, 7]) == -1\n assert candidate(source = \"xyxzy\",target = \"yxyzx\",original = ['x', 'y', 'z'],changed = ['y', 'z', 'x'],cost = [1, 1, 1]) == 6\n assert candidate(source = \"programming\",target = \"algorithm\",original = ['p', 'r', 'o', 'g', 'a', 'm', 'i', 'n', 't', 'l', 'e'],changed = ['a', 'l', 'g', 'o', 'r', 'i', 't', 'h', 'm', 'p', 'e'],cost = [11, 22, 33, 44, 55, 66, 77, 88, 99, 100, 110]) == -1\n assert candidate(source = \"xyxyxy\",target = \"yzyzyz\",original = ['x', 'y'],changed = ['y', 'z'],cost = [10, 20]) == 90\n assert candidate(source = \"abcde\",target = \"aaaaa\",original = ['a', 'b', 'c', 'd', 'e'],changed = ['a', 'a', 'a', 'a', 'a'],cost = [1, 1, 1, 1, 1]) == 4\n assert candidate(source = \"aaaaaaaaaa\",target = \"zzzzzzzzzz\",original = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],changed = ['z', 'y', 'x', 'w', 'v', 'u', 't', 's', 'r', 'q'],cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(source = \"abacabadabacaba\",target = \"xyzxyzyxzyzyxzy\",original = ['a', 'b', 'c'],changed = ['x', 'y', 'z'],cost = [10, 20, 30]) == -1\n assert candidate(source = \"abcdefghij\",target = \"jihgfedcba\",original = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],changed = ['j', 'i', 'h', 'g', 'f', 'e', 'd', 'c', 'b', 'a'],cost = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 55\n assert candidate(source = \"abcabcabcabc\",target = \"xyzxyzxyzxyz\",original = ['a', 'b', 'c', 'x', 'y', 'z'],changed = ['x', 'y', 'z', 'a', 'b', 'c'],cost = [10, 20, 30, 40, 50, 60]) == 240\n assert candidate(source = \"hellohellohello\",target = \"worldworldworld\",original = ['h', 'e', 'l', 'o', 'w', 'r', 'd'],changed = ['w', 'r', 'd', 'o', 'h', 'e', 'l'],cost = [5, 15, 25, 35, 45, 55, 65]) == -1\n assert candidate(source = \"abcdefghij\",target = \"jihgfedcba\",original = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],changed = ['j', 'i', 'h', 'g', 'f', 'e', 'd', 'c', 'b', 'a'],cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(source = \"mississippi\",target = \"sssmmmipipi\",original = ['m', 'i', 's', 'p'],changed = ['s', 'm', 'i', 'p'],cost = [2, 3, 4, 5]) == -1\n assert candidate(source = \"hello\",target = \"world\",original = ['h', 'e', 'l', 'o', 'w', 'r', 'd'],changed = ['w', 'r', 'd', 'r', 'o', 'l', 'l'],cost = [1, 2, 3, 4, 5, 6, 7]) == -1\n assert candidate(source = \"quickbrownfox\",target = \"jumpingoverlazy\",original = ['q', 'u', 'i', 'c', 'k', 'b', 'r', 'o', 'w', 'n', 'f', 'o', 'x'],changed = ['j', 'u', 'm', 'p', 'i', 'n', 'g', 'v', 'e', 'r', 'l', 'a', 'z'],cost = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130]) == -1\n assert candidate(source = \"aabbcc\",target = \"bbccdd\",original = ['a', 'b', 'c', 'd'],changed = ['b', 'c', 'd', 'e'],cost = [1, 2, 3, 4]) == 12\n assert candidate(source = \"abracadabra\",target = \"zabzazaba\",original = ['a', 'b', 'c', 'd', 'r'],changed = ['z', 'a', 'a', 'a', 'a'],cost = [10, 20, 30, 40, 5]) == -1\n assert candidate(source = \"mississippi\",target = \"hississippi\",original = ['m'],changed = ['h'],cost = [5]) == 5\n assert candidate(source = \"xyxyxyxyxyxyxyxyxy\",target = \"yzyzyzyzyzyzyzyzyz\",original = ['x', 'y', 'z'],changed = ['y', 'z', 'x'],cost = [5, 4, 3]) == 81\n assert candidate(source = \"conversion\",target = \"transformation\",original = ['c', 'o', 'n', 'v', 'e', 'r', 's', 'i', 'o', 'n'],changed = ['t', 'r', 'a', 'n', 's', 'f', 'o', 'r', 'm', 'a'],cost = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 480\n assert candidate(source = \"abcabcabcabcabcabc\",target = \"defdefdefdefdefdef\",original = ['a', 'b', 'c'],changed = ['d', 'e', 'f'],cost = [1, 2, 3]) == 36\n assert candidate(source = \"algorithm\",target = \"algorithm\",original = ['a', 'l', 'g', 'o', 'r', 'i', 't', 'h', 'm'],changed = ['m', 'a', 'l', 'g', 'o', 'r', 'i', 't', 'h'],cost = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(source = \"repeated\",target = \"rotating\",original = ['e', 'p', 't', 'a', 'd'],changed = ['o', 'a', 'i', 't', 'n'],cost = [5, 7, 3, 9, 12]) == -1\n assert candidate(source = \"abcdefghijklmnopqrstuvwxyz\",target = \"zyxwvutsrqponmlkjihgfedcba\",original = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'],changed = ['z', 'y', 'x', 'w', 'v', 'u', 't', 's', 'r', 'q', 'p', 'o', 'n', 'm', 'l', 'k', 'j', 'i', 'h', 'g', 'f', 'e', 'd', 'c', 'b', 'a'],cost = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260]) == 3510\n assert candidate(source = \"abcdefghij\",target = \"fedcbaghij\",original = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],changed = ['e', 'd', 'c', 'b', 'a', 'j', 'i', 'h', 'g', 'f'],cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == -1\n assert candidate(source = \"abababababababababab\",target = \"bcbcbcbcbcbcbcbcbcbc\",original = ['a', 'b', 'c'],changed = ['b', 'c', 'a'],cost = [1, 2, 3]) == 30\n assert candidate(source = \"abcde\",target = \"edcba\",original = ['a', 'b', 'c', 'd', 'e'],changed = ['e', 'd', 'c', 'b', 'a'],cost = [1, 1, 1, 1, 1]) == 4\n assert candidate(source = \"abcdefghijklmnopqrstuvwxyz\",target = \"bcdefghijklmnopqrstuvwxyza\",original = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'],changed = ['b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'a'],cost = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 26\n assert candidate(source = \"aaaabbbbcccc\",target = \"bbccccddddee\",original = ['a', 'b', 'c'],changed = ['b', 'c', 'd'],cost = [1, 2, 3]) == -1\n assert candidate(source = \"abcdefghijklmnopqrstuvwxyz\",target = \"abcdefghijklmnopqrstuvwxyz\",original = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'],changed = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'],cost = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(source = \"aaaaaaaaaaaaaaaaaa\",target = \"bbbbbbbbbbbbbbbbbb\",original = ['a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b'],changed = ['b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a'],cost = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 36\n assert candidate(source = \"abcdefghijklmnopqrstuvwxyza\",target = \"zyxwvutsrqponmlkjihgfedcbaa\",original = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'],changed = ['z', 'y', 'x', 'w', 'v', 'u', 't', 's', 'r', 'q', 'p', 'o', 'n', 'm', 'l', 'k', 'j', 'i', 'h', 'g', 'f', 'e', 'd', 'c', 'b', 'a'],cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]) == 351\n assert candidate(source = \"abcdefghijklmnopqrstuvwxyz\",target = \"abcdefghijklmnopqrstuvwxyz\",original = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'],changed = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'],cost = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(source = \"transform\",target = \"convert\",original = ['t', 'r', 'a', 'n', 's', 'f', 'o', 'm'],changed = ['c', 'o', 'n', 'v', 'e', 'r', 't', 'd'],cost = [4, 2, 1, 3, 6, 5, 7, 8]) == 28\n assert candidate(source = \"abcabcabcabcabcabcabcabcabcabc\",target = \"xyzxyzxyzxyzxyzxyzxyzxyzxyzxyz\",original = ['a', 'b', 'c', 'x', 'y', 'z'],changed = ['x', 'y', 'z', 'a', 'b', 'c'],cost = [10, 20, 30, 40, 50, 60]) == 600\n assert candidate(source = \"abcabcabcabcabc\",target = \"defdefdefdefdef\",original = ['a', 'b', 'c'],changed = ['d', 'e', 'f'],cost = [100, 200, 300]) == 3000\n assert candidate(source = \"abcabcabcabc\",target = \"xyzxyzxyzxyz\",original = ['a', 'b', 'c', 'x', 'y', 'z'],changed = ['x', 'y', 'z', 'a', 'b', 'c'],cost = [10, 20, 30, 5, 15, 25]) == 240\n assert candidate(source = \"abcdefghijklmnopqrstuvwxyz\",target = \"zyxwvutsrqponmlkjihgfedcba\",original = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'],changed = ['z', 'y', 'x', 'w', 'v', 'u', 't', 's', 'r', 'q', 'p', 'o', 'n', 'm', 'l', 'k', 'j', 'i', 'h', 'g', 'f', 'e', 'd', 'c', 'b', 'a'],cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]) == 351\n assert candidate(source = \"python\",target = \"java\",original = ['p', 'y', 't', 'h', 'o', 'n', 'j', 'a', 'v'],changed = ['j', 'a', 'v', 'a', 'v', 'a', 'p', 'y', 't'],cost = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 100\n assert candidate(source = \"aaaaaaaaaaaaaaaaaaaa\",target = \"bbbbbbbbbbbbbbbbbbbb\",original = ['a', 'b', 'c'],changed = ['b', 'c', 'a'],cost = [100, 200, 300]) == 2000\n assert candidate(source = \"programming\",target = \"ppppppppppp\",original = ['p', 'r', 'o', 'g', 'a', 'm'],changed = ['p', 'p', 'p', 'p', 'p', 'p'],cost = [1, 2, 3, 4, 5, 6]) == -1\n assert candidate(source = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",target = \"zzzzyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeeeddccbaa\",original = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'],changed = ['z', 'y', 'x', 'w', 'v', 'u', 't', 's', 'r', 'q', 'p', 'o', 'n', 'm', 'l', 'k', 'j', 'i', 'h', 'g', 'f', 'e', 'd', 'c', 'b', 'a'],cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]) == -1\n assert candidate(source = \"abacabadabacaba\",target = \"xyzxyzxyzxyzxyz\",original = ['a', 'b', 'c'],changed = ['x', 'y', 'z'],cost = [100, 200, 300]) == -1\n assert candidate(source = \"abcdefghij\",target = \"klmnopqrst\",original = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],changed = ['k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't'],cost = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 550\n assert candidate(source = \"abcde\",target = \"fghij\",original = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],changed = ['f', 'g', 'h', 'i', 'j', 'a', 'b', 'c', 'd', 'e'],cost = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 1500\n assert candidate(source = \"abcdefg\",target = \"gfedcba\",original = ['a', 'b', 'c', 'd', 'e', 'f', 'g'],changed = ['g', 'f', 'e', 'd', 'c', 'b', 'a'],cost = [7, 6, 5, 4, 3, 2, 1]) == 24\n assert candidate(source = \"aaaaabbbbbaaaaa\",target = \"bbbbbbaaaaabbbb\",original = ['a', 'b'],changed = ['b', 'a'],cost = [100, 150]) == 1500\n"}, "metadata": {"canonical_parameter_names": ["source", "target", "original", "changed", "cost"], "leetcode_dataset_entry_point": "Solution().minimumCost", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "long long minimumCost(string source, string target, vector& original, vector& changed, vector& cost) {", "container": "Solution", "callable": "minimumCost", "parameters": [{"name": "source", "type": "string"}, {"name": "target", "type": "string"}, {"name": "original", "type": "vector&"}, {"name": "changed", "type": "vector&"}, {"name": "cost", "type": "vector&"}], "return_type": "long long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2977, "task_id": "minimum-cost-to-convert-string-ii", "difficulty": "Hard", "problem_description": "You are given two 0-indexed strings source and target, both of length n and consisting of lowercase English characters. You are also given two 0-indexed string arrays original and changed, and an integer array cost, where cost[i] represents the cost of converting the string original[i] to the string changed[i].\nYou start with the string source. In one operation, you can pick a substring x from the string, and change it to y at a cost of z if there exists any index j such that cost[j] == z, original[j] == x, and changed[j] == y. You are allowed to do any number of operations, but any pair of operations must satisfy either of these two conditions:\n\nThe substrings picked in the operations are source[a..b] and source[c..d] with either b < c or d < a. In other words, the indices picked in both operations are disjoint.\nThe substrings picked in the operations are source[a..b] and source[c..d] with a == c and b == d. In other words, the indices picked in both operations are identical.\n\nReturn the minimum cost to convert the string source to the string target using any number of operations. If it is impossible to convert source to target, return -1.\nNote that there may exist indices i, j such that original[j] == original[i] and changed[j] == changed[i].\n \nExample 1:\n\nInput: source = \"abcd\", target = \"acbe\", original = [\"a\",\"b\",\"c\",\"c\",\"e\",\"d\"], changed = [\"b\",\"c\",\"b\",\"e\",\"b\",\"e\"], cost = [2,5,5,1,2,20]\nOutput: 28\nExplanation: To convert \"abcd\" to \"acbe\", do the following operations:\n- Change substring source[1..1] from \"b\" to \"c\" at a cost of 5.\n- Change substring source[2..2] from \"c\" to \"e\" at a cost of 1.\n- Change substring source[2..2] from \"e\" to \"b\" at a cost of 2.\n- Change substring source[3..3] from \"d\" to \"e\" at a cost of 20.\nThe total cost incurred is 5 + 1 + 2 + 20 = 28. \nIt can be shown that this is the minimum possible cost.\n\nExample 2:\n\nInput: source = \"abcdefgh\", target = \"acdeeghh\", original = [\"bcd\",\"fgh\",\"thh\"], changed = [\"cde\",\"thh\",\"ghh\"], cost = [1,3,5]\nOutput: 9\nExplanation: To convert \"abcdefgh\" to \"acdeeghh\", do the following operations:\n- Change substring source[1..3] from \"bcd\" to \"cde\" at a cost of 1.\n- Change substring source[5..7] from \"fgh\" to \"thh\" at a cost of 3. We can do this operation because indices [5,7] are disjoint with indices picked in the first operation.\n- Change substring source[5..7] from \"thh\" to \"ghh\" at a cost of 5. We can do this operation because indices [5,7] are disjoint with indices picked in the first operation, and identical with indices picked in the second operation.\nThe total cost incurred is 1 + 3 + 5 = 9.\nIt can be shown that this is the minimum possible cost.\n\nExample 3:\n\nInput: source = \"abcdefgh\", target = \"addddddd\", original = [\"bcd\",\"defgh\"], changed = [\"ddd\",\"ddddd\"], cost = [100,1578]\nOutput: -1\nExplanation: It is impossible to convert \"abcdefgh\" to \"addddddd\".\nIf you select substring source[1..3] as the first operation to change \"abcdefgh\" to \"adddefgh\", you cannot select substring source[3..7] as the second operation because it has a common index, 3, with the first operation.\nIf you select substring source[3..7] as the first operation to change \"abcdefgh\" to \"abcddddd\", you cannot select substring source[1..3] as the second operation because it has a common index, 3, with the first operation.\n\n \nConstraints:\n\n1 <= source.length == target.length <= 1000\nsource, target consist only of lowercase English characters.\n1 <= cost.length == original.length == changed.length <= 100\n1 <= original[i].length == changed[i].length <= source.length\noriginal[i], changed[i] consist only of lowercase English characters.\noriginal[i] != changed[i]\n1 <= cost[i] <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(source = \"abcdefgh\",target = \"acdeeghh\",original = ['bcd', 'fgh', 'thh'],changed = ['cde', 'thh', 'ghh'],cost = [1, 3, 5]) == 9\n assert candidate(source = \"abcd\",target = \"acbe\",original = ['a', 'b', 'c', 'c', 'e', 'd'],changed = ['b', 'c', 'b', 'e', 'b', 'e'],cost = [2, 5, 5, 1, 2, 20]) == 28\n assert candidate(source = \"abcdefgh\",target = \"addddddd\",original = ['bcd', 'defgh'],changed = ['ddd', 'ddddd'],cost = [100, 1578]) == -1\n assert candidate(source = \"mississippi\",target = \"massissippi\",original = ['issi', 'miss'],changed = ['assi', 'mass'],cost = [20, 30]) == 20\n assert candidate(source = \"xyzxyzxyz\",target = \"zyxzyxzyx\",original = ['xyz', 'zyx'],changed = ['zyx', 'xyz'],cost = [500, 500]) == 1500\n assert candidate(source = \"abcdeffedcba\",target = \"zyxwvutsrqponmlkjihgfedcba\",original = ['abc', 'def', 'fed', 'cba'],changed = ['zyx', 'wvu', 'tsr', 'pon'],cost = [50, 60, 70, 80]) == -1\n assert candidate(source = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",target = \"zzxxwwvvuuttrrssqqppoonnmmllkkjjiihhggffeeeeddccbbaa\",original = ['ab', 'bc', 'cd', 'de', 'ef', 'fg', 'gh', 'hi', 'ij', 'jk', 'kl', 'lm', 'mn', 'no', 'op', 'pq', 'qr', 'rs', 'st', 'tu', 'uv', 'vw', 'wx', 'xy', 'yz'],changed = ['yx', 'xw', 'wg', 'vf', 'fu', 'et', 'ts', 'sr', 'rq', 'qp', 'po', 'on', 'nm', 'ml', 'lk', 'kj', 'ji', 'ih', 'hg', 'gf', 'fe', 'ed', 'dc', 'cb', 'ba'],cost = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250]) == -1\n assert candidate(source = \"abcdefghijklmnopqrstuvwxyz\",target = \"zyxwvutsrqponmlkjihgfedcba\",original = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz'],changed = ['zyx', 'wvu', 'tsr', 'pon', 'mlk', 'jih', 'gf', 'edc', 'ba'],cost = [200, 150, 100, 50, 150, 200, 50, 100, 150]) == -1\n assert candidate(source = \"mnopqr\",target = \"rqpomn\",original = ['mnop', 'opqr', 'pqro', 'qrop', 'rpoq', 'poqm'],changed = ['rpoq', 'poqm', 'mnop', 'opqr', 'pqro', 'qrop'],cost = [100, 200, 300, 400, 500, 600]) == -1\n assert candidate(source = \"abcdefgabcdefgabcdefg\",target = \"zyxwvutzyxwvutzyxwvut\",original = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz'],changed = ['zyx', 'wvu', 'tsr', 'pon', 'mlk', 'jih', 'fed', 'cba', 'ba'],cost = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == -1\n assert candidate(source = \"mnopqrst\",target = \"nopqrstu\",original = ['mnop', 'qrst', 'rstu'],changed = ['nopq', 'mnop', 'rstv'],cost = [100, 200, 300]) == -1\n assert candidate(source = \"abracadabra\",target = \"abracabadaa\",original = ['ra'],changed = ['aa'],cost = [3]) == -1\n assert candidate(source = \"abcabcabcabc\",target = \"defdefdefdef\",original = ['abc', 'def'],changed = ['def', 'abc'],cost = [1000, 1000]) == 4000\n assert candidate(source = \"aaaaabbbbb\",target = \"bbbbbbaaaa\",original = ['aaaaa', 'bbbbb'],changed = ['bbbbb', 'aaaaa'],cost = [2000, 1000]) == -1\n assert candidate(source = \"mississippi\",target = \"mssssssssss\",original = ['issi', 'ssis', 'ippi', 'ppi', 'missi', 'ssipp'],changed = ['ssss', 'ssss', 'ppp', 'pp', 'sssss', 'sssss'],cost = [50, 55, 30, 35, 40, 45]) == -1\n assert candidate(source = \"aaaaabbbbb\",target = \"bbbbbbaaaa\",original = ['aaaaa', 'bbbbb'],changed = ['bbbbb', 'aaaaa'],cost = [1000, 1000]) == -1\n assert candidate(source = \"abcdefabcdefabcdef\",target = \"ghijklghijklghijkl\",original = ['abc', 'def', 'ghi', 'jkl'],changed = ['ghi', 'jkl', 'abc', 'def'],cost = [10, 20, 30, 40]) == 90\n assert candidate(source = \"qwertyuiopqwertyuiopqwertyuiop\",target = \"asdfghjklasdfghjklasdfghjkl\",original = ['qwerty', 'uiop', 'asdf', 'ghjkl', 'qwertyuiop', 'asdfghjkl'],changed = ['asdfgh', 'jklasdf', 'qwerty', 'uiopqw', 'asdfghjkl', 'qwertyui'],cost = [150, 250, 350, 450, 550, 650]) == -1\n assert candidate(source = \"ababababab\",target = \"bababababa\",original = ['aba', 'bab'],changed = ['bab', 'aba'],cost = [5, 10]) == -1\n assert candidate(source = \"ababababab\",target = \"cdcdcdcdcd\",original = ['ab', 'ba'],changed = ['cd', 'dc'],cost = [1, 2]) == 5\n assert candidate(source = \"abababababababababababab\",target = \"babababababababababababa\",original = ['ab', 'ba'],changed = ['ba', 'ab'],cost = [1, 2]) == 12\n assert candidate(source = \"abcdefgabcdefg\",target = \"gfedcbagfedcba\",original = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz'],changed = ['cba', 'fed', 'ihg', 'lkj', 'onm', 'rqp', 'uts', 'xwv', 'zy'],cost = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == -1\n assert candidate(source = \"abcabcabcabcabcabc\",target = \"defdefdefdefdefdef\",original = ['abc', 'def'],changed = ['def', 'abc'],cost = [1, 2]) == 6\n assert candidate(source = \"abcdef\",target = \"fedcba\",original = ['abc', 'def', 'fed'],changed = ['def', 'fed', 'abc'],cost = [100, 200, 300]) == -1\n assert candidate(source = \"abcabcabcabc\",target = \"cbacbacbacba\",original = ['abc', 'cba'],changed = ['cba', 'abc'],cost = [25, 35]) == 100\n assert candidate(source = \"aaaabbbbccccddddeeeeffff\",target = \"zzzzzzzzzzzzzzzzzzzzzzzzzz\",original = ['aaaa', 'bbbb', 'cccc', 'dddd', 'eeee', 'ffff'],changed = ['zzzz', 'zzzz', 'zzzz', 'zzzz', 'zzzz', 'zzzz'],cost = [100, 200, 300, 400, 500, 600]) == 2100\n assert candidate(source = \"abababab\",target = \"cdcdcdcd\",original = ['ab', 'ba', 'abcd', 'cd', 'dc'],changed = ['cd', 'cd', 'cdcd', 'ab', 'ab'],cost = [10, 20, 30, 40, 50]) == 40\n assert candidate(source = \"abcdefghij\",target = \"jihgfedcba\",original = ['abcdefghi', 'hgfedcba'],changed = ['jihgfedcba', 'abcdefghij'],cost = [500, 600]) == -1\n assert candidate(source = \"abcdefghijkl\",target = \"abcklmnopq\",original = ['def', 'ghi', 'jkl', 'mnop'],changed = ['ghi', 'jkl', 'mnop', 'nopq'],cost = [10, 15, 20, 25]) == -1\n assert candidate(source = \"abcdefghij\",target = \"jihgfedcba\",original = ['abcdefghi', 'bcdefgh', 'cdefgh', 'defgh', 'efgh', 'fgh', 'gh', 'h'],changed = ['ihgfedcb', 'ihgfedc', 'ihgfed', 'ihgfe', 'ihgf', 'ihg', 'ih', 'i'],cost = [1000, 900, 800, 700, 600, 500, 400, 300]) == -1\n assert candidate(source = \"abcdefghijklmnopqrstuvwxyz\",target = \"zyxwvutsrqponmlkjihgfedcba\",original = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz'],changed = ['xyz', 'wvu', 'tsr', 'qpo', 'nml', 'kji', 'hgf', 'edc', 'ba'],cost = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == -1\n assert candidate(source = \"abcdefgabcdefg\",target = \"ghijklmghijklm\",original = ['abc', 'def', 'ghi', 'jkl'],changed = ['ghi', 'jkl', 'mno', 'pqr'],cost = [50, 75, 100, 125]) == -1\n assert candidate(source = \"aaaaaaaaaaaaaaaaaaaa\",target = \"bbbbbbbbbbbbbbbbbbbb\",original = ['aaa', 'bbb', 'aab', 'abb'],changed = ['bbb', 'aaa', 'abb', 'aab'],cost = [10, 5, 20, 15]) == -1\n assert candidate(source = \"mississippi\",target = \"maddessippi\",original = ['issi', 'ippi', 'ippi', 'issi'],changed = ['addi', 'essi', 'ppii', 'ppii'],cost = [100, 200, 50, 300]) == -1\n assert candidate(source = \"abcdefg\",target = \"abcdefg\",original = ['abc', 'def', 'ghi'],changed = ['bcd', 'efg', 'hij'],cost = [10, 20, 30]) == 0\n assert candidate(source = \"thisisatargetstring\",target = \"thisisanoriginalstr\",original = ['target', 'string', 'atarget', 'original'],changed = ['original', 'str', 'isan', 'target'],cost = [12, 15, 7, 18]) == -1\n assert candidate(source = \"aaaaaabbbbbbccccccdddddd\",target = \"ddddddddccccccccbbbbbaaaaa\",original = ['aaaaaa', 'bbbbbb', 'cccccc', 'dddddd'],changed = ['dddddd', 'cccccc', 'bbbbbb', 'aaaaaa'],cost = [1000, 2000, 3000, 4000]) == -1\n assert candidate(source = \"ababababab\",target = \"bababababa\",original = ['aba', 'bab'],changed = ['bab', 'aba'],cost = [5, 7]) == -1\n assert candidate(source = \"mississippi\",target = \"missezzzzzzzzzz\",original = ['issi', 'ssis', 'ssiss', 'ippi', 'ppi', 'ippii'],changed = ['zzzz', 'pppi', 'issip', 'zzzz', 'ippp', 'zzzzz'],cost = [100, 200, 300, 400, 500, 600]) == -1\n assert candidate(source = \"abcdabcdabcd\",target = \"zzzzzzzzzzzz\",original = ['abcd', 'abc', 'bcd', 'cd', 'd', 'ab'],changed = ['zzzz', 'zzz', 'zzz', 'zz', 'z', 'zz'],cost = [100, 110, 120, 130, 140, 150]) == 300\n assert candidate(source = \"transform\",target = \"reformant\",original = ['trans', 'form', 'ant'],changed = ['reform', 'orm', 'tant'],cost = [150, 250, 350]) == -1\n assert candidate(source = \"aabbcc\",target = \"bbaaccaa\",original = ['aa', 'bb', 'cc', 'bb', 'aa'],changed = ['bb', 'cc', 'bb', 'aa', 'cc'],cost = [5, 10, 15, 20, 25]) == 25\n assert candidate(source = \"abcde\",target = \"edcba\",original = ['abc', 'cde', 'edc', 'cba'],changed = ['cde', 'edc', 'cba', 'abc'],cost = [10, 20, 30, 40]) == -1\n assert candidate(source = \"abcdefgabcdefgabcdefg\",target = \"bcdefgbcdefgbcdefga\",original = ['abcdefg'],changed = ['bcdefga'],cost = [500]) == -1\n assert candidate(source = \"complexproblemcomplexproblem\",target = \"simpleproblemcomplexproblem\",original = ['complex', 'problem', 'simple'],changed = ['simple', 'solution', 'complex'],cost = [100, 200, 50]) == -1\n assert candidate(source = \"abababab\",target = \"babababa\",original = ['aba', 'bab', 'aab'],changed = ['bab', 'aba', 'bab'],cost = [2, 3, 1]) == -1\n assert candidate(source = \"abcdefabcdef\",target = \"fedcbafedcba\",original = ['abc', 'def'],changed = ['def', 'abc'],cost = [50, 60]) == -1\n assert candidate(source = \"abcdefghijklmnopqrstuvwxyz\",target = \"zyxwvutsrqponmlkjihgfedcba\",original = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yza'],changed = ['uvw', 'rst', 'opq', 'lmn', 'fed', 'cba', 'zyx', 'wvu', 'tsr'],cost = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == -1\n assert candidate(source = \"aaaabbbbcccc\",target = \"bbbbaaaaaccc\",original = ['aaa', 'bbb', 'ccc'],changed = ['bbb', 'aaa', 'ccc'],cost = [10, 20, 30]) == -1\n assert candidate(source = \"hellohellohello\",target = \"worldworldworld\",original = ['hello', 'world'],changed = ['world', 'hello'],cost = [500, 300]) == 1500\n assert candidate(source = \"abcabcabcabc\",target = \"xyzxyzxyzxyz\",original = ['abc', 'ab', 'bc'],changed = ['xyz', 'yx', 'zx'],cost = [100, 50, 30]) == 400\n assert candidate(source = \"abcdefghij\",target = \"jihgfedcba\",original = ['abc', 'def', 'ghi', 'jkl'],changed = ['cba', 'fed', 'ihg', 'lkj'],cost = [10, 20, 30, 40]) == -1\n assert candidate(source = \"abcdefg\",target = \"zzzzzzz\",original = ['abc', 'def', 'gh', 'a', 'b', 'c', 'd', 'e', 'f', 'g'],changed = ['zzz', 'zzz', 'zzz', 'z', 'z', 'z', 'z', 'z', 'z', 'z'],cost = [100, 100, 100, 1, 2, 3, 4, 5, 6, 7]) == 28\n assert candidate(source = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",target = \"zzxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaa\",original = ['ab', 'cd', 'ef', 'gh', 'ij', 'kl', 'mn', 'op', 'qr', 'st', 'uv', 'wx', 'yz'],changed = ['ba', 'dc', 'fe', 'hg', 'ji', 'lk', 'no', 'po', 'rq', 'ts', 'vu', 'xw', 'zy'],cost = [111, 222, 333, 444, 555, 666, 777, 888, 999, 1111, 2222, 3333, 4444]) == -1\n assert candidate(source = \"aaaaabbbbbcccc\",target = \"bbbbbcccccddddd\",original = ['aaa', 'bbb', 'ccc'],changed = ['bbb', 'ccc', 'ddd'],cost = [1, 2, 3]) == -1\n assert candidate(source = \"abcdefghij\",target = \"ijabcdefgh\",original = ['abcdefgh', 'ijkl'],changed = ['ijkl', 'abcdefgh'],cost = [2000000, 2000000]) == -1\n assert candidate(source = \"abcdef\",target = \"fedcba\",original = ['abc', 'def'],changed = ['def', 'abc'],cost = [10, 20]) == -1\n assert candidate(source = \"abacabadabacaba\",target = \"xyzxyzxyzxyzxyz\",original = ['aba', 'bac', 'cab', 'abc'],changed = ['xyz', 'zyx', 'yxz', 'yzx'],cost = [1000, 2000, 3000, 4000]) == -1\n assert candidate(source = \"zzzzzzzzzz\",target = \"zzzzzzzzzz\",original = ['zzz', 'zzzz'],changed = ['zzzz', 'zzz'],cost = [1000, 2000]) == 0\n assert candidate(source = \"abcdefghijklmnopqrstuvwxyz\",target = \"zyxwvutsrqponmlkjihgfedcba\",original = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz'],changed = ['zyx', 'wvu', 'tsr', 'pon', 'mlk', 'jih', 'fed', 'cba', 'ba'],cost = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == -1\n assert candidate(source = \"abcdefghij\",target = \"zabcdefghi\",original = ['a', 'z'],changed = ['z', 'a'],cost = [1000000]) == -1\n assert candidate(source = \"xyxyxyxyxy\",target = \"yxyxyxyxyx\",original = ['xy', 'yx'],changed = ['yx', 'xy'],cost = [10, 5]) == 50\n assert candidate(source = \"abcdefghij\",target = \"abcdefghij\",original = ['abc', 'def', 'ghi', 'jkl'],changed = ['abc', 'def', 'ghi', 'jkl'],cost = [1, 1, 1, 1]) == 0\n assert candidate(source = \"xyzxyzxyz\",target = \"zyxzyxzyx\",original = ['xyz', 'zyx'],changed = ['zyx', 'xyz'],cost = [1, 2]) == 3\n assert candidate(source = \"mississippi\",target = \"hellohello\",original = ['issi', 'issipp', 'ippi', 'issipp', 'issipp'],changed = ['ello', 'ello', 'ello', 'ello', 'ello'],cost = [1, 2, 3, 4, 5]) == -1\n assert candidate(source = \"aabbccddeeff\",target = \"ffeeddccbbaa\",original = ['aa', 'bb', 'cc', 'dd', 'ee', 'ff'],changed = ['ff', 'ee', 'dd', 'cc', 'bb', 'aa'],cost = [1, 2, 3, 4, 5, 6]) == 21\n assert candidate(source = \"zzzzzzzz\",target = \"yyyyyyyy\",original = ['zzz', 'zyz', 'yzy'],changed = ['yyy', 'yyy', 'yyy'],cost = [10, 20, 5]) == -1\n assert candidate(source = \"aabbccddeeff\",target = \"ffeeddccbbaa\",original = ['ab', 'bc', 'cd', 'de', 'ef'],changed = ['fe', 'ed', 'dc', 'cb', 'ba'],cost = [1, 2, 3, 4, 5]) == -1\n assert candidate(source = \"aabbccddeeff\",target = \"zzzzzzzzzzzz\",original = ['aa', 'bb', 'cc', 'dd', 'ee', 'ff', 'abcdef'],changed = ['zz', 'zz', 'zz', 'zz', 'zz', 'zz', 'zzzzzz'],cost = [10, 10, 10, 10, 10, 10, 50]) == 60\n assert candidate(source = \"zzzzzzzzzz\",target = \"abcdefghij\",original = ['zzzz', 'zzz', 'zz', 'z'],changed = ['abcd', 'bcde', 'cdef', 'defg'],cost = [1000, 500, 250, 125]) == -1\n assert candidate(source = \"thisisaverylongstringthatweneedtoconvert\",target = \"toreallyconvertthislongstring\",original = ['this', 'very', 'long', 'string', 'that', 'need', 'to'],changed = ['to', 'need', 'that', 'convert', 'very', 'long', 'this'],cost = [1, 2, 3, 4, 5, 6, 7]) == -1\n assert candidate(source = \"abcdefghij\",target = \"jihgfedcba\",original = ['abc', 'def', 'ghi', 'jih', 'fed', 'cba'],changed = ['jih', 'fed', 'cba', 'abc', 'def', 'ghi'],cost = [100, 200, 300, 400, 500, 600]) == -1\n assert candidate(source = \"aabbccddeeff\",target = \"ffeeddccbbaa\",original = ['aab', 'bcc', 'dde', 'eff'],changed = ['ff', 'ee', 'dd', 'cc'],cost = [1, 2, 3, 4]) == -1\n assert candidate(source = \"aaaaabbbbbcccccdddddeeeee\",target = \"eeeeeaaaaabbbbcccccd\",original = ['aaaaa', 'bbbbb', 'ccccc', 'ddddd', 'eeeee'],changed = ['eeeee', 'aaaaa', 'bbbbb', 'ccccc', 'ddddd'],cost = [100, 200, 300, 400, 500]) == -1\n assert candidate(source = \"abcabcabcabcabcabcabcabcabcabc\",target = \"xyzxyzxyzxyzxyzxyzxyzxyzxyzxyz\",original = ['abc', 'bc', 'c', 'a', 'b', 'ab', 'bc', 'ca'],changed = ['xyz', 'yz', 'z', 'x', 'y', 'xy', 'yz', 'zx'],cost = [10, 20, 30, 40, 50, 60, 70, 80]) == 100\n assert candidate(source = \"conversionexampleexample\",target = \"transformationexampleexample\",original = ['conversion', 'transformation'],changed = ['transformation', 'conversion'],cost = [40, 60]) == -1\n assert candidate(source = \"abacabadabacaba\",target = \"zzzzzzzzzzzzzzz\",original = ['aba', 'abc', 'aca', 'bca', 'cab'],changed = ['zzz', 'zzz', 'zzz', 'zzz', 'zzz'],cost = [10, 20, 30, 40, 50]) == -1\n assert candidate(source = \"abacabadabacabad\",target = \"xyzxyzxyzxyz\",original = ['aba', 'bac', 'cad', 'bad', 'abc', 'acb', 'bcd', 'bca', 'cab', 'cba'],changed = ['xyz', 'zyx', 'yzx', 'xyz', 'zyx', 'yzx', 'xyz', 'zyx', 'yzx', 'xyz'],cost = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == -1\n assert candidate(source = \"xyzxyzxyz\",target = \"uvwuvwuvw\",original = ['xyz', 'yzx', 'zxy', 'xy', 'yz', 'zx', 'x', 'y', 'z'],changed = ['uvw', 'uvw', 'uvw', 'uv', 'uw', 'vw', 'u', 'v', 'w'],cost = [100, 150, 200, 10, 20, 30, 1, 2, 3]) == 18\n assert candidate(source = \"aaaaabbbbb\",target = \"bbbbbbaaaa\",original = ['aaaa', 'bbbb'],changed = ['bbbb', 'aaaa'],cost = [1000, 2000]) == -1\n assert candidate(source = \"aabbccddeeff\",target = \"aabbccddeeff\",original = ['aa', 'bb', 'cc', 'dd', 'ee', 'ff'],changed = ['bb', 'cc', 'dd', 'ee', 'ff', 'aa'],cost = [10, 20, 30, 40, 50, 60]) == 0\n assert candidate(source = \"abababababababababab\",target = \"babababababababababa\",original = ['ab', 'ba'],changed = ['ba', 'ab'],cost = [3, 2]) == 30\n assert candidate(source = \"repeatedsubstringsubstring\",target = \"differentsubstringsubstring\",original = ['repeated', 'different'],changed = ['different', 'repeated'],cost = [100, 120]) == -1\n assert candidate(source = \"qwertyuiop\",target = \"zxcvbnmzxc\",original = ['qw', 'er', 'ty', 'ui', 'op', 'zxc', 'cv', 'bn', 'm', 'zx', 'xc'],changed = ['zx', 'xc', 'cv', 'bn', 'm', 'qw', 'er', 'ty', 'ui', 'op', 'zxc'],cost = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == -1\n assert candidate(source = \"mississippi\",target = \"mississippa\",original = ['ippi'],changed = ['appa'],cost = [5]) == -1\n assert candidate(source = \"abcdefghijklmnopqrstuvwxyz\",target = \"zyxwvutsrqponmlkjihgfedcba\",original = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz'],changed = ['zyx', 'wvu', 'tsr', 'pon', 'mlk', 'jih', 'gf', 'ed', 'cb'],cost = [100, 200, 300, 400, 500, 600, 700, 800, 900]) == -1\n assert candidate(source = \"aaaaabbbbbaaaaabbbbbaaaaabbbbbaaaaa\",target = \"zzzzzxxxxxzzzzzxxxxxzzzzzxxxxxzzzzz\",original = ['aaaaa', 'bbbbb', 'xxxxx', 'zzzzz'],changed = ['zzzzz', 'aaaaa', 'zzzzz', 'xxxxx'],cost = [100, 200, 300, 400]) == 2500\n assert candidate(source = \"xyxyxyxyxyxyxyxyxy\",target = \"yxyxyxyxyxyxyxyxyx\",original = ['xy', 'yx'],changed = ['yx', 'xy'],cost = [1, 2]) == 9\n assert candidate(source = \"abcdefghijklmnopqrstuvwxyz\",target = \"zyxwvutsrqponmlkjihgfedcba\",original = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz'],changed = ['zyx', 'wvu', 'tsr', 'pon', 'mlk', 'jih', 'fed', 'cba', 'abc'],cost = [100, 200, 300, 400, 500, 600, 700, 800, 900]) == -1\n assert candidate(source = \"nestednestednested\",target = \"deepdeepdeep\",original = ['nested', 'deep'],changed = ['deep', 'nested'],cost = [50, 30]) == -1\n assert candidate(source = \"thisisatest\",target = \"tistiatest\",original = ['this', 'test'],changed = ['tist', 'taste'],cost = [50, 70]) == -1\n"}, "metadata": {"canonical_parameter_names": ["source", "target", "original", "changed", "cost"], "leetcode_dataset_entry_point": "Solution().minimumCost", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "long long minimumCost(string source, string target, vector& original, vector& changed, vector& cost) {", "container": "Solution", "callable": "minimumCost", "parameters": [{"name": "source", "type": "string"}, {"name": "target", "type": "string"}, {"name": "original", "type": "vector&"}, {"name": "changed", "type": "vector&"}, {"name": "cost", "type": "vector&"}], "return_type": "long long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2980, "task_id": "check-if-bitwise-or-has-trailing-zeros", "difficulty": "Easy", "problem_description": "You are given an array of positive integers nums.\nYou have to check if it is possible to select two or more elements in the array such that the bitwise OR of the selected elements has at least one trailing zero in its binary representation.\nFor example, the binary representation of 5, which is \"101\", does not have any trailing zeros, whereas the binary representation of 4, which is \"100\", has two trailing zeros.\nReturn true if it is possible to select two or more elements whose bitwise OR has trailing zeros, return false otherwise.\n \nExample 1:\n\nInput: nums = [1,2,3,4,5]\nOutput: true\nExplanation: If we select the elements 2 and 4, their bitwise OR is 6, which has the binary representation \"110\" with one trailing zero.\n\nExample 2:\n\nInput: nums = [2,4,8,16]\nOutput: true\nExplanation: If we select the elements 2 and 4, their bitwise OR is 6, which has the binary representation \"110\" with one trailing zero.\nOther possible ways to select elements to have trailing zeroes in the binary representation of their bitwise OR are: (2, 8), (2, 16), (4, 8), (4, 16), (8, 16), (2, 4, 8), (2, 4, 16), (2, 8, 16), (4, 8, 16), and (2, 4, 8, 16).\n\nExample 3:\n\nInput: nums = [1,3,5,7,9]\nOutput: false\nExplanation: There is no possible way to select two or more elements to have trailing zeros in the binary representation of their bitwise OR.\n\n \nConstraints:\n\n2 <= nums.length <= 100\n1 <= nums[i] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 1, 1, 1]) == False\n assert candidate(nums = [1, 3, 5, 7, 9]) == False\n assert candidate(nums = [5, 7, 9, 11]) == False\n assert candidate(nums = [7, 11, 13, 14]) == False\n assert candidate(nums = [3, 6, 9, 12, 15]) == True\n assert candidate(nums = [11, 13, 15, 17]) == False\n assert candidate(nums = [1, 2, 3, 4, 5]) == True\n assert candidate(nums = [2, 4, 8, 16]) == True\n assert candidate(nums = [6, 12, 18, 24, 30]) == True\n assert candidate(nums = [5, 7, 11, 13]) == False\n assert candidate(nums = [9, 18, 27, 36]) == True\n assert candidate(nums = [2, 2, 2, 2]) == True\n assert candidate(nums = [8, 16, 32]) == True\n assert candidate(nums = [6, 12, 18, 24]) == True\n assert candidate(nums = [32, 64, 128, 256]) == True\n assert candidate(nums = [3, 5]) == False\n assert candidate(nums = [5, 10, 15, 20]) == True\n assert candidate(nums = [1, 2, 4, 8, 16, 32]) == True\n assert candidate(nums = [1, 2]) == False\n assert candidate(nums = [5, 7, 9, 11, 13]) == False\n assert candidate(nums = [7, 14, 21, 28]) == True\n assert candidate(nums = [10, 20, 30, 40]) == True\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == False\n assert candidate(nums = [10, 18, 22, 34, 50, 62]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8]) == True\n assert candidate(nums = [101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115]) == True\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == True\n assert candidate(nums = [32, 64, 128, 256]) == True\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == True\n assert candidate(nums = [7, 15, 23, 31, 39, 47, 55, 63, 71, 79]) == False\n assert candidate(nums = [31, 63, 127, 255, 511, 1023, 2047]) == False\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37]) == False\n assert candidate(nums = [2, 3, 4, 6, 8, 10]) == True\n assert candidate(nums = [14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133]) == True\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == True\n assert candidate(nums = [32, 64, 128, 256, 512, 1024]) == True\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64]) == True\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48]) == True\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80]) == True\n assert candidate(nums = [101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120]) == True\n assert candidate(nums = [10, 20, 40, 80, 160, 320]) == True\n assert candidate(nums = [101, 102, 104, 108, 112]) == True\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == True\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150]) == True\n assert candidate(nums = [3, 6, 9, 12, 15]) == True\n assert candidate(nums = [3, 7, 11, 15, 19, 23, 27, 31, 35, 39]) == False\n assert candidate(nums = [16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240]) == True\n assert candidate(nums = [15, 23, 31, 39, 47, 55, 63, 71, 79, 87, 95, 103, 111, 119, 127]) == False\n assert candidate(nums = [7, 14, 21, 28, 35]) == True\n assert candidate(nums = [8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]) == True\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512]) == True\n assert candidate(nums = [2, 3, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(nums = [30, 60, 90, 120, 150, 180, 210, 240, 270, 300]) == True\n assert candidate(nums = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72]) == True\n assert candidate(nums = [11, 14, 19, 22, 27, 30, 35, 38, 43]) == True\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == False\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]) == True\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128]) == True\n assert candidate(nums = [25, 50, 75, 100, 125, 150, 175, 200, 225, 250]) == True\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == True\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120]) == True\n assert candidate(nums = [101, 102, 103, 104, 105, 106, 107, 108, 109, 110]) == True\n assert candidate(nums = [10, 14, 18, 22, 26]) == True\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == True\n assert candidate(nums = [17, 33, 65, 129, 257]) == False\n assert candidate(nums = [4, 8, 16, 32, 64, 128, 256, 512, 1024]) == True\n assert candidate(nums = [10, 12, 14, 16, 18, 20, 22]) == True\n assert candidate(nums = [31, 62, 124, 248, 496, 992, 1984, 3968, 7936, 15872, 31744, 63488, 126976, 253952, 507904]) == True\n assert candidate(nums = [8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536]) == True\n assert candidate(nums = [101, 102, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 144, 148, 152, 156, 160, 164, 168, 172, 176, 180, 184, 188, 192]) == True\n assert candidate(nums = [50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78]) == True\n assert candidate(nums = [17, 34, 51, 68, 85]) == True\n assert candidate(nums = [63, 62, 61, 60, 59, 58, 57, 56, 55, 54]) == True\n assert candidate(nums = [17, 19, 21, 23, 25, 27, 29, 31]) == False\n assert candidate(nums = [65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79]) == True\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == False\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21]) == True\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049]) == False\n assert candidate(nums = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16]) == True\n assert candidate(nums = [2, 3, 6, 12, 24, 48]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == True\n assert candidate(nums = [25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == True\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15]) == False\n assert candidate(nums = [10, 20, 30, 40, 50]) == True\n assert candidate(nums = [8, 16, 32, 64, 128, 256, 512]) == True\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == True\n assert candidate(nums = [4, 12, 20, 28, 36, 44, 52]) == True\n assert candidate(nums = [129, 131, 133, 135, 137, 139, 141, 143, 145, 147, 149, 151, 153, 155, 157]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == True\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85]) == True\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == False\n assert candidate(nums = [33, 35, 37, 39, 41, 43, 45, 47, 49, 51]) == False\n assert candidate(nums = [6, 12, 18, 24, 30, 36, 42]) == True\n assert candidate(nums = [1, 3, 5, 7, 8, 9, 11]) == False\n assert candidate(nums = [2, 6, 10, 14, 18, 22, 26, 30, 34, 38]) == True\n assert candidate(nums = [101, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128]) == True\n assert candidate(nums = [99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109]) == True\n assert candidate(nums = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60]) == True\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]) == True\n assert candidate(nums = [32, 64, 128, 256, 512]) == True\n assert candidate(nums = [3, 6, 12, 24, 48, 96, 192, 384, 768, 1536, 3072, 6144, 12288, 24576, 49152]) == True\n assert candidate(nums = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == False\n assert candidate(nums = [10, 12, 14, 16, 18, 20]) == True\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == True\n assert candidate(nums = [1, 2, 3, 5, 6, 7, 10, 11, 13, 14, 15]) == True\n assert candidate(nums = [101, 102, 104, 105, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126]) == True\n assert candidate(nums = [25, 30, 40, 50, 60, 70]) == True\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == True\n assert candidate(nums = [16, 32, 64, 128, 256]) == True\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53]) == False\n assert candidate(nums = [25, 26, 27, 28, 29, 30, 31, 32, 33, 34]) == True\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61]) == False\n assert candidate(nums = [101, 104, 109, 112, 117, 120, 125, 128]) == True\n assert candidate(nums = [30, 42, 54, 66, 78, 90]) == True\n assert candidate(nums = [10, 12, 14, 16, 18, 20, 22, 24]) == True\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55]) == True\n assert candidate(nums = [51, 53, 57, 61, 65, 69, 73, 77]) == False\n assert candidate(nums = [65, 130, 195, 260, 325, 390, 455, 520, 585, 650]) == True\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().hasTrailingZeros", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool hasTrailingZeros(vector& nums) {", "container": "Solution", "callable": "hasTrailingZeros", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2981, "task_id": "find-longest-special-substring-that-occurs-thrice-i", "difficulty": "Medium", "problem_description": "You are given a string s that consists of lowercase English letters.\nA string is called special if it is made up of only a single character. For example, the string \"abc\" is not special, whereas the strings \"ddd\", \"zz\", and \"f\" are special.\nReturn the length of the longest special substring of s which occurs at least thrice, or -1 if no special substring occurs at least thrice.\nA substring is a contiguous non-empty sequence of characters within a string.\n \nExample 1:\n\nInput: s = \"aaaa\"\nOutput: 2\nExplanation: The longest special substring which occurs thrice is \"aa\": substrings \"aaaa\", \"aaaa\", and \"aaaa\".\nIt can be shown that the maximum length achievable is 2.\n\nExample 2:\n\nInput: s = \"abcdef\"\nOutput: -1\nExplanation: There exists no special substring which occurs at least thrice. Hence return -1.\n\nExample 3:\n\nInput: s = \"abcaba\"\nOutput: 1\nExplanation: The longest special substring which occurs thrice is \"a\": substrings \"abcaba\", \"abcaba\", and \"abcaba\".\nIt can be shown that the maximum length achievable is 1.\n\n \nConstraints:\n\n3 <= s.length <= 50\ns consists of only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"zzzzzzzzz\") == 7\n assert candidate(s = \"abcabcabc\") == 1\n assert candidate(s = \"aaabbbccc\") == 1\n assert candidate(s = \"aabbcc\") == -1\n assert candidate(s = \"aaaabbbbcccc\") == 2\n assert candidate(s = \"abcabcabcabc\") == 1\n assert candidate(s = \"aaaaaa\") == 4\n assert candidate(s = \"ababab\") == 1\n assert candidate(s = \"zzzzzz\") == 4\n assert candidate(s = \"abcaba\") == 1\n assert candidate(s = \"zzzzyzzzz\") == 3\n assert candidate(s = \"abcdef\") == -1\n assert candidate(s = \"aabbaabbaa\") == 2\n assert candidate(s = \"abcabc\") == -1\n assert candidate(s = \"aaaabb\") == 2\n assert candidate(s = \"aaabbb\") == 1\n assert candidate(s = \"aaaa\") == 2\n assert candidate(s = \"aaaabaaa\") == 3\n assert candidate(s = \"mnopmnopmnopmnop\") == 1\n assert candidate(s = \"aaaaaaaabbaaaaaaabbaaaaaaa\") == 7\n assert candidate(s = \"aaabbbcccdddaaaabbbcccddd\") == 3\n assert candidate(s = \"aabbaaabaabb\") == 2\n assert candidate(s = \"abcdefabcdefabcdef\") == 1\n assert candidate(s = \"abacabadabacabadabacabadabacabad\") == 1\n assert candidate(s = \"aabbccddeeefffgggaaaabbbcccddd\") == 2\n assert candidate(s = \"zzzzzzzzzzzzzzz\") == 13\n assert candidate(s = \"aabbbcccaabbcccaa\") == 2\n assert candidate(s = \"aaaaaaaabbaaaaaaa\") == 7\n assert candidate(s = \"hhhhhhhhhhhhhhhhhiiiiiiiihhhhiiiiiii\") == 15\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 30\n assert candidate(s = \"abcddcbaabcddcba\") == 1\n assert candidate(s = \"cccccccccccccccccccc\") == 18\n assert candidate(s = \"ccccaaaabbbccc\") == 3\n assert candidate(s = \"aaabbbcccddd\") == 1\n assert candidate(s = \"abacabadabacab\") == 1\n assert candidate(s = \"zzzzyyyyxxxwwvvuuttrrssqqppoonnmmllkkjjiihhggffeeddccbbaaa\") == 2\n assert candidate(s = \"aabbaabbaabbaabb\") == 2\n assert candidate(s = \"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj\") == 44\n assert candidate(s = \"aaabbbaaabbbaaabb\") == 3\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 1\n assert candidate(s = \"xxyyxxyyxxyy\") == 2\n assert candidate(s = \"ababababababababababababababab\") == 1\n assert candidate(s = \"zzzzzzyzzzzz\") == 5\n assert candidate(s = \"zzzzzzzzzzzz\") == 10\n assert candidate(s = \"qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\") == 44\n assert candidate(s = \"abababababab\") == 1\n assert candidate(s = \"abcabcabcabcabcabc\") == 1\n assert candidate(s = \"xyzxyzzxyzyzyx\") == 1\n assert candidate(s = \"aabbbcccbbbccccccbbbaabbcc\") == 4\n assert candidate(s = \"aaaaaabaaaaabaaaaa\") == 5\n assert candidate(s = \"mnopqrstuvwxyzaaa\") == 1\n assert candidate(s = \"abcdabcdabcdabcd\") == 1\n assert candidate(s = \"aaaaaaa\") == 5\n assert candidate(s = \"ppppqqppqqqqqqpp\") == 4\n assert candidate(s = \"abcdabcdabcdabcdabcd\") == 1\n assert candidate(s = \"abababababababababab\") == 1\n assert candidate(s = \"abababab\") == 1\n assert candidate(s = \"nnnmmmnnnmmmnnnmmmm\") == 3\n assert candidate(s = \"aaaaaaaabbbbbbbbbb\") == 8\n assert candidate(s = \"abacabadabacaba\") == 1\n assert candidate(s = \"aabbaaabbbaaaabbb\") == 3\n assert candidate(s = \"aabbccddeeefffggg\") == 1\n assert candidate(s = \"aaaaaabbbcccaabb\") == 4\n assert candidate(s = \"aaaabbbbccccddddeeeeffff\") == 2\n assert candidate(s = \"vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv\") == 58\n assert candidate(s = \"aaabbbcccaaaabbb\") == 3\n assert candidate(s = \"xyxyxyxyxyxyxyx\") == 1\n assert candidate(s = \"zzzzzzzzzzzzz\") == 11\n assert candidate(s = \"aaabbbaaabbbbaaabbbbaaabbb\") == 3\n assert candidate(s = \"tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt\") == 74\n assert candidate(s = \"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk\") == 48\n assert candidate(s = \"aaaaabbbaaaaaaaaabbbaaaa\") == 7\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == -1\n assert candidate(s = \"pppppqqqqqrrrrrppqqrr\") == 3\n assert candidate(s = \"aaabbaaabbaa\") == 2\n assert candidate(s = \"ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss\") == 62\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzz\") == 8\n assert candidate(s = \"kkkkkllllllmmmmm\") == 4\n assert candidate(s = \"lkllkkkklllllllllllkkk\") == 9\n assert candidate(s = \"ppppqpppqqqpppp\") == 3\n assert candidate(s = \"aaabbbcccdddcccbbbcccbbbcccaaacccaaa\") == 3\n assert candidate(s = \"aaabbbcccdddeeefffgggaaaabbbcccddd\") == 3\n assert candidate(s = \"abcddcba\") == -1\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyz\") == -1\n assert candidate(s = \"cccccbbbbbbaaaaa\") == 4\n assert candidate(s = \"mmmmmnnnnooooo\") == 3\n assert candidate(s = \"abcabcabcabcabcab\") == 1\n assert candidate(s = \"tttttttttttttttttttttttttt\") == 24\n assert candidate(s = \"aaaaaaaabaaaaaa\") == 6\n assert candidate(s = \"aaaaabbbbcccc\") == 3\n assert candidate(s = \"xzyxzyxzyxzyxzyxzy\") == 1\n assert candidate(s = \"wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww\") == 46\n assert candidate(s = \"abcabcabcabcabc\") == 1\n assert candidate(s = \"uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu\") == 52\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 48\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().maximumLength", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maximumLength(string s) {", "container": "Solution", "callable": "maximumLength", "parameters": [{"name": "s", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2982, "task_id": "find-longest-special-substring-that-occurs-thrice-ii", "difficulty": "Medium", "problem_description": "You are given a string s that consists of lowercase English letters.\nA string is called special if it is made up of only a single character. For example, the string \"abc\" is not special, whereas the strings \"ddd\", \"zz\", and \"f\" are special.\nReturn the length of the longest special substring of s which occurs at least thrice, or -1 if no special substring occurs at least thrice.\nA substring is a contiguous non-empty sequence of characters within a string.\n \nExample 1:\n\nInput: s = \"aaaa\"\nOutput: 2\nExplanation: The longest special substring which occurs thrice is \"aa\": substrings \"aaaa\", \"aaaa\", and \"aaaa\".\nIt can be shown that the maximum length achievable is 2.\n\nExample 2:\n\nInput: s = \"abcdef\"\nOutput: -1\nExplanation: There exists no special substring which occurs at least thrice. Hence return -1.\n\nExample 3:\n\nInput: s = \"abcaba\"\nOutput: 1\nExplanation: The longest special substring which occurs thrice is \"a\": substrings \"abcaba\", \"abcaba\", and \"abcaba\".\nIt can be shown that the maximum length achievable is 1.\n\n \nConstraints:\n\n3 <= s.length <= 5 * 105\ns consists of only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"zzzzzzzzz\") == 7\n assert candidate(s = \"aaabbbccc\") == 1\n assert candidate(s = \"aabbbcccaaa\") == 2\n assert candidate(s = \"abcdef\") == -1\n assert candidate(s = \"abacabadabacaba\") == 1\n assert candidate(s = \"abcabcabc\") == 1\n assert candidate(s = \"abcaba\") == 1\n assert candidate(s = \"aaaaabbbbccccc\") == 3\n assert candidate(s = \"aabbaabbcc\") == 1\n assert candidate(s = \"aaaaaaaaaa\") == 8\n assert candidate(s = \"aaaabbbbcccc\") == 2\n assert candidate(s = \"abababababa\") == 1\n assert candidate(s = \"abcdabcabcd\") == 1\n assert candidate(s = \"aabbccddeeefff\") == 1\n assert candidate(s = \"aabbccddeeffgg\") == -1\n assert candidate(s = \"aaaa\") == 2\n assert candidate(s = \"aaabaaa\") == 2\n assert candidate(s = \"aaaaabbbbbaaaa\") == 4\n assert candidate(s = \"nnnhaaaannn\") == 2\n assert candidate(s = \"zzzzz\") == 3\n assert candidate(s = \"aabbaabbccddccddc\") == 1\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == -1\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().maximumLength", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maximumLength(string s) {", "container": "Solution", "callable": "maximumLength", "parameters": [{"name": "s", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2983, "task_id": "palindrome-rearrangement-queries", "difficulty": "Hard", "problem_description": "You are given a 0-indexed string s having an even length n.\nYou are also given a 0-indexed 2D integer array, queries, where queries[i] = [ai, bi, ci, di].\nFor each query i, you are allowed to perform the following operations:\n\nRearrange the characters within the substring s[ai:bi], where 0 <= ai <= bi < n / 2.\nRearrange the characters within the substring s[ci:di], where n / 2 <= ci <= di < n.\n\nFor each query, your task is to determine whether it is possible to make s a palindrome by performing the operations.\nEach query is answered independently of the others.\nReturn a 0-indexed array answer, where answer[i] == true if it is possible to make s a palindrome by performing operations specified by the ith query, and false otherwise.\n\nA substring is a contiguous sequence of characters within a string.\ns[x:y] represents the substring consisting of characters from the index x to index y in s, both inclusive.\n\n \nExample 1:\n\nInput: s = \"abcabc\", queries = [[1,1,3,5],[0,2,5,5]]\nOutput: [true,true]\nExplanation: In this example, there are two queries:\nIn the first query:\n- a0 = 1, b0 = 1, c0 = 3, d0 = 5.\n- So, you are allowed to rearrange s[1:1] => abcabc and s[3:5] => abcabc.\n- To make s a palindrome, s[3:5] can be rearranged to become => abccba.\n- Now, s is a palindrome. So, answer[0] = true.\nIn the second query:\n- a1 = 0, b1 = 2, c1 = 5, d1 = 5.\n- So, you are allowed to rearrange s[0:2] => abcabc and s[5:5] => abcabc.\n- To make s a palindrome, s[0:2] can be rearranged to become => cbaabc.\n- Now, s is a palindrome. So, answer[1] = true.\n\nExample 2:\n\nInput: s = \"abbcdecbba\", queries = [[0,2,7,9]]\nOutput: [false]\nExplanation: In this example, there is only one query.\na0 = 0, b0 = 2, c0 = 7, d0 = 9.\nSo, you are allowed to rearrange s[0:2] => abbcdecbba and s[7:9] => abbcdecbba.\nIt is not possible to make s a palindrome by rearranging these substrings because s[3:6] is not a palindrome.\nSo, answer[0] = false.\nExample 3:\n\nInput: s = \"acbcab\", queries = [[1,2,4,5]]\nOutput: [true]\nExplanation: In this example, there is only one query.\na0 = 1, b0 = 2, c0 = 4, d0 = 5.\nSo, you are allowed to rearrange s[1:2] => acbcab and s[4:5] => acbcab.\nTo make s a palindrome s[1:2] can be rearranged to become abccab.\nThen, s[4:5] can be rearranged to become abccba.\nNow, s is a palindrome. So, answer[0] = true.\n \nConstraints:\n\n2 <= n == s.length <= 105\n1 <= queries.length <= 105\nqueries[i].length == 4\nai == queries[i][0], bi == queries[i][1]\nci == queries[i][2], di == queries[i][3]\n0 <= ai <= bi < n / 2\nn / 2 <= ci <= di < n \nn is even.\ns consists of only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abbcdecbba\",queries = [[0, 2, 7, 9]]) == [False]\n assert candidate(s = \"abcabc\",queries = [[1, 1, 3, 5], [0, 2, 5, 5]]) == [True, True]\n assert candidate(s = \"abcdefgfedcba\",queries = [[1, 2, 11, 12], [3, 4, 8, 9]]) == [True, True]\n assert candidate(s = \"acbcab\",queries = [[1, 2, 4, 5]]) == [True]\n assert candidate(s = \"aabbaa\",queries = [[0, 2, 3, 5]]) == [True]\n assert candidate(s = \"abcdedcba\",queries = [[0, 1, 7, 8], [2, 3, 5, 6]]) == [True, True]\n assert candidate(s = \"aabbccdd\",queries = [[0, 1, 6, 7], [2, 3, 4, 5]]) == [False, False]\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",queries = [[0, 19, 38, 57], [1, 18, 39, 56], [2, 17, 40, 55]]) == [False, False, False]\n assert candidate(s = \"abcdexyzwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\",queries = [[0, 1, 38, 39], [2, 3, 36, 37], [4, 5, 34, 35]]) == [False, False, False]\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",queries = [[0, 9, 32, 41], [1, 5, 28, 37], [2, 7, 25, 34]]) == [False, False, False]\n assert candidate(s = \"racecaracercar\",queries = [[0, 2, 10, 12], [3, 5, 8, 10], [1, 4, 7, 9]]) == [False, False, False]\n assert candidate(s = \"abacaxbaxaba\",queries = [[0, 1, 9, 10], [2, 3, 7, 8], [4, 5, 5, 6]]) == [False, False, False]\n assert candidate(s = \"abacabadabacaba\",queries = [[0, 4, 11, 15], [1, 3, 12, 14], [2, 2, 13, 13]]) == [True, True, True]\n assert candidate(s = \"aabbccddeeffgg\",queries = [[0, 5, 7, 12], [2, 3, 10, 11]]) == [False, False]\n assert candidate(s = \"mississippiissippi\",queries = [[0, 4, 10, 14], [1, 3, 11, 13]]) == [False, False]\n assert candidate(s = \"abcdefghijhgfedcba\",queries = [[0, 4, 14, 18], [1, 3, 15, 17], [2, 2, 16, 16]]) == [False, False, False]\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",queries = [[0, 11, 34, 45], [12, 22, 23, 33]]) == [False, False]\n assert candidate(s = \"mississippiissippi\",queries = [[0, 4, 10, 14], [2, 6, 8, 12]]) == [False, False]\n assert candidate(s = \"abacabadabacaba\",queries = [[0, 6, 11, 17], [1, 5, 12, 16], [2, 4, 13, 15]]) == [True, True, True]\n assert candidate(s = \"xyzyxzyzyxzyzyxzyz\",queries = [[0, 3, 9, 12], [4, 7, 13, 16], [1, 2, 17, 18]]) == [False, False, False]\n assert candidate(s = \"aaaabbbbccccdddd\",queries = [[0, 3, 12, 15], [1, 2, 13, 14], [2, 3, 14, 15]]) == [False, False, False]\n assert candidate(s = \"racecarannakayak\",queries = [[0, 6, 8, 13], [1, 5, 9, 12]]) == [False, False]\n assert candidate(s = \"noonnoon\",queries = [[0, 2, 5, 7], [1, 3, 4, 6]]) == [True, True]\n assert candidate(s = \"abcdeedcba\",queries = [[0, 4, 5, 9], [1, 3, 6, 8], [2, 2, 7, 7]]) == [True, True, True]\n assert candidate(s = \"xyzxyzxyzxyzxyzxyzxyzxyzxyzxyz\",queries = [[0, 3, 15, 18], [1, 4, 14, 17], [2, 5, 13, 16], [3, 6, 12, 15], [4, 7, 11, 14]]) == [False, False, False, False, False]\n assert candidate(s = \"mississippiissippi\",queries = [[0, 2, 9, 11], [1, 3, 8, 10], [2, 4, 7, 9]]) == [False, False, False]\n assert candidate(s = \"rotorrotorrotorrotor\",queries = [[0, 4, 12, 16], [2, 5, 10, 14], [3, 6, 11, 15]]) == [True, True, True]\n assert candidate(s = \"abacabadabacabad\",queries = [[0, 7, 8, 15], [1, 6, 9, 14], [2, 5, 10, 13], [3, 4, 11, 12]]) == [True, False, False, False]\n assert candidate(s = \"abcdefghijzyxwvutsrqponmlkjihgfedcba\",queries = [[0, 9, 20, 29], [1, 8, 21, 28], [2, 7, 22, 27], [3, 6, 23, 26], [4, 5, 24, 25]]) == [False, False, False, False, False]\n assert candidate(s = \"rotorrotor\",queries = [[0, 2, 6, 8], [1, 4, 5, 7]]) == [True, True]\n assert candidate(s = \"thisisanoddlengthstring\",queries = [[0, 4, 14, 19]]) == [False]\n assert candidate(s = \"aabbccddeeff\",queries = [[0, 2, 9, 11], [1, 3, 8, 10], [2, 4, 7, 9]]) == [False, False, False]\n assert candidate(s = \"mississippiissim\",queries = [[0, 3, 11, 14], [2, 4, 9, 12], [1, 5, 8, 11]]) == [False, False, False]\n assert candidate(s = \"abacabadabacabad\",queries = [[0, 3, 8, 11], [1, 2, 6, 7], [4, 5, 12, 13]]) == [False, False, False]\n assert candidate(s = \"mississippi\",queries = [[1, 2, 7, 8], [0, 1, 10, 11], [3, 4, 6, 7]]) == [False, False, False]\n assert candidate(s = \"abcdedcbaa\",queries = [[0, 1, 8, 9], [2, 3, 6, 7], [1, 4, 5, 8]]) == [False, False, False]\n assert candidate(s = \"zzzzzzzzzz\",queries = [[0, 4, 5, 9], [1, 3, 6, 8], [2, 2, 7, 7]]) == [True, True, True]\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\",queries = [[0, 1, 28, 29], [1, 2, 27, 28], [2, 3, 26, 27], [3, 4, 25, 26], [4, 5, 24, 25], [5, 6, 23, 24]]) == [False, False, False, False, False, False]\n assert candidate(s = \"abacabadabacabad\",queries = [[0, 3, 8, 11], [1, 4, 9, 12], [2, 5, 10, 13]]) == [False, False, False]\n assert candidate(s = \"aaabbbcccdddeeefffggg\",queries = [[0, 4, 11, 15], [1, 2, 9, 10]]) == [False, False]\n assert candidate(s = \"racecarannakayak\",queries = [[0, 2, 9, 11], [1, 3, 8, 10], [2, 4, 7, 9]]) == [False, False, False]\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",queries = [[0, 5, 26, 31], [6, 10, 22, 26], [11, 15, 17, 21]]) == [False, False, False]\n assert candidate(s = \"noonnoon\",queries = [[0, 1, 5, 6], [2, 3, 4, 5]]) == [True, True]\n assert candidate(s = \"zyxzyxzyxzyx\",queries = [[0, 2, 9, 11], [3, 5, 6, 8]]) == [False, False]\n assert candidate(s = \"abcabcabcabcabcabcabcabc\",queries = [[0, 5, 21, 26], [6, 11, 15, 20], [12, 17, 9, 14]]) == [False, False, False]\n assert candidate(s = \"noonnoonnoon\",queries = [[1, 3, 9, 11], [2, 4, 8, 10], [0, 2, 6, 8]]) == [True, True, True]\n assert candidate(s = \"abacaxabacax\",queries = [[0, 2, 8, 10], [1, 3, 6, 8]]) == [False, False]\n assert candidate(s = \"abcdefghijkzyxwvutsrqponml\",queries = [[0, 4, 19, 23], [2, 3, 17, 18]]) == [False, False]\n assert candidate(s = \"noonnoonnoonnoon\",queries = [[0, 3, 12, 15], [1, 2, 13, 14]]) == [True, True]\n assert candidate(s = \"xyzzyxzyxzyx\",queries = [[0, 1, 10, 11], [2, 3, 8, 9], [4, 5, 6, 7]]) == [False, False, False]\n assert candidate(s = \"abacabadabacaba\",queries = [[0, 2, 9, 11], [1, 3, 10, 12], [2, 4, 8, 10]]) == [True, True, True]\n"}, "metadata": {"canonical_parameter_names": ["s", "queries"], "leetcode_dataset_entry_point": "Solution().canMakePalindromeQueries", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector canMakePalindromeQueries(string s, vector>& queries) {", "container": "Solution", "callable": "canMakePalindromeQueries", "parameters": [{"name": "s", "type": "string"}, {"name": "queries", "type": "vector>&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2996, "task_id": "smallest-missing-integer-greater-than-sequential-prefix-sum", "difficulty": "Easy", "problem_description": "You are given a 0-indexed array of integers nums.\nA prefix nums[0..i] is sequential if, for all 1 <= j <= i, nums[j] = nums[j - 1] + 1. In particular, the prefix consisting only of nums[0] is sequential.\nReturn the smallest integer x missing from nums such that x is greater than or equal to the sum of the longest sequential prefix.\n \nExample 1:\n\nInput: nums = [1,2,3,2,5]\nOutput: 6\nExplanation: The longest sequential prefix of nums is [1,2,3] with a sum of 6. 6 is not in the array, therefore 6 is the smallest missing integer greater than or equal to the sum of the longest sequential prefix.\n\nExample 2:\n\nInput: nums = [3,4,5,1,12,14,13]\nOutput: 15\nExplanation: The longest sequential prefix of nums is [3,4,5] with a sum of 12. 12, 13, and 14 belong to the array while 15 does not. Therefore 15 is the smallest missing integer greater than or equal to the sum of the longest sequential prefix.\n\n \nConstraints:\n\n1 <= nums.length <= 50\n1 <= nums[i] <= 50\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 3, 2, 4, 5]) == 6\n assert candidate(nums = [10, 11, 12, 8, 9, 13]) == 33\n assert candidate(nums = [10, 11, 12, 13, 14]) == 60\n assert candidate(nums = [1, 3, 5, 7, 9]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [50, 49, 48, 47, 46]) == 51\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 95\n assert candidate(nums = [2, 3, 4, 5, 6]) == 20\n assert candidate(nums = [1, 2, 4, 3, 5]) == 6\n assert candidate(nums = [5, 6, 7, 8, 9]) == 35\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 110\n assert candidate(nums = [1, 2, 3, 4, 5]) == 15\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 54\n assert candidate(nums = [1, 2, 3, 2, 5]) == 6\n assert candidate(nums = [1, 1, 1, 1, 1]) == 2\n assert candidate(nums = [3, 4, 5, 1, 12, 14, 13]) == 15\n assert candidate(nums = [1, 2, 2, 3, 4]) == 5\n assert candidate(nums = [1, 2, 3, 5, 6]) == 7\n assert candidate(nums = [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 204\n assert candidate(nums = [1, 2, 4, 5, 6]) == 3\n assert candidate(nums = [7, 8, 9, 10, 12, 13, 14, 15, 16, 17]) == 34\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 1265\n assert candidate(nums = [5, 6, 7, 8, 10, 11, 12]) == 26\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 54\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 26\n assert candidate(nums = [1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 50]) == 1275\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 51\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 1]) == 1274\n assert candidate(nums = [3, 5, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 1]) == 31\n assert candidate(nums = [5, 6, 7, 8, 10, 11, 12, 13, 14]) == 26\n assert candidate(nums = [3, 2, 1, 4, 5, 6, 7, 8, 9, 10]) == 11\n assert candidate(nums = [10, 11, 12, 13, 10, 9, 8]) == 46\n assert candidate(nums = [1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 3\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 51\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 104\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 50]) == 1176\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 465\n assert candidate(nums = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]) == 609\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15]) == 65\n assert candidate(nums = [1, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 2\n assert candidate(nums = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 21\n assert candidate(nums = [1, 2, 4, 5, 6, 3, 7, 8, 9, 10]) == 11\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4]) == 45\n assert candidate(nums = [10, 11, 12, 13, 15, 14, 16, 17, 18, 19]) == 46\n assert candidate(nums = [2, 3, 5, 4, 6, 7, 8, 9, 10, 11]) == 12\n assert candidate(nums = [25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 975\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == 2\n assert candidate(nums = [1, 2, 3, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 6\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 315\n assert candidate(nums = [25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]) == 925\n assert candidate(nums = [10, 11, 12, 13, 15, 16, 17, 18, 19, 20]) == 46\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 3, 2, 1]) == 45\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 54\n assert candidate(nums = [1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12]) == 13\n assert candidate(nums = [2, 3, 4, 1, 5, 6, 7, 8, 9, 10]) == 11\n assert candidate(nums = [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1]) == 114\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) == 14\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15]) == 31\n assert candidate(nums = [10, 11, 12, 13, 14, 20, 21, 22, 23]) == 60\n assert candidate(nums = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == 4\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 6\n assert candidate(nums = [3, 5, 4, 6, 7, 8, 9, 10, 11, 12]) == 13\n assert candidate(nums = [1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 2\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 11\n assert candidate(nums = [1, 2, 4, 5, 7, 8, 10, 11, 13, 14]) == 3\n assert candidate(nums = [10, 11, 12, 13, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 46\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 11, 12, 13]) == 54\n assert candidate(nums = [10, 11, 12, 13, 7, 8, 9]) == 46\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == 6\n assert candidate(nums = [5, 6, 7, 8, 9, 3, 2, 1]) == 35\n assert candidate(nums = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 775\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 3, 4, 2, 1]) == 45\n assert candidate(nums = [3, 4, 5, 6, 7, 8, 9, 10, 1, 2]) == 52\n assert candidate(nums = [2, 3, 4, 5, 10, 9, 8, 7, 6, 5, 4, 3, 2]) == 14\n assert candidate(nums = [1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 3\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10]) == 11\n assert candidate(nums = [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1, 2]) == 85\n assert candidate(nums = [49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 50\n assert candidate(nums = [5, 6, 7, 8, 10, 11, 12, 13, 14, 15]) == 26\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(nums = [20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 275\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 1, 2, 3, 4]) == 1265\n assert candidate(nums = [30, 31, 32, 33, 30, 31, 32, 33]) == 126\n assert candidate(nums = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 115\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 54\n assert candidate(nums = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 165\n assert candidate(nums = [3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 4\n assert candidate(nums = [40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39]) == 495\n assert candidate(nums = [40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 1, 2, 3]) == 495\n assert candidate(nums = [49, 50, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28]) == 99\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 325\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 55\n assert candidate(nums = [25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]) == 330\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]) == 425\n assert candidate(nums = [5, 6, 7, 8, 3, 4, 2, 1]) == 26\n assert candidate(nums = [45, 46, 47, 48, 49, 50, 1, 2, 3]) == 285\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 55\n assert candidate(nums = [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 319\n assert candidate(nums = [45, 46, 47, 48, 49, 50, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 285\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 209\n assert candidate(nums = [49, 50, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 99\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 16\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 1275\n assert candidate(nums = [30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 840\n assert candidate(nums = [20, 21, 22, 23, 24, 15, 16, 17, 18, 19]) == 110\n assert candidate(nums = [3, 5, 4, 6, 7, 8, 9, 10, 11, 12, 13]) == 14\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 21\n assert candidate(nums = [5, 6, 7, 8, 9, 3, 4, 2, 1]) == 35\n assert candidate(nums = [30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 1, 2, 3, 4, 5]) == 840\n assert candidate(nums = [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 1, 2, 3]) == 1269\n assert candidate(nums = [10, 11, 12, 15, 16, 17, 18]) == 33\n assert candidate(nums = [25, 26, 27, 28, 29, 30, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]) == 165\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 465\n assert candidate(nums = [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 360\n assert candidate(nums = [30, 31, 28, 29, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 61\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 50]) == 435\n assert candidate(nums = [15, 16, 17, 18, 19, 20, 1, 2, 3, 4]) == 105\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 51]) == 1225\n assert candidate(nums = [2, 3, 1, 4, 5, 6, 7, 8, 9, 10]) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 10, 11, 12, 13, 14, 15, 16]) == 17\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().missingInteger", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int missingInteger(vector& nums) {", "container": "Solution", "callable": "missingInteger", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2997, "task_id": "minimum-number-of-operations-to-make-array-xor-equal-to-k", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums and a positive integer k.\nYou can apply the following operation on the array any number of times:\n\nChoose any element of the array and flip a bit in its binary representation. Flipping a bit means changing a 0 to 1 or vice versa.\n\nReturn the minimum number of operations required to make the bitwise XOR of all elements of the final array equal to k.\nNote that you can flip leading zero bits in the binary representation of elements. For example, for the number (101)2 you can flip the fourth bit and obtain (1101)2.\n \nExample 1:\n\nInput: nums = [2,1,3,4], k = 1\nOutput: 2\nExplanation: We can do the following operations:\n- Choose element 2 which is 3 == (011)2, we flip the first bit and we obtain (010)2 == 2. nums becomes [2,1,2,4].\n- Choose element 0 which is 2 == (010)2, we flip the third bit and we obtain (110)2 = 6. nums becomes [6,1,2,4].\nThe XOR of elements of the final array is (6 XOR 1 XOR 2 XOR 4) == 1 == k.\nIt can be shown that we cannot make the XOR equal to k in less than 2 operations.\n\nExample 2:\n\nInput: nums = [2,0,2,0], k = 0\nOutput: 0\nExplanation: The XOR of elements of the array is (2 XOR 0 XOR 2 XOR 0) == 0 == k. So no operation is needed.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n0 <= nums[i] <= 106\n0 <= k <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [0, 0, 0, 0],k = 2) == 1\n assert candidate(nums = [1, 1, 1, 1],k = 0) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1],k = 63) == 6\n assert candidate(nums = [1, 2, 3, 4, 5],k = 3) == 1\n assert candidate(nums = [1, 2, 3, 4, 5],k = 5) == 1\n assert candidate(nums = [2, 1, 3, 4],k = 1) == 2\n assert candidate(nums = [1000000, 500000, 250000],k = 125000) == 12\n assert candidate(nums = [1, 1, 1, 1],k = 1) == 1\n assert candidate(nums = [1, 3, 5, 7, 9],k = 15) == 2\n assert candidate(nums = [3, 3, 3, 3],k = 3) == 2\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64],k = 127) == 0\n assert candidate(nums = [1000000],k = 1000000) == 0\n assert candidate(nums = [0, 0, 0, 0],k = 1) == 1\n assert candidate(nums = [0, 0, 0, 0],k = 15) == 4\n assert candidate(nums = [1, 2, 3, 4, 5],k = 7) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 1\n assert candidate(nums = [2, 0, 2, 0],k = 0) == 0\n assert candidate(nums = [1000000, 500000, 250000],k = 1250000) == 5\n assert candidate(nums = [0, 0, 0, 0],k = 0) == 0\n assert candidate(nums = [1234567, 7654321, 9876543, 3214567, 6543219],k = 1357924) == 15\n assert candidate(nums = [15, 27, 33, 45],k = 58) == 2\n assert candidate(nums = [999999, 888888, 777777, 666666, 555555, 444444, 333333, 222222, 111111, 100000],k = 999998) == 8\n assert candidate(nums = [7, 14, 28, 56, 112, 224],k = 112) == 5\n assert candidate(nums = [8388607, 16777215, 33554431, 67108863, 134217727],k = 268435455) == 3\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],k = 1022) == 4\n assert candidate(nums = [17, 34, 51, 68, 85],k = 255) == 6\n assert candidate(nums = [123456, 789012, 345678, 901234],k = 67890) == 10\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000],k = 1000001) == 8\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],k = 1023) == 5\n assert candidate(nums = [7, 13, 15, 21],k = 10) == 3\n assert candidate(nums = [8388607, 4194303, 2097151, 1048575, 524287, 262143, 131071, 65535, 32767, 16383],k = 1073741823) == 25\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],k = 1023) == 0\n assert candidate(nums = [15, 7, 3, 1],k = 14) == 1\n assert candidate(nums = [524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],k = 1048574) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 1\n assert candidate(nums = [1023, 2047, 4095, 8191],k = 16383) == 12\n assert candidate(nums = [1048575, 524287, 262143, 131071, 65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63],k = 2097151) == 8\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],k = 2047) == 0\n assert candidate(nums = [1, 3, 5, 7, 9],k = 15) == 2\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8],k = 8) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 1\n assert candidate(nums = [1023, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],k = 2047) == 11\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 1\n assert candidate(nums = [1234567, 7654321, 111222333, 333222111, 444555666],k = 987654321) == 20\n assert candidate(nums = [255, 128, 64, 32, 16, 8, 4, 2, 1],k = 0) == 0\n assert candidate(nums = [123456, 654321, 111111, 222222, 333333, 444444],k = 555555) == 9\n assert candidate(nums = [3, 5, 6, 12],k = 7) == 3\n assert candidate(nums = [1234567, 2345678, 3456789, 4567890, 5678901, 6789012, 7890123, 8901234, 9012345, 1012345],k = 5000000) == 10\n assert candidate(nums = [999999, 888888, 777777, 666666, 555555, 444444, 333333, 222222, 111111, 100000],k = 555555) == 12\n assert candidate(nums = [13, 7, 15, 8, 2],k = 31) == 1\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],k = 0) == 5\n assert candidate(nums = [987654, 321098, 654321, 123456, 789012],k = 1234567) == 12\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 28) == 2\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109],k = 112) == 4\n assert candidate(nums = [8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192],k = 16383) == 3\n assert candidate(nums = [255, 128, 64, 32, 16, 8, 4, 2, 1],k = 255) == 8\n assert candidate(nums = [4294967295, 2147483647, 1073741823, 536870911, 268435455, 134217727, 67108863, 33554431, 16777215, 8388607, 4194303, 2097151, 1048575, 524287, 262143, 131071, 65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],k = 4294967295) == 16\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 8) == 1\n assert candidate(nums = [999999, 888888, 777777, 666666, 555555, 444444, 333333, 222222, 111111],k = 6666666) == 16\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 0\n assert candidate(nums = [999999, 888888, 777777, 666666, 555555, 444444, 333333, 222222, 111111, 101010],k = 123456789) == 12\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991],k = 10) == 6\n assert candidate(nums = [987654, 876543, 765432, 654321, 543210, 432109, 321098, 210987, 109876, 98765],k = 1000000) == 12\n assert candidate(nums = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953],k = 1000000) == 8\n assert candidate(nums = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953, 976, 488, 244, 122, 61, 30, 15, 7, 3, 1],k = 1048575) == 6\n assert candidate(nums = [123, 456, 789, 101112, 131415, 161718, 192021, 222324, 252627, 282930],k = 123456) == 13\n assert candidate(nums = [1000000, 500000, 250000, 125000],k = 1048575) == 8\n assert candidate(nums = [63, 31, 15, 7, 3, 1],k = 64) == 4\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 990) == 7\n assert candidate(nums = [255, 128, 64, 32, 16, 8, 4, 2, 1],k = 254) == 7\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],k = 2047) == 6\n assert candidate(nums = [4294967295, 0, 1, 2, 3, 4, 5, 6, 7, 8],k = 4294967295) == 1\n assert candidate(nums = [15, 15, 15, 15],k = 15) == 4\n assert candidate(nums = [8388607, 4194303, 2097151, 1048575, 524287, 262143, 131071, 65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],k = 8388607) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 31) == 5\n assert candidate(nums = [2147483647, 1073741823, 536870911, 268435455, 134217727, 67108863, 33554431, 16777215, 8388607, 4194303],k = 8589934591) == 28\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576],k = 1048575) == 1\n assert candidate(nums = [1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],k = 1048575) == 1\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 2048) == 12\n assert candidate(nums = [255, 128, 64, 32, 16, 8, 4, 2, 1],k = 256) == 1\n assert candidate(nums = [987654321, 123456789, 192837465, 567890123, 246813579],k = 1234567890) == 13\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996],k = 1000000) == 0\n assert candidate(nums = [1048575, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],k = 2097151) == 21\n assert candidate(nums = [3, 5, 7, 9, 11],k = 15) == 2\n assert candidate(nums = [255, 127, 63, 31, 15, 7, 3, 1],k = 254) == 3\n assert candidate(nums = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953],k = 2048) == 10\n assert candidate(nums = [4, 6, 8, 10, 12, 14, 16, 18, 20],k = 14) == 3\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],k = 1023) == 1\n assert candidate(nums = [999999, 888888, 777777, 666666, 555555, 444444, 333333, 222222, 111111],k = 123456) == 13\n assert candidate(nums = [64, 32, 16, 8, 4, 2, 1],k = 127) == 0\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],k = 2047) == 0\n assert candidate(nums = [268435455, 134217727, 67108863, 33554431, 16777215, 8388607, 4194303, 2097151, 1048575, 524287, 262143, 131071, 65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],k = 536870911) == 15\n assert candidate(nums = [16777215, 8388607, 4194303, 2097151, 1048575, 524287, 262143, 131071, 65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],k = 16777214) == 11\n assert candidate(nums = [1, 3, 7, 15, 31],k = 63) == 3\n assert candidate(nums = [65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],k = 65534) == 7\n assert candidate(nums = [3, 5, 7, 9],k = 15) == 3\n assert candidate(nums = [5, 3, 15, 8],k = 10) == 3\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15],k = 0) == 0\n assert candidate(nums = [15, 31, 63, 127, 255],k = 255) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],k = 31) == 5\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],k = 1024) == 6\n assert candidate(nums = [8, 4, 2, 1, 8, 4, 2, 1, 8, 4, 2, 1, 8, 4, 2, 1],k = 15) == 4\n assert candidate(nums = [1000000, 500000, 250000, 125000, 62500, 31250],k = 2187500) == 11\n assert candidate(nums = [8388607, 4194304, 2097152, 1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],k = 16777215) == 24\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],k = 23) == 0\n assert candidate(nums = [255, 255, 255, 255, 255, 255, 255, 255, 255, 255],k = 0) == 0\n assert candidate(nums = [500, 501, 502, 503, 504, 505, 506, 507, 508, 509],k = 512) == 2\n assert candidate(nums = [100000, 200000, 300000, 400000, 500000],k = 1000000) == 8\n assert candidate(nums = [1048575, 524287, 262143, 131071, 65535, 32767, 16383, 8191, 4095, 2047],k = 1023) == 15\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1023) == 10\n assert candidate(nums = [123456, 654321, 789012, 345678, 901234, 234567, 876543, 456789, 543210, 123456],k = 999999) == 10\n assert candidate(nums = [255, 128, 64, 32, 16, 8, 4, 2, 1],k = 1023) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 4095) == 12\n assert candidate(nums = [7, 7, 7, 7, 7],k = 7) == 0\n assert candidate(nums = [135792468, 246813579, 357924681, 468135792, 579246813, 681357924, 792468135, 813579246, 924681357, 1035792468],k = 999999999) == 16\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minOperations(vector& nums, int k) {", "container": "Solution", "callable": "minOperations", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2998, "task_id": "minimum-number-of-operations-to-make-x-and-y-equal", "difficulty": "Medium", "problem_description": "You are given two positive integers x and y.\nIn one operation, you can do one of the four following operations:\n\nDivide x by 11 if x is a multiple of 11.\nDivide x by 5 if x is a multiple of 5.\nDecrement x by 1.\nIncrement x by 1.\n\nReturn the minimum number of operations required to make x and y equal.\n \nExample 1:\n\nInput: x = 26, y = 1\nOutput: 3\nExplanation: We can make 26 equal to 1 by applying the following operations: \n1. Decrement x by 1\n2. Divide x by 5\n3. Divide x by 5\nIt can be shown that 3 is the minimum number of operations required to make 26 equal to 1.\n\nExample 2:\n\nInput: x = 54, y = 2\nOutput: 4\nExplanation: We can make 54 equal to 2 by applying the following operations: \n1. Increment x by 1\n2. Divide x by 11 \n3. Divide x by 5\n4. Increment x by 1\nIt can be shown that 4 is the minimum number of operations required to make 54 equal to 2.\n\nExample 3:\n\nInput: x = 25, y = 30\nOutput: 5\nExplanation: We can make 25 equal to 30 by applying the following operations: \n1. Increment x by 1\n2. Increment x by 1\n3. Increment x by 1\n4. Increment x by 1\n5. Increment x by 1\nIt can be shown that 5 is the minimum number of operations required to make 25 equal to 30.\n\n \nConstraints:\n\n1 <= x, y <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(x = 1,y = 10000) == 9999\n assert candidate(x = 11,y = 5) == 5\n assert candidate(x = 10000,y = 1) == 8\n assert candidate(x = 111,y = 11) == 3\n assert candidate(x = 77,y = 7) == 1\n assert candidate(x = 500,y = 20) == 2\n assert candidate(x = 25,y = 30) == 5\n assert candidate(x = 11,y = 1) == 1\n assert candidate(x = 55,y = 11) == 1\n assert candidate(x = 2,y = 20) == 18\n assert candidate(x = 1234,y = 4321) == 3087\n assert candidate(x = 100,y = 1) == 4\n assert candidate(x = 26,y = 1) == 3\n assert candidate(x = 54,y = 2) == 4\n assert candidate(x = 99,y = 9) == 1\n assert candidate(x = 9999,y = 9999) == 0\n assert candidate(x = 55,y = 10) == 2\n assert candidate(x = 10,y = 10) == 0\n assert candidate(x = 55,y = 5) == 1\n assert candidate(x = 100,y = 10) == 3\n assert candidate(x = 5,y = 1) == 1\n assert candidate(x = 15,y = 6) == 4\n assert candidate(x = 1,y = 100) == 99\n assert candidate(x = 1111,y = 5555) == 4444\n assert candidate(x = 6666,y = 3333) == 2002\n assert candidate(x = 9876,y = 5432) == 3459\n assert candidate(x = 8888,y = 111) == 45\n assert candidate(x = 3000,y = 2500) == 500\n assert candidate(x = 1111,y = 100) == 2\n assert candidate(x = 7777,y = 6666) == 1111\n assert candidate(x = 100,y = 2500) == 2400\n assert candidate(x = 5555,y = 22) == 6\n assert candidate(x = 1234,y = 8765) == 7531\n assert candidate(x = 7000,y = 3500) == 2101\n assert candidate(x = 9876,y = 1234) == 339\n assert candidate(x = 55,y = 15) == 5\n assert candidate(x = 3333,y = 6666) == 3333\n assert candidate(x = 3333,y = 33) == 12\n assert candidate(x = 1010,y = 10) == 7\n assert candidate(x = 550,y = 10) == 2\n assert candidate(x = 100,y = 10000) == 9900\n assert candidate(x = 6666,y = 66) == 14\n assert candidate(x = 5000,y = 5005) == 5\n assert candidate(x = 5000,y = 50) == 13\n assert candidate(x = 441,y = 121) == 35\n assert candidate(x = 5000,y = 2500) == 1501\n assert candidate(x = 330,y = 3) == 5\n assert candidate(x = 9999,y = 10000) == 1\n assert candidate(x = 5000,y = 6000) == 1000\n assert candidate(x = 9999,y = 1000) == 92\n assert candidate(x = 500,y = 1000) == 500\n assert candidate(x = 2222,y = 2222) == 0\n assert candidate(x = 9000,y = 9009) == 9\n assert candidate(x = 1000,y = 345) == 146\n assert candidate(x = 4444,y = 4445) == 1\n assert candidate(x = 220,y = 385) == 165\n assert candidate(x = 300,y = 105) == 46\n assert candidate(x = 9999,y = 1) == 9\n assert candidate(x = 1234,y = 654) == 409\n assert candidate(x = 5000,y = 5) == 7\n assert candidate(x = 55,y = 77) == 22\n assert candidate(x = 4999,y = 5001) == 2\n assert candidate(x = 1000,y = 10000) == 9000\n assert candidate(x = 3000,y = 2990) == 10\n assert candidate(x = 300,y = 150) == 91\n assert candidate(x = 220,y = 20) == 1\n assert candidate(x = 4567,y = 890) == 26\n assert candidate(x = 1111,y = 1000) == 111\n assert candidate(x = 1000,y = 995) == 5\n assert candidate(x = 4444,y = 44) == 12\n assert candidate(x = 123,y = 321) == 198\n assert candidate(x = 1000,y = 999) == 1\n assert candidate(x = 6000,y = 1000) == 201\n assert candidate(x = 880,y = 15) == 3\n assert candidate(x = 880,y = 55) == 23\n assert candidate(x = 1100,y = 50) == 8\n assert candidate(x = 1331,y = 110) == 12\n assert candidate(x = 1000,y = 990) == 10\n assert candidate(x = 7777,y = 2222) == 670\n assert candidate(x = 1100,y = 10) == 4\n assert candidate(x = 4000,y = 2000) == 1201\n assert candidate(x = 9876,y = 4321) == 2348\n assert candidate(x = 9876,y = 4567) == 2594\n assert candidate(x = 1234,y = 5678) == 4444\n assert candidate(x = 495,y = 660) == 165\n assert candidate(x = 6110,y = 55) == 12\n assert candidate(x = 1111,y = 222) == 2\n assert candidate(x = 45,y = 33) == 12\n assert candidate(x = 9876,y = 11) == 11\n assert candidate(x = 5500,y = 220) == 2\n assert candidate(x = 1024,y = 128) == 37\n assert candidate(x = 24,y = 29) == 5\n assert candidate(x = 8000,y = 8008) == 8\n assert candidate(x = 88,y = 22) == 7\n assert candidate(x = 495,y = 4) == 3\n assert candidate(x = 7000,y = 7000) == 0\n assert candidate(x = 825,y = 17) == 4\n assert candidate(x = 5555,y = 5) == 6\n assert candidate(x = 1234,y = 88) == 27\n assert candidate(x = 1024,y = 512) == 309\n assert candidate(x = 9999,y = 8888) == 1111\n assert candidate(x = 8000,y = 2000) == 401\n assert candidate(x = 5432,y = 6789) == 1357\n assert candidate(x = 111,y = 55) == 35\n assert candidate(x = 7500,y = 7400) == 100\n assert candidate(x = 242,y = 11) == 7\n assert candidate(x = 121,y = 1) == 2\n assert candidate(x = 6105,y = 1221) == 1\n assert candidate(x = 3333,y = 999) == 335\n assert candidate(x = 2020,y = 202) == 23\n assert candidate(x = 121,y = 110) == 11\n assert candidate(x = 4321,y = 9876) == 5555\n assert candidate(x = 4444,y = 8888) == 4444\n assert candidate(x = 2222,y = 222) == 21\n assert candidate(x = 1234,y = 890) == 344\n assert candidate(x = 7,y = 143) == 136\n assert candidate(x = 7777,y = 77) == 18\n assert candidate(x = 5555,y = 1111) == 1\n assert candidate(x = 8888,y = 7777) == 1111\n assert candidate(x = 9876,y = 123) == 48\n assert candidate(x = 2000,y = 10000) == 8000\n assert candidate(x = 8000,y = 8010) == 10\n assert candidate(x = 88,y = 13) == 6\n assert candidate(x = 7777,y = 1111) == 405\n assert candidate(x = 3333,y = 4444) == 1111\n assert candidate(x = 6000,y = 6005) == 5\n assert candidate(x = 9999,y = 9990) == 9\n assert candidate(x = 2222,y = 7777) == 5555\n assert candidate(x = 77,y = 22) == 10\n assert candidate(x = 2000,y = 10) == 9\n assert candidate(x = 1111,y = 9999) == 8888\n assert candidate(x = 1234,y = 987) == 247\n assert candidate(x = 8888,y = 1111) == 304\n"}, "metadata": {"canonical_parameter_names": ["x", "y"], "leetcode_dataset_entry_point": "Solution().minimumOperationsToMakeEqual", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumOperationsToMakeEqual(int x, int y) {", "container": "Solution", "callable": "minimumOperationsToMakeEqual", "parameters": [{"name": "x", "type": "int"}, {"name": "y", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 2999, "task_id": "count-the-number-of-powerful-integers", "difficulty": "Hard", "problem_description": "You are given three integers start, finish, and limit. You are also given a 0-indexed string s representing a positive integer.\nA positive integer x is called powerful if it ends with s (in other words, s is a suffix of x) and each digit in x is at most limit.\nReturn the total number of powerful integers in the range [start..finish].\nA string x is a suffix of a string y if and only if x is a substring of y that starts from some index (including 0) in y and extends to the index y.length - 1. For example, 25 is a suffix of 5125 whereas 512 is not.\n \nExample 1:\n\nInput: start = 1, finish = 6000, limit = 4, s = \"124\"\nOutput: 5\nExplanation: The powerful integers in the range [1..6000] are 124, 1124, 2124, 3124, and, 4124. All these integers have each digit <= 4, and \"124\" as a suffix. Note that 5124 is not a powerful integer because the first digit is 5 which is greater than 4.\nIt can be shown that there are only 5 powerful integers in this range.\n\nExample 2:\n\nInput: start = 15, finish = 215, limit = 6, s = \"10\"\nOutput: 2\nExplanation: The powerful integers in the range [15..215] are 110 and 210. All these integers have each digit <= 6, and \"10\" as a suffix.\nIt can be shown that there are only 2 powerful integers in this range.\n\nExample 3:\n\nInput: start = 1000, finish = 2000, limit = 4, s = \"3000\"\nOutput: 0\nExplanation: All integers in the range [1000..2000] are smaller than 3000, hence \"3000\" cannot be a suffix of any integer in this range.\n\n \nConstraints:\n\n1 <= start <= finish <= 1015\n1 <= limit <= 9\n1 <= s.length <= floor(log10(finish)) + 1\ns only consists of numeric digits which are at most limit.\ns does not have leading zeros.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(start = 100,finish = 1000,limit = 1,s = \"00\") == 2\n assert candidate(start = 1111,finish = 2222,limit = 2,s = \"11\") == 5\n assert candidate(start = 500,finish = 5000,limit = 7,s = \"50\") == 35\n assert candidate(start = 10000,finish = 99999,limit = 8,s = \"8888\") == 8\n assert candidate(start = 1,finish = 6000,limit = 4,s = \"124\") == 5\n assert candidate(start = 111,finish = 999,limit = 9,s = \"11\") == 9\n assert candidate(start = 1234,finish = 98765,limit = 8,s = \"4321\") == 9\n assert candidate(start = 100,finish = 1000,limit = 5,s = \"00\") == 6\n assert candidate(start = 1234,finish = 98765,limit = 9,s = \"567\") == 98\n assert candidate(start = 5,finish = 55,limit = 5,s = \"5\") == 6\n assert candidate(start = 1,finish = 1000000000000000,limit = 9,s = \"999\") == 1000000000000\n assert candidate(start = 500,finish = 1500,limit = 5,s = \"50\") == 6\n assert candidate(start = 1,finish = 999999999999999,limit = 9,s = \"999\") == 1000000000000\n assert candidate(start = 5,finish = 500,limit = 3,s = \"1\") == 15\n assert candidate(start = 100,finish = 1000,limit = 7,s = \"00\") == 8\n assert candidate(start = 15,finish = 215,limit = 6,s = \"10\") == 2\n assert candidate(start = 123,finish = 456,limit = 5,s = \"34\") == 4\n assert candidate(start = 1000,finish = 2000,limit = 4,s = \"3000\") == 0\n assert candidate(start = 5,finish = 5,limit = 5,s = \"5\") == 1\n assert candidate(start = 1,finish = 10,limit = 1,s = \"1\") == 1\n assert candidate(start = 200,finish = 800,limit = 2,s = \"2\") == 3\n assert candidate(start = 1234,finish = 4321,limit = 7,s = \"34\") == 25\n assert candidate(start = 10,finish = 100,limit = 1,s = \"0\") == 2\n assert candidate(start = 1234,finish = 123456,limit = 7,s = \"34\") == 659\n assert candidate(start = 1,finish = 1000000000000000,limit = 1,s = \"1\") == 16384\n assert candidate(start = 10,finish = 100,limit = 3,s = \"0\") == 4\n assert candidate(start = 10,finish = 100,limit = 3,s = \"1\") == 3\n assert candidate(start = 100,finish = 200,limit = 2,s = \"00\") == 2\n assert candidate(start = 10000,finish = 100000,limit = 1,s = \"0000\") == 2\n assert candidate(start = 999,finish = 9999,limit = 9,s = \"999\") == 10\n assert candidate(start = 10,finish = 100,limit = 3,s = \"2\") == 3\n assert candidate(start = 500,finish = 5000,limit = 5,s = \"50\") == 25\n assert candidate(start = 1000000000000000,finish = 2000000000000000,limit = 5,s = \"54321\") == 60466176\n assert candidate(start = 123456789,finish = 987654321,limit = 8,s = \"123\") == 456707\n assert candidate(start = 1000000000000,finish = 10000000000000,limit = 6,s = \"6666\") == 34588806\n assert candidate(start = 1000000000,finish = 1000000000,limit = 9,s = \"0\") == 1\n assert candidate(start = 123,finish = 321,limit = 1,s = \"1\") == 0\n assert candidate(start = 1,finish = 1000000000000000,limit = 7,s = \"777777777777777\") == 1\n assert candidate(start = 10000000000,finish = 99999999999,limit = 4,s = \"44444\") == 12500\n assert candidate(start = 500000000,finish = 5000000000,limit = 4,s = \"444444\") == 500\n assert candidate(start = 1234567890,finish = 2345678901,limit = 7,s = \"789\") == 299592\n assert candidate(start = 555555555555555,finish = 666666666666666,limit = 5,s = \"555\") == 1\n assert candidate(start = 1000000000,finish = 9000000000,limit = 4,s = \"4444\") == 12500\n assert candidate(start = 1111111111,finish = 2222222222,limit = 2,s = \"222\") == 1094\n assert candidate(start = 123456789,finish = 987654321,limit = 8,s = \"876\") == 456708\n assert candidate(start = 123456789,finish = 9876543210,limit = 8,s = \"8765\") == 523138\n assert candidate(start = 111111111111111,finish = 222222222222222,limit = 2,s = \"2222222222\") == 122\n assert candidate(start = 100000000000000,finish = 200000000000000,limit = 6,s = \"666666\") == 5764801\n assert candidate(start = 5000,finish = 50000,limit = 5,s = \"25\") == 150\n assert candidate(start = 1000000000,finish = 2000000000,limit = 9,s = \"999999\") == 1000\n assert candidate(start = 123456789,finish = 123456789,limit = 9,s = \"999\") == 0\n assert candidate(start = 1234567890123456789,finish = 9876543210987654321,limit = 8,s = \"890\") == 1592439230847996\n assert candidate(start = 123456789,finish = 987654321,limit = 4,s = \"789\") == 10750\n assert candidate(start = 1000000000,finish = 2000000000,limit = 6,s = \"12345\") == 2401\n assert candidate(start = 123456789,finish = 9876543210,limit = 4,s = \"4321\") == 14650\n assert candidate(start = 123,finish = 456789,limit = 6,s = \"678\") == 238\n assert candidate(start = 500000000,finish = 600000000,limit = 4,s = \"40000\") == 0\n assert candidate(start = 1000000000000000,finish = 2000000000000000,limit = 5,s = \"555555555555555\") == 1\n assert candidate(start = 1000000000,finish = 1500000000,limit = 3,s = \"321\") == 4096\n assert candidate(start = 100000000,finish = 200000000,limit = 9,s = \"90000000\") == 1\n assert candidate(start = 10000,finish = 999999999,limit = 5,s = \"5555\") == 7775\n assert candidate(start = 1000000000,finish = 10000000000,limit = 6,s = \"6000000\") == 294\n assert candidate(start = 123456789,finish = 987654321,limit = 8,s = \"456\") == 456707\n assert candidate(start = 100000,finish = 9999999999,limit = 5,s = \"2500\") == 46650\n assert candidate(start = 100,finish = 999,limit = 1,s = \"1\") == 2\n assert candidate(start = 1000000000,finish = 2000000000,limit = 3,s = \"123\") == 4096\n assert candidate(start = 1000000000,finish = 9999999999,limit = 5,s = \"4444\") == 38880\n assert candidate(start = 1,finish = 1000000000000,limit = 1,s = \"1\") == 2048\n assert candidate(start = 1,finish = 10000000000,limit = 2,s = \"12\") == 6561\n assert candidate(start = 99999999,finish = 1000000000,limit = 9,s = \"999\") == 900001\n assert candidate(start = 1000000,finish = 10000000,limit = 3,s = \"333\") == 192\n assert candidate(start = 1000000000000,finish = 9999999999999,limit = 8,s = \"8888\") == 344373768\n assert candidate(start = 100000,finish = 999999,limit = 5,s = \"2500\") == 30\n assert candidate(start = 10000,finish = 15000,limit = 3,s = \"3000\") == 1\n assert candidate(start = 500000000,finish = 800000000,limit = 6,s = \"567\") == 33614\n assert candidate(start = 111111111,finish = 222222222,limit = 2,s = \"222\") == 365\n assert candidate(start = 100000,finish = 999999,limit = 4,s = \"4444\") == 20\n assert candidate(start = 123456789012345,finish = 987654321098765,limit = 7,s = \"789\") == 57499975680\n assert candidate(start = 1111,finish = 2222,limit = 1,s = \"11\") == 1\n assert candidate(start = 100000000000,finish = 900000000000,limit = 3,s = \"333\") == 196608\n assert candidate(start = 111111111111111,finish = 222222222222222,limit = 2,s = \"21\") == 797162\n assert candidate(start = 100000000000000,finish = 200000000000000,limit = 1,s = \"1\") == 8192\n assert candidate(start = 500000000000000,finish = 600000000000000,limit = 5,s = \"500\") == 362797056\n assert candidate(start = 10000000000000,finish = 50000000000000,limit = 4,s = \"4444444\") == 62500\n assert candidate(start = 5000000,finish = 5500000,limit = 5,s = \"5000\") == 30\n assert candidate(start = 987654321,finish = 987654321987654321,limit = 9,s = \"987654321\") == 987654322\n assert candidate(start = 1000000000000000,finish = 9999999999999999,limit = 5,s = \"55555\") == 302330880\n assert candidate(start = 123456789012345,finish = 234567890123456,limit = 2,s = \"222\") == 177147\n assert candidate(start = 100000000000000,finish = 200000000000000,limit = 7,s = \"7654321\") == 2097152\n assert candidate(start = 987654321098765,finish = 9876543210987654,limit = 9,s = \"987654321\") == 8888889\n assert candidate(start = 123123123,finish = 987987987,limit = 8,s = \"876\") == 456981\n assert candidate(start = 222222222222222,finish = 333333333333333,limit = 3,s = \"3333333333\") == 342\n assert candidate(start = 1234567890,finish = 1234567890123456789,limit = 6,s = \"67890\") == 131875584409\n assert candidate(start = 1000000000,finish = 9000000000,limit = 6,s = \"666\") == 705894\n assert candidate(start = 100000000000000,finish = 300000000000000,limit = 5,s = \"55555555555555\") == 2\n assert candidate(start = 10000,finish = 99999,limit = 2,s = \"22\") == 18\n assert candidate(start = 1000000000,finish = 10000000000,limit = 1,s = \"1\") == 256\n assert candidate(start = 10000,finish = 20000,limit = 3,s = \"111\") == 4\n assert candidate(start = 1000000000000,finish = 1000000000000,limit = 9,s = \"999999999999\") == 0\n assert candidate(start = 50000,finish = 150000,limit = 5,s = \"2500\") == 6\n assert candidate(start = 1000000000000000,finish = 1000000000000000,limit = 9,s = \"999999999999999\") == 0\n assert candidate(start = 123456789,finish = 2100000000,limit = 6,s = \"6789\") == 32748\n assert candidate(start = 1000000000000,finish = 9999999999999,limit = 2,s = \"21\") == 118098\n assert candidate(start = 123456789012345,finish = 987654321098765,limit = 7,s = \"765\") == 57499975680\n assert candidate(start = 123456789012345,finish = 987654321098765,limit = 6,s = \"654321\") == 32507139\n assert candidate(start = 100000000000000,finish = 200000000000000,limit = 3,s = \"100\") == 4194304\n assert candidate(start = 50000,finish = 60000,limit = 5,s = \"500\") == 6\n assert candidate(start = 1000000000000000,finish = 1500000000000000,limit = 6,s = \"666666666666666\") == 0\n assert candidate(start = 123456789123,finish = 987654321987,limit = 9,s = \"987\") == 864197533\n assert candidate(start = 123456789012,finish = 987654321012,limit = 5,s = \"5555\") == 1276560\n assert candidate(start = 500,finish = 5000,limit = 3,s = \"300\") == 3\n assert candidate(start = 12345,finish = 67890,limit = 7,s = \"789\") == 46\n assert candidate(start = 5000000000,finish = 5000000000000000,limit = 5,s = \"5000\") == 1813946400\n assert candidate(start = 555555555,finish = 666666666,limit = 9,s = \"555\") == 111112\n assert candidate(start = 1000000,finish = 2000000,limit = 2,s = \"222\") == 27\n assert candidate(start = 9000000000,finish = 9999999999,limit = 9,s = \"9999\") == 100000\n assert candidate(start = 1234567890,finish = 1234567890123,limit = 6,s = \"6789\") == 7823592\n assert candidate(start = 1111,finish = 3333,limit = 1,s = \"11\") == 1\n assert candidate(start = 123456789012345,finish = 987654321098765,limit = 7,s = \"7654321\") == 14038080\n assert candidate(start = 1000000000000000,finish = 9999999999999999,limit = 7,s = \"777777777777777\") == 7\n assert candidate(start = 5000,finish = 15000,limit = 3,s = \"300\") == 4\n assert candidate(start = 1,finish = 1000000000000000,limit = 4,s = \"444444444444444\") == 1\n assert candidate(start = 100000,finish = 500000,limit = 7,s = \"7777\") == 32\n assert candidate(start = 100000000000000,finish = 200000000000000,limit = 8,s = \"8888888888\") == 6561\n assert candidate(start = 5000,finish = 80000,limit = 5,s = \"250\") == 31\n assert candidate(start = 5000000000,finish = 6000000000,limit = 6,s = \"5555\") == 16807\n assert candidate(start = 123456789,finish = 987654321,limit = 6,s = \"666\") == 94773\n assert candidate(start = 1000000,finish = 2000000,limit = 2,s = \"200\") == 27\n assert candidate(start = 987654321098765,finish = 9876543210987654,limit = 9,s = \"9876543210\") == 888889\n assert candidate(start = 500,finish = 2500,limit = 4,s = \"444\") == 2\n assert candidate(start = 100000000000000,finish = 1000000000000000,limit = 4,s = \"43210\") == 7812500\n assert candidate(start = 123456789012345,finish = 123456789012345,limit = 9,s = \"123456789\") == 0\n assert candidate(start = 1000000000000,finish = 4000000000000,limit = 3,s = \"333333333333\") == 3\n assert candidate(start = 5000000,finish = 6000000,limit = 4,s = \"4000\") == 0\n assert candidate(start = 111111111111111,finish = 222222222222222,limit = 1,s = \"1\") == 1\n assert candidate(start = 1234567890,finish = 1234567890000000000,limit = 4,s = \"43210\") == 1904295900\n assert candidate(start = 1000000000000000,finish = 2000000000000000,limit = 9,s = \"999999999999999\") == 1\n assert candidate(start = 100000000,finish = 600000000,limit = 2,s = \"222222222\") == 1\n assert candidate(start = 500000000000,finish = 5000000000000,limit = 7,s = \"777\") == 587202560\n assert candidate(start = 10000000000,finish = 50000000000,limit = 4,s = \"4444444444\") == 4\n assert candidate(start = 10000000000,finish = 11000000000,limit = 3,s = \"3000\") == 1024\n assert candidate(start = 123456789,finish = 987654321,limit = 4,s = \"3456\") == 2150\n assert candidate(start = 1000000000000000,finish = 1000000000000000,limit = 9,s = \"1\") == 0\n assert candidate(start = 111111111111111,finish = 999999999999999,limit = 9,s = \"999999999999999\") == 1\n assert candidate(start = 111111111,finish = 222222222,limit = 2,s = \"123\") == 365\n assert candidate(start = 123456789012345,finish = 987654321098765,limit = 7,s = \"765432\") == 112304640\n assert candidate(start = 222222222222222,finish = 333333333333333,limit = 3,s = \"333\") == 5592406\n"}, "metadata": {"canonical_parameter_names": ["start", "finish", "limit", "s"], "leetcode_dataset_entry_point": "Solution().numberOfPowerfulInt", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "long long numberOfPowerfulInt(long long start, long long finish, int limit, string s) {", "container": "Solution", "callable": "numberOfPowerfulInt", "parameters": [{"name": "start", "type": "long long"}, {"name": "finish", "type": "long long"}, {"name": "limit", "type": "int"}, {"name": "s", "type": "string"}], "return_type": "long long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3000, "task_id": "maximum-area-of-longest-diagonal-rectangle", "difficulty": "Easy", "problem_description": "You are given a 2D 0-indexed integer array dimensions.\nFor all indices i, 0 <= i < dimensions.length, dimensions[i][0] represents the length and dimensions[i][1] represents the width of the rectangle i.\nReturn the area of the rectangle having the longest diagonal. If there are multiple rectangles with the longest diagonal, return the area of the rectangle having the maximum area.\n \nExample 1:\n\nInput: dimensions = [[9,3],[8,6]]\nOutput: 48\nExplanation: \nFor index = 0, length = 9 and width = 3. Diagonal length = sqrt(9 * 9 + 3 * 3) = sqrt(90) ≈ 9.487.\nFor index = 1, length = 8 and width = 6. Diagonal length = sqrt(8 * 8 + 6 * 6) = sqrt(100) = 10.\nSo, the rectangle at index 1 has a greater diagonal length therefore we return area = 8 * 6 = 48.\n\nExample 2:\n\nInput: dimensions = [[3,4],[4,3]]\nOutput: 12\nExplanation: Length of diagonal is the same for both which is 5, so maximum area = 12.\n\n \nConstraints:\n\n1 <= dimensions.length <= 100\ndimensions[i].length == 2\n1 <= dimensions[i][0], dimensions[i][1] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(dimensions = [[5, 12], [13, 88], [20, 21]]) == 1144\n assert candidate(dimensions = [[6, 8], [8, 6], [10, 24]]) == 240\n assert candidate(dimensions = [[9, 3], [8, 6]]) == 48\n assert candidate(dimensions = [[7, 24], [24, 7], [10, 10]]) == 168\n assert candidate(dimensions = [[1, 1], [1, 1], [1, 1]]) == 1\n assert candidate(dimensions = [[100, 1], [1, 100]]) == 100\n assert candidate(dimensions = [[1, 2], [2, 1], [3, 4], [4, 3]]) == 12\n assert candidate(dimensions = [[5, 12], [12, 5], [8, 8]]) == 60\n assert candidate(dimensions = [[10, 10], [15, 15], [20, 20]]) == 400\n assert candidate(dimensions = [[10, 24], [24, 10], [15, 20]]) == 240\n assert candidate(dimensions = [[1, 1], [2, 2], [3, 3]]) == 9\n assert candidate(dimensions = [[5, 12], [12, 5], [8, 15]]) == 120\n assert candidate(dimensions = [[10, 10], [10, 10], [10, 10]]) == 100\n assert candidate(dimensions = [[5, 12], [12, 5], [8, 6]]) == 60\n assert candidate(dimensions = [[3, 4], [4, 3]]) == 12\n assert candidate(dimensions = [[5, 12], [12, 5], [8, 15], [15, 8], [7, 24], [24, 7], [9, 40], [40, 9], [11, 60], [60, 11]]) == 660\n assert candidate(dimensions = [[9, 40], [40, 9], [12, 35], [35, 12], [15, 36], [36, 15]]) == 360\n assert candidate(dimensions = [[20, 21], [19, 22], [21, 20], [22, 19]]) == 418\n assert candidate(dimensions = [[48, 55], [60, 80], [33, 56], [77, 36]]) == 4800\n assert candidate(dimensions = [[99, 1], [1, 99], [45, 55]]) == 99\n assert candidate(dimensions = [[10, 24], [24, 10], [7, 24], [24, 7]]) == 240\n assert candidate(dimensions = [[12, 5], [7, 24], [9, 40]]) == 360\n assert candidate(dimensions = [[99, 1], [1, 99], [49, 51], [51, 49], [50, 50], [33, 66], [66, 33]]) == 99\n assert candidate(dimensions = [[10, 10], [15, 20], [20, 15], [10, 25], [25, 10]]) == 250\n assert candidate(dimensions = [[60, 80], [80, 60], [48, 55], [55, 48]]) == 4800\n assert candidate(dimensions = [[20, 21], [21, 20], [15, 20], [20, 15], [18, 24], [24, 18]]) == 432\n assert candidate(dimensions = [[10, 24], [7, 24], [24, 10]]) == 240\n assert candidate(dimensions = [[4, 1], [1, 4], [3, 5], [5, 3], [2, 6], [6, 2], [7, 1], [1, 7], [8, 2], [2, 8]]) == 16\n assert candidate(dimensions = [[50, 50], [40, 60], [60, 40], [30, 70], [70, 30]]) == 2100\n assert candidate(dimensions = [[12, 16], [15, 20], [7, 24], [8, 15]]) == 300\n assert candidate(dimensions = [[66, 68], [67, 67], [65, 69], [68, 66], [69, 65]]) == 4485\n assert candidate(dimensions = [[99, 1], [1, 99], [50, 50], [45, 45], [55, 55]]) == 99\n assert candidate(dimensions = [[1, 100], [100, 1], [50, 50], [25, 75], [75, 25], [60, 80], [80, 60]]) == 100\n assert candidate(dimensions = [[45, 55], [55, 45], [30, 70], [70, 30], [60, 60], [20, 80], [80, 20], [10, 90], [90, 10]]) == 900\n assert candidate(dimensions = [[3, 4], [4, 3], [5, 12], [12, 5], [8, 15], [15, 8]]) == 120\n assert candidate(dimensions = [[7, 24], [24, 7], [3, 4], [4, 3]]) == 168\n assert candidate(dimensions = [[50, 50], [51, 49], [49, 51], [30, 40], [40, 30], [25, 60], [60, 25]]) == 2499\n assert candidate(dimensions = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90]]) == 8100\n assert candidate(dimensions = [[20, 21], [21, 20], [19, 22], [22, 19], [18, 23], [23, 18]]) == 414\n assert candidate(dimensions = [[10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]]) == 225\n assert candidate(dimensions = [[80, 15], [15, 80], [75, 20], [20, 75], [70, 25], [25, 70]]) == 1200\n assert candidate(dimensions = [[99, 1], [1, 99], [45, 45], [23, 77]]) == 99\n assert candidate(dimensions = [[50, 50], [51, 51], [49, 49], [48, 48], [52, 52], [53, 53], [54, 54]]) == 2916\n assert candidate(dimensions = [[10, 1], [9, 12], [12, 9], [8, 15], [15, 8], [7, 18], [18, 7]]) == 126\n assert candidate(dimensions = [[10, 6], [6, 10], [8, 15], [15, 8], [12, 5], [5, 12]]) == 120\n assert candidate(dimensions = [[99, 1], [1, 99], [45, 45], [50, 50]]) == 99\n assert candidate(dimensions = [[33, 56], [56, 33], [45, 60], [60, 45], [28, 96], [96, 28], [55, 72], [72, 55]]) == 2688\n assert candidate(dimensions = [[50, 50], [40, 60], [30, 70], [20, 80]]) == 1600\n assert candidate(dimensions = [[50, 50], [60, 80], [80, 60], [45, 45], [70, 70]]) == 4800\n assert candidate(dimensions = [[10, 24], [24, 10], [15, 20], [20, 15], [12, 35], [35, 12], [16, 30], [30, 16], [18, 24], [24, 18]]) == 420\n assert candidate(dimensions = [[8, 6], [6, 8], [5, 5], [7, 7], [9, 9]]) == 81\n assert candidate(dimensions = [[1, 100], [100, 1], [50, 50], [75, 25], [25, 75]]) == 100\n assert candidate(dimensions = [[7, 24], [24, 7], [8, 15], [15, 8], [3, 4], [4, 3], [10, 24], [24, 10]]) == 240\n assert candidate(dimensions = [[1, 100], [100, 1], [50, 50], [30, 70], [70, 30], [20, 80], [80, 20], [10, 90], [90, 10], [45, 55], [55, 45], [60, 60], [25, 60], [60, 25]]) == 100\n assert candidate(dimensions = [[33, 56], [56, 33], [40, 42], [42, 40], [48, 55], [55, 48]]) == 2640\n assert candidate(dimensions = [[8, 15], [15, 8], [7, 24], [24, 7], [5, 12], [12, 5], [9, 40], [40, 9]]) == 360\n assert candidate(dimensions = [[1, 2], [2, 1], [3, 4], [4, 3], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 100\n assert candidate(dimensions = [[99, 1], [1, 99], [50, 50], [60, 80], [80, 60]]) == 4800\n assert candidate(dimensions = [[5, 12], [12, 5], [8, 15], [15, 8]]) == 120\n assert candidate(dimensions = [[8, 15], [15, 8], [7, 24], [24, 7], [12, 16], [16, 12], [9, 40], [40, 9], [6, 72], [72, 6]]) == 432\n assert candidate(dimensions = [[97, 1], [1, 97], [98, 2], [2, 98], [50, 50]]) == 196\n assert candidate(dimensions = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16]]) == 240\n assert candidate(dimensions = [[15, 20], [20, 15], [25, 25]]) == 625\n assert candidate(dimensions = [[48, 55], [55, 48], [60, 80], [80, 60]]) == 4800\n assert candidate(dimensions = [[45, 55], [55, 45], [40, 60], [60, 40], [35, 65], [65, 35]]) == 2275\n assert candidate(dimensions = [[6, 8], [8, 6], [10, 24], [24, 10], [15, 20], [20, 15]]) == 240\n assert candidate(dimensions = [[6, 8], [8, 6], [5, 12], [12, 5], [9, 40], [40, 9], [35, 12], [12, 35], [7, 24], [24, 7]]) == 360\n assert candidate(dimensions = [[99, 1], [1, 99], [90, 40], [40, 90], [50, 50], [60, 60]]) == 99\n assert candidate(dimensions = [[33, 56], [56, 33], [48, 55], [55, 48], [60, 80], [80, 60], [77, 36], [36, 77]]) == 4800\n assert candidate(dimensions = [[30, 40], [40, 30], [25, 50], [50, 25], [20, 60], [60, 20]]) == 1200\n assert candidate(dimensions = [[1, 100], [100, 1], [50, 50], [40, 60], [60, 40], [30, 70], [70, 30]]) == 100\n assert candidate(dimensions = [[10, 24], [24, 10], [15, 20], [20, 15], [7, 24], [24, 7]]) == 240\n assert candidate(dimensions = [[3, 4], [6, 8], [5, 12], [8, 15]]) == 120\n assert candidate(dimensions = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60]]) == 3600\n assert candidate(dimensions = [[33, 56], [56, 33], [28, 45], [45, 28], [60, 80], [80, 60]]) == 4800\n assert candidate(dimensions = [[33, 56], [56, 33], [40, 40], [30, 40], [40, 30]]) == 1848\n assert candidate(dimensions = [[10, 24], [7, 24], [24, 10], [15, 20], [30, 40], [25, 60], [60, 25]]) == 1500\n assert candidate(dimensions = [[50, 50], [40, 80], [60, 40], [30, 70]]) == 3200\n assert candidate(dimensions = [[99, 1], [1, 99], [50, 50], [40, 70], [70, 40]]) == 99\n assert candidate(dimensions = [[12, 16], [16, 12], [10, 10], [20, 20]]) == 400\n assert candidate(dimensions = [[10, 10], [15, 15], [20, 20], [25, 25], [30, 30]]) == 900\n assert candidate(dimensions = [[30, 40], [40, 30], [35, 35], [25, 25], [45, 45]]) == 2025\n assert candidate(dimensions = [[1, 100], [100, 1], [50, 50], [25, 75], [75, 25], [20, 80], [80, 20], [30, 70], [70, 30]]) == 100\n assert candidate(dimensions = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12]]) == 144\n assert candidate(dimensions = [[6, 8], [8, 6], [7, 24], [24, 7], [15, 20], [20, 15], [12, 16], [16, 12]]) == 300\n assert candidate(dimensions = [[8, 15], [15, 8], [7, 24], [24, 7], [6, 8], [8, 6]]) == 168\n assert candidate(dimensions = [[99, 1], [98, 2], [97, 3], [96, 4], [95, 5]]) == 99\n assert candidate(dimensions = [[3, 4], [4, 3], [6, 8], [8, 6], [5, 12], [12, 5], [7, 24], [24, 7]]) == 168\n assert candidate(dimensions = [[15, 20], [20, 15], [10, 25], [25, 10]]) == 250\n assert candidate(dimensions = [[5, 12], [12, 5], [9, 40], [40, 9], [35, 12], [12, 35]]) == 360\n assert candidate(dimensions = [[60, 80], [80, 60], [70, 70], [50, 90], [90, 50], [65, 75], [75, 65]]) == 4500\n assert candidate(dimensions = [[10, 24], [20, 21], [15, 36], [30, 40], [12, 16], [8, 15]]) == 1200\n assert candidate(dimensions = [[33, 56], [56, 33], [22, 88], [88, 22], [44, 44]]) == 1936\n assert candidate(dimensions = [[25, 60], [30, 40], [50, 50], [45, 55], [35, 65]]) == 2275\n assert candidate(dimensions = [[60, 80], [80, 60], [48, 55], [55, 48], [5, 12], [12, 5], [8, 15], [15, 8]]) == 4800\n assert candidate(dimensions = [[20, 21], [21, 20], [15, 25], [25, 15]]) == 375\n assert candidate(dimensions = [[50, 50], [70, 30], [60, 40]]) == 2100\n assert candidate(dimensions = [[50, 50], [49, 51], [51, 49], [60, 8], [8, 60]]) == 2499\n assert candidate(dimensions = [[1, 100], [100, 1], [50, 50], [70, 70], [60, 80], [80, 60]]) == 100\n assert candidate(dimensions = [[25, 60], [60, 25], [40, 40], [30, 70], [70, 30], [10, 90], [90, 10]]) == 900\n assert candidate(dimensions = [[10, 24], [24, 10], [15, 36], [36, 15], [20, 21], [21, 20], [25, 60], [60, 25], [30, 40], [40, 30]]) == 1500\n assert candidate(dimensions = [[33, 56], [56, 33], [44, 48], [48, 44], [29, 71], [71, 29], [17, 84], [84, 17]]) == 1428\n assert candidate(dimensions = [[13, 84], [84, 13], [16, 82], [82, 16], [20, 79], [79, 20], [24, 76], [76, 24], [28, 73], [73, 28]]) == 1092\n assert candidate(dimensions = [[15, 20], [30, 40], [25, 60], [60, 25]]) == 1500\n assert candidate(dimensions = [[5, 12], [12, 5], [8, 15], [15, 8], [10, 24], [24, 10]]) == 240\n assert candidate(dimensions = [[28, 45], [35, 84], [65, 72], [72, 65], [50, 120], [120, 50]]) == 6000\n assert candidate(dimensions = [[20, 21], [21, 20], [19, 22], [22, 19], [18, 23], [23, 18], [17, 24], [24, 17]]) == 408\n"}, "metadata": {"canonical_parameter_names": ["dimensions"], "leetcode_dataset_entry_point": "Solution().areaOfMaxDiagonal", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int areaOfMaxDiagonal(vector>& dimensions) {", "container": "Solution", "callable": "areaOfMaxDiagonal", "parameters": [{"name": "dimensions", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3001, "task_id": "minimum-moves-to-capture-the-queen", "difficulty": "Medium", "problem_description": "There is a 1-indexed 8 x 8 chessboard containing 3 pieces.\nYou are given 6 integers a, b, c, d, e, and f where:\n\n(a, b) denotes the position of the white rook.\n(c, d) denotes the position of the white bishop.\n(e, f) denotes the position of the black queen.\n\nGiven that you can only move the white pieces, return the minimum number of moves required to capture the black queen.\nNote that:\n\nRooks can move any number of squares either vertically or horizontally, but cannot jump over other pieces.\nBishops can move any number of squares diagonally, but cannot jump over other pieces.\nA rook or a bishop can capture the queen if it is located in a square that they can move to.\nThe queen does not move.\n\n \nExample 1:\n\n\nInput: a = 1, b = 1, c = 8, d = 8, e = 2, f = 3\nOutput: 2\nExplanation: We can capture the black queen in two moves by moving the white rook to (1, 3) then to (2, 3).\nIt is impossible to capture the black queen in less than two moves since it is not being attacked by any of the pieces at the beginning.\n\nExample 2:\n\n\nInput: a = 5, b = 3, c = 3, d = 4, e = 5, f = 2\nOutput: 1\nExplanation: We can capture the black queen in a single move by doing one of the following: \n- Move the white rook to (5, 2).\n- Move the white bishop to (5, 2).\n\n \nConstraints:\n\n1 <= a, b, c, d, e, f <= 8\nNo two pieces are on the same square.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(a = 4,b = 4,c = 7,d = 7,e = 3,f = 3) == 2\n assert candidate(a = 3,b = 3,c = 6,d = 6,e = 7,f = 7) == 1\n assert candidate(a = 7,b = 2,c = 2,d = 7,e = 4,f = 4) == 2\n assert candidate(a = 1,b = 8,c = 2,d = 7,e = 3,f = 6) == 1\n assert candidate(a = 8,b = 8,c = 1,d = 1,e = 3,f = 3) == 1\n assert candidate(a = 8,b = 8,c = 1,d = 1,e = 4,f = 4) == 1\n assert candidate(a = 8,b = 1,c = 5,d = 4,e = 7,f = 7) == 2\n assert candidate(a = 4,b = 4,c = 7,d = 7,e = 6,f = 6) == 1\n assert candidate(a = 5,b = 3,c = 3,d = 4,e = 5,f = 2) == 1\n assert candidate(a = 1,b = 1,c = 8,d = 8,e = 2,f = 3) == 2\n assert candidate(a = 4,b = 4,c = 6,d = 6,e = 7,f = 7) == 1\n assert candidate(a = 6,b = 6,c = 2,d = 2,e = 4,f = 4) == 1\n assert candidate(a = 2,b = 2,c = 4,d = 4,e = 6,f = 6) == 1\n assert candidate(a = 4,b = 4,c = 1,d = 4,e = 8,f = 4) == 1\n assert candidate(a = 2,b = 3,c = 5,d = 6,e = 3,f = 4) == 1\n assert candidate(a = 4,b = 4,c = 4,d = 1,e = 4,f = 8) == 1\n assert candidate(a = 3,b = 3,c = 5,d = 5,e = 6,f = 6) == 1\n assert candidate(a = 8,b = 8,c = 7,d = 7,e = 6,f = 6) == 1\n assert candidate(a = 3,b = 3,c = 6,d = 6,e = 5,f = 5) == 1\n assert candidate(a = 1,b = 1,c = 2,d = 2,e = 8,f = 8) == 1\n assert candidate(a = 4,b = 4,c = 5,d = 5,e = 6,f = 6) == 1\n assert candidate(a = 1,b = 1,c = 2,d = 2,e = 3,f = 3) == 1\n assert candidate(a = 1,b = 8,c = 8,d = 1,e = 4,f = 4) == 2\n assert candidate(a = 3,b = 3,c = 5,d = 5,e = 2,f = 2) == 2\n assert candidate(a = 5,b = 5,c = 1,d = 9,e = 9,f = 1) == 2\n assert candidate(a = 2,b = 4,c = 7,d = 1,e = 4,f = 7) == 2\n assert candidate(a = 6,b = 2,c = 3,d = 5,e = 5,f = 2) == 1\n assert candidate(a = 5,b = 1,c = 2,d = 6,e = 5,f = 8) == 1\n assert candidate(a = 5,b = 5,c = 2,d = 8,e = 2,f = 3) == 2\n assert candidate(a = 3,b = 6,c = 6,d = 3,e = 7,f = 7) == 2\n assert candidate(a = 2,b = 2,c = 5,d = 5,e = 3,f = 3) == 1\n assert candidate(a = 5,b = 5,c = 1,d = 1,e = 8,f = 8) == 2\n assert candidate(a = 5,b = 5,c = 3,d = 3,e = 5,f = 1) == 1\n assert candidate(a = 6,b = 3,c = 3,d = 6,e = 8,f = 1) == 2\n assert candidate(a = 8,b = 8,c = 1,d = 1,e = 5,f = 5) == 1\n assert candidate(a = 3,b = 3,c = 6,d = 6,e = 4,f = 7) == 2\n assert candidate(a = 1,b = 1,c = 7,d = 7,e = 4,f = 4) == 1\n assert candidate(a = 4,b = 8,c = 8,d = 4,e = 1,f = 1) == 2\n assert candidate(a = 1,b = 4,c = 8,d = 4,e = 5,f = 4) == 1\n assert candidate(a = 2,b = 5,c = 5,d = 2,e = 7,f = 7) == 2\n assert candidate(a = 1,b = 1,c = 3,d = 5,e = 7,f = 7) == 2\n assert candidate(a = 7,b = 2,c = 3,d = 6,e = 5,f = 4) == 1\n assert candidate(a = 4,b = 4,c = 1,d = 8,e = 8,f = 1) == 1\n assert candidate(a = 2,b = 5,c = 5,d = 2,e = 7,f = 5) == 1\n assert candidate(a = 5,b = 8,c = 3,d = 3,e = 1,f = 1) == 1\n assert candidate(a = 1,b = 5,c = 8,d = 5,e = 6,f = 5) == 1\n assert candidate(a = 8,b = 8,c = 1,d = 8,e = 1,f = 1) == 2\n assert candidate(a = 7,b = 7,c = 2,d = 2,e = 5,f = 5) == 1\n assert candidate(a = 3,b = 5,c = 1,d = 1,e = 8,f = 8) == 1\n assert candidate(a = 3,b = 3,c = 6,d = 3,e = 5,f = 3) == 1\n assert candidate(a = 5,b = 1,c = 1,d = 5,e = 6,f = 6) == 2\n assert candidate(a = 4,b = 4,c = 3,d = 5,e = 5,f = 3) == 2\n assert candidate(a = 8,b = 8,c = 3,d = 3,e = 6,f = 6) == 1\n assert candidate(a = 8,b = 1,c = 5,d = 4,e = 4,f = 4) == 2\n assert candidate(a = 4,b = 4,c = 1,d = 8,e = 7,f = 2) == 1\n assert candidate(a = 6,b = 2,c = 2,d = 6,e = 3,f = 3) == 2\n assert candidate(a = 3,b = 6,c = 6,d = 3,e = 8,f = 8) == 2\n assert candidate(a = 2,b = 2,c = 5,d = 5,e = 7,f = 7) == 1\n assert candidate(a = 8,b = 1,c = 1,d = 8,e = 5,f = 5) == 2\n assert candidate(a = 4,b = 4,c = 7,d = 1,e = 1,f = 8) == 2\n assert candidate(a = 4,b = 4,c = 1,d = 8,e = 7,f = 7) == 2\n assert candidate(a = 1,b = 8,c = 7,d = 1,e = 4,f = 4) == 1\n assert candidate(a = 7,b = 3,c = 4,d = 6,e = 1,f = 1) == 2\n assert candidate(a = 1,b = 1,c = 7,d = 7,e = 8,f = 8) == 1\n assert candidate(a = 4,b = 4,c = 8,d = 1,e = 2,f = 2) == 2\n assert candidate(a = 3,b = 8,c = 6,d = 3,e = 8,f = 1) == 1\n assert candidate(a = 3,b = 6,c = 6,d = 3,e = 5,f = 5) == 2\n assert candidate(a = 5,b = 5,c = 2,d = 2,e = 8,f = 1) == 2\n assert candidate(a = 4,b = 4,c = 5,d = 5,e = 7,f = 2) == 2\n assert candidate(a = 1,b = 8,c = 8,d = 1,e = 5,f = 5) == 2\n assert candidate(a = 6,b = 3,c = 2,d = 7,e = 5,f = 5) == 2\n assert candidate(a = 4,b = 4,c = 1,d = 1,e = 8,f = 8) == 2\n assert candidate(a = 7,b = 2,c = 2,d = 7,e = 5,f = 5) == 2\n assert candidate(a = 8,b = 1,c = 1,d = 8,e = 4,f = 4) == 2\n assert candidate(a = 1,b = 1,c = 7,d = 2,e = 8,f = 8) == 2\n assert candidate(a = 1,b = 8,c = 3,d = 6,e = 4,f = 4) == 2\n assert candidate(a = 2,b = 2,c = 5,d = 5,e = 8,f = 8) == 1\n assert candidate(a = 1,b = 1,c = 7,d = 7,e = 5,f = 5) == 1\n assert candidate(a = 2,b = 3,c = 4,d = 6,e = 3,f = 6) == 2\n assert candidate(a = 4,b = 4,c = 7,d = 1,e = 1,f = 7) == 2\n assert candidate(a = 1,b = 8,c = 5,d = 5,e = 3,f = 3) == 1\n assert candidate(a = 1,b = 8,c = 4,d = 4,e = 8,f = 1) == 2\n assert candidate(a = 7,b = 7,c = 3,d = 3,e = 4,f = 4) == 1\n assert candidate(a = 5,b = 5,c = 8,d = 1,e = 1,f = 8) == 1\n assert candidate(a = 2,b = 2,c = 7,d = 7,e = 4,f = 4) == 1\n assert candidate(a = 8,b = 8,c = 5,d = 5,e = 2,f = 2) == 1\n assert candidate(a = 1,b = 1,c = 8,d = 8,e = 4,f = 4) == 1\n assert candidate(a = 1,b = 5,c = 5,d = 1,e = 8,f = 8) == 2\n assert candidate(a = 8,b = 1,c = 4,d = 4,e = 5,f = 5) == 1\n"}, "metadata": {"canonical_parameter_names": ["a", "b", "c", "d", "e", "f"], "leetcode_dataset_entry_point": "Solution().minMovesToCaptureTheQueen", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minMovesToCaptureTheQueen(int a, int b, int c, int d, int e, int f) {", "container": "Solution", "callable": "minMovesToCaptureTheQueen", "parameters": [{"name": "a", "type": "int"}, {"name": "b", "type": "int"}, {"name": "c", "type": "int"}, {"name": "d", "type": "int"}, {"name": "e", "type": "int"}, {"name": "f", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3002, "task_id": "maximum-size-of-a-set-after-removals", "difficulty": "Medium", "problem_description": "You are given two 0-indexed integer arrays nums1 and nums2 of even length n.\nYou must remove n / 2 elements from nums1 and n / 2 elements from nums2. After the removals, you insert the remaining elements of nums1 and nums2 into a set s.\nReturn the maximum possible size of the set s.\n \nExample 1:\n\nInput: nums1 = [1,2,1,2], nums2 = [1,1,1,1]\nOutput: 2\nExplanation: We remove two occurences of 1 from nums1 and nums2. After the removals, the arrays become equal to nums1 = [2,2] and nums2 = [1,1]. Therefore, s = {1,2}.\nIt can be shown that 2 is the maximum possible size of the set s after the removals.\n\nExample 2:\n\nInput: nums1 = [1,2,3,4,5,6], nums2 = [2,3,2,3,2,3]\nOutput: 5\nExplanation: We remove 2, 3, and 6 from nums1, as well as 2 and two occurrences of 3 from nums2. After the removals, the arrays become equal to nums1 = [1,4,5] and nums2 = [2,3,2]. Therefore, s = {1,2,3,4,5}.\nIt can be shown that 5 is the maximum possible size of the set s after the removals.\n\nExample 3:\n\nInput: nums1 = [1,1,2,2,3,3], nums2 = [4,4,5,5,6,6]\nOutput: 6\nExplanation: We remove 1, 2, and 3 from nums1, as well as 4, 5, and 6 from nums2. After the removals, the arrays become equal to nums1 = [1,2,3] and nums2 = [4,5,6]. Therefore, s = {1,2,3,4,5,6}.\nIt can be shown that 6 is the maximum possible size of the set s after the removals.\n\n \nConstraints:\n\nn == nums1.length == nums2.length\n1 <= n <= 2 * 104\nn is even.\n1 <= nums1[i], nums2[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6],nums2 = [1, 2, 3, 4, 5, 6]) == 6\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1],nums2 = [2, 2, 2, 2, 2, 2]) == 2\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3],nums2 = [4, 4, 5, 5, 6, 6]) == 6\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8],nums2 = [5, 6, 7, 8, 9, 10, 11, 12]) == 8\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60],nums2 = [40, 50, 60, 70, 80, 90]) == 6\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11],nums2 = [2, 4, 6, 8, 10, 12]) == 6\n assert candidate(nums1 = [1, 1, 1, 1],nums2 = [2, 2, 2, 2]) == 2\n assert candidate(nums1 = [1, 2, 1, 2],nums2 = [1, 1, 1, 1]) == 2\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3],nums2 = [3, 3, 4, 4, 5, 5]) == 5\n assert candidate(nums1 = [9, 9, 9, 9, 9, 9],nums2 = [9, 9, 9, 9, 9, 9]) == 1\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60],nums2 = [10, 20, 10, 20, 10, 20]) == 5\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6],nums2 = [2, 3, 2, 3, 2, 3]) == 5\n assert candidate(nums1 = [1, 2, 3, 4],nums2 = [5, 6, 7, 8]) == 4\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 20\n assert candidate(nums1 = [1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 5, 6, 6],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 14\n assert candidate(nums1 = [1000000000, 1000000000, 1000000000, 1000000000],nums2 = [1000000000, 1000000000, 1000000000, 1000000000]) == 1\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4],nums2 = [2, 2, 3, 3, 5, 5, 6, 6]) == 6\n assert candidate(nums1 = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 10\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 16\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4],nums2 = [4, 4, 5, 5, 6, 6, 7, 7]) == 7\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3]) == 3\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 7\n assert candidate(nums1 = [10, 20, 20, 30, 30, 30, 40, 50],nums2 = [10, 20, 20, 30, 40, 40, 50, 60]) == 6\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 12\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 17, 18, 19, 20]) == 16\n assert candidate(nums1 = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11],nums2 = [2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 12]) == 12\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],nums2 = [17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]) == 16\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],nums2 = [6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11]) == 11\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60]) == 30\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 10\n assert candidate(nums1 = [1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4],nums2 = [2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 5]) == 5\n assert candidate(nums1 = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7],nums2 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11]) == 11\n assert candidate(nums1 = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11],nums2 = [2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12]) == 12\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32],nums2 = [31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62]) == 32\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(nums1 = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9],nums2 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]) == 9\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160],nums2 = [10, 20, 30, 40, 50, 60, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 16\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15],nums2 = [2, 4, 6, 8, 10, 12, 14, 16]) == 8\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],nums2 = [1, 1, 2, 2, 3, 3, 7, 8, 9, 10, 11, 12]) == 12\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums2 = [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 20\n assert candidate(nums1 = [1, 2, 2, 3, 4, 4, 5, 5, 6, 6, 7, 7],nums2 = [2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8]) == 8\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4],nums2 = [2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5]) == 5\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums1 = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5],nums2 = [5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9]) == 9\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],nums2 = [6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11]) == 11\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 30\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(nums1 = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],nums2 = [4, 4, 4, 4, 5, 5, 5, 6, 6, 6]) == 6\n assert candidate(nums1 = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6],nums2 = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 6\n assert candidate(nums1 = [1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9],nums2 = [9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16]) == 16\n assert candidate(nums1 = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10],nums2 = [10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2]) == 10\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],nums2 = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 14\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums2 = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 20\n assert candidate(nums1 = [5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9],nums2 = [5, 6, 7, 8, 9, 5, 6, 7, 8, 9, 5, 6, 7, 8, 9, 5, 6, 7, 8, 9]) == 5\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 3\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 7\n assert candidate(nums1 = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5],nums2 = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 5\n assert candidate(nums1 = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2],nums2 = [3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3]) == 3\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 6\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],nums2 = [31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60]) == 30\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16],nums2 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16]) == 16\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 9\n assert candidate(nums1 = [1, 2, 2, 3, 4, 4, 5, 5],nums2 = [2, 3, 3, 4, 5, 5, 6, 7]) == 7\n assert candidate(nums1 = [10, 10, 20, 20, 30, 30, 40, 40],nums2 = [40, 40, 50, 50, 60, 60, 70, 70]) == 7\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 14\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],nums2 = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 16\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7],nums2 = [2, 2, 3, 3, 4, 4, 5, 5, 8, 8, 9, 9, 10, 10]) == 10\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7],nums2 = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3]) == 6\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],nums2 = [9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]) == 16\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]) == 24\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],nums2 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]) == 16\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],nums2 = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 12\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 16\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],nums2 = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 16\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 100]) == 10\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 2\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 16\n assert candidate(nums1 = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4],nums2 = [4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7]) == 7\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums2 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 20\n assert candidate(nums1 = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11],nums2 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 11\n assert candidate(nums1 = [1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6],nums2 = [6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 10, 10]) == 10\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [50, 60, 70, 80, 90, 100, 110, 120, 130, 140]) == 10\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums2 = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]) == 20\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 3\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 10\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 2, 2, 3, 3],nums2 = [4, 4, 5, 5, 6, 6, 7, 7, 8, 8]) == 8\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]) == 18\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18],nums2 = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6]) == 15\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18],nums2 = [9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]) == 18\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(nums1 = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8],nums2 = [5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]) == 9\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],nums2 = [9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 9\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4],nums2 = [4, 4, 5, 5, 6, 6, 7, 7]) == 7\n assert candidate(nums1 = [1, 2, 3, 4, 5, 5, 5, 6, 6, 7, 8, 9, 10, 10, 10, 11],nums2 = [5, 5, 6, 6, 6, 7, 8, 9, 10, 10, 10, 11, 12, 13, 14, 15]) == 15\n assert candidate(nums1 = [1000000000, 1000000000, 1000000000, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],nums2 = [1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]) == 18\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],nums2 = [16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45]) == 30\n"}, "metadata": {"canonical_parameter_names": ["nums1", "nums2"], "leetcode_dataset_entry_point": "Solution().maximumSetSize", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maximumSetSize(vector& nums1, vector& nums2) {", "container": "Solution", "callable": "maximumSetSize", "parameters": [{"name": "nums1", "type": "vector&"}, {"name": "nums2", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3003, "task_id": "maximize-the-number-of-partitions-after-operations", "difficulty": "Hard", "problem_description": "You are given a string s and an integer k.\nFirst, you are allowed to change at most one index in s to another lowercase English letter.\nAfter that, do the following partitioning operation until s is empty:\n\nChoose the longest prefix of s containing at most k distinct characters.\nDelete the prefix from s and increase the number of partitions by one. The remaining characters (if any) in s maintain their initial order.\n\nReturn an integer denoting the maximum number of resulting partitions after the operations by optimally choosing at most one index to change.\n \nExample 1:\n\nInput: s = \"accca\", k = 2\nOutput: 3\nExplanation:\nThe optimal way is to change s[2] to something other than a and c, for example, b. then it becomes \"acbca\".\nThen we perform the operations:\n\nThe longest prefix containing at most 2 distinct characters is \"ac\", we remove it and s becomes \"bca\".\nNow The longest prefix containing at most 2 distinct characters is \"bc\", so we remove it and s becomes \"a\".\nFinally, we remove \"a\" and s becomes empty, so the procedure ends.\n\nDoing the operations, the string is divided into 3 partitions, so the answer is 3.\n\nExample 2:\n\nInput: s = \"aabaab\", k = 3\nOutput: 1\nExplanation:\nInitially s contains 2 distinct characters, so whichever character we change, it will contain at most 3 distinct characters, so the longest prefix with at most 3 distinct characters would always be all of it, therefore the answer is 1.\n\nExample 3:\n\nInput: s = \"xxyz\", k = 1\nOutput: 4\nExplanation:\nThe optimal way is to change s[0] or s[1] to something other than characters in s, for example, to change s[0] to w.\nThen s becomes \"wxyz\", which consists of 4 distinct characters, so as k is 1, it will divide into 4 partitions.\n\n \nConstraints:\n\n1 <= s.length <= 104\ns consists only of lowercase English letters.\n1 <= k <= 26\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"zzzzzzz\",k = 1) == 3\n assert candidate(s = \"abcdef\",k = 6) == 1\n assert candidate(s = \"aaaaaaa\",k = 1) == 3\n assert candidate(s = \"abcdefghijklmnop\",k = 5) == 4\n assert candidate(s = \"aabacbebebe\",k = 3) == 2\n assert candidate(s = \"aaaabbbbcccc\",k = 3) == 2\n assert candidate(s = \"zzzzzzzzzz\",k = 1) == 3\n assert candidate(s = \"abcd\",k = 2) == 2\n assert candidate(s = \"abacabadabacaba\",k = 3) == 4\n assert candidate(s = \"aabaab\",k = 3) == 1\n assert candidate(s = \"aabbccddeeffgg\",k = 2) == 4\n assert candidate(s = \"accca\",k = 2) == 3\n assert candidate(s = \"aabbaa\",k = 2) == 2\n assert candidate(s = \"zzzzz\",k = 1) == 3\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 10) == 3\n assert candidate(s = \"aabbccddeeff\",k = 3) == 3\n assert candidate(s = \"xxyz\",k = 1) == 4\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 26) == 1\n assert candidate(s = \"abcdabcd\",k = 4) == 2\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzz\",k = 1) == 3\n assert candidate(s = \"abcdefg\",k = 7) == 1\n assert candidate(s = \"aabbaabb\",k = 2) == 3\n assert candidate(s = \"zzzzzzzzz\",k = 1) == 3\n assert candidate(s = \"abacabadabacaba\",k = 2) == 7\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 26) == 1\n assert candidate(s = \"abcdefabcdef\",k = 4) == 3\n assert candidate(s = \"aabbccddeeff\",k = 2) == 4\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\",k = 2) == 15\n assert candidate(s = \"abcdefg\",k = 3) == 3\n assert candidate(s = \"abcabcabc\",k = 3) == 3\n assert candidate(s = \"abacabad\",k = 2) == 4\n assert candidate(s = \"aaaa\",k = 1) == 3\n assert candidate(s = \"abcabcabcabc\",k = 3) == 3\n assert candidate(s = \"aabcccccaabaab\",k = 2) == 4\n assert candidate(s = \"mnopqrstuvw\",k = 6) == 2\n assert candidate(s = \"abcdabcdabcdabcd\",k = 4) == 3\n assert candidate(s = \"xyzxyzxyzxyzxyz\",k = 3) == 3\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\",k = 5) == 1\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\",k = 10) == 3\n assert candidate(s = \"ababababababab\",k = 2) == 3\n assert candidate(s = \"banana\",k = 2) == 3\n assert candidate(s = \"aaaaabbbbbaaaaabbbbb\",k = 2) == 3\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 1) == 27\n assert candidate(s = \"aaabbbcccdddeeefffggghhh\",k = 2) == 5\n assert candidate(s = \"abcdefghijklaaaa\",k = 4) == 4\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 1) == 3\n assert candidate(s = \"zzzzzzzzzzzz\",k = 1) == 3\n assert candidate(s = \"ababababababababab\",k = 2) == 3\n assert candidate(s = \"abcdefgabcdefg\",k = 4) == 4\n assert candidate(s = \"mississippi\",k = 2) == 4\n assert candidate(s = \"zzzzzzzzzzzzzzzzzz\",k = 1) == 3\n assert candidate(s = \"llllllllllllllllllllllllll\",k = 1) == 3\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 5) == 6\n assert candidate(s = \"abcabcabcabcabc\",k = 2) == 8\n assert candidate(s = \"xyxyxyxyxyxyxyxy\",k = 2) == 3\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyza\",k = 10) == 3\n assert candidate(s = \"abcabcabcabcabcabc\",k = 3) == 3\n assert candidate(s = \"zzzzzzzzzzzzzzzzz\",k = 1) == 3\n assert candidate(s = \"xyzzzzxyzzzz\",k = 2) == 4\n assert candidate(s = \"abcabcaabbccbbaccc\",k = 2) == 7\n assert candidate(s = \"abcdeabcdeabcde\",k = 5) == 3\n assert candidate(s = \"abcdefghijabcdefghijabcdefghij\",k = 5) == 6\n assert candidate(s = \"abcabcabcabcabcabcabcabc\",k = 2) == 12\n assert candidate(s = \"abcdefabcdefabcdef\",k = 5) == 4\n assert candidate(s = \"aabbaabbaabbaabbaabbaabb\",k = 2) == 3\n assert candidate(s = \"abcdabcdabcd\",k = 3) == 4\n assert candidate(s = \"abcdefghij\",k = 5) == 2\n assert candidate(s = \"aaabbbcccddd\",k = 3) == 2\n assert candidate(s = \"aabbccddeeffgghhii\",k = 26) == 1\n assert candidate(s = \"abcabcabcabc\",k = 2) == 6\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyza\",k = 25) == 2\n assert candidate(s = \"abababababababababababababababababababababababababababababab\",k = 2) == 3\n assert candidate(s = \"ababababababababababababababab\",k = 2) == 3\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",k = 1) == 3\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\",k = 3) == 3\n assert candidate(s = \"zzzzzzzzzzzzzzzz\",k = 1) == 3\n assert candidate(s = \"abcdefghij\",k = 1) == 10\n assert candidate(s = \"aabbbcccccdddd\",k = 3) == 2\n assert candidate(s = \"aaaaaaaaabbbbbbb\",k = 2) == 2\n assert candidate(s = \"aabbaabbaabbaabb\",k = 2) == 3\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcd\",k = 4) == 3\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 10) == 3\n assert candidate(s = \"aabccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 5) == 6\n assert candidate(s = \"abcdefg\",k = 1) == 7\n assert candidate(s = \"abbaabbaabba\",k = 2) == 3\n assert candidate(s = \"abracadabra\",k = 4) == 3\n assert candidate(s = \"aabbaabbccddeeffgg\",k = 3) == 3\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 1) == 3\n assert candidate(s = \"abcabcabc\",k = 2) == 5\n assert candidate(s = \"xyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzz\",k = 2) == 16\n assert candidate(s = \"aabbccddeeffgghhii\",k = 5) == 2\n assert candidate(s = \"abababababab\",k = 2) == 3\n assert candidate(s = \"ababababababababababababab\",k = 2) == 3\n assert candidate(s = \"xyzzxyzzxyzz\",k = 3) == 3\n assert candidate(s = \"aaaaaaaaaabbbbbbbbccccccccdddddddd\",k = 4) == 2\n assert candidate(s = \"mississippi\",k = 3) == 3\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 1) == 26\n assert candidate(s = \"lalalalalala\",k = 2) == 3\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 3) == 9\n assert candidate(s = \"aaabbbcccdddeeefffggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxxyyyyzzzz\",k = 4) == 7\n assert candidate(s = \"aaaaaabbbbbbbccc\",k = 2) == 3\n assert candidate(s = \"xyzxyzxyzxyzxyzxyz\",k = 3) == 3\n assert candidate(s = \"xyzzzxyzzzxyzzz\",k = 3) == 3\n assert candidate(s = \"abracadabra\",k = 2) == 6\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\",k = 3) == 3\n assert candidate(s = \"abacbacbacbacba\",k = 4) == 1\n assert candidate(s = \"abcdefg\",k = 2) == 4\n assert candidate(s = \"abababababababab\",k = 2) == 3\n assert candidate(s = \"xyzzzxyzzzxyzzz\",k = 2) == 6\n assert candidate(s = \"abracadabraabracadabraabracadabra\",k = 3) == 8\n assert candidate(s = \"abcdabcdbca\",k = 3) == 4\n assert candidate(s = \"zzzzzabczzzzzdefzzzzzghizzzzzjklzzzzzmnopzzzzzqrstzzzzzuvwxyz\",k = 26) == 1\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",k = 13) == 4\n"}, "metadata": {"canonical_parameter_names": ["s", "k"], "leetcode_dataset_entry_point": "Solution().maxPartitionsAfterOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxPartitionsAfterOperations(string s, int k) {", "container": "Solution", "callable": "maxPartitionsAfterOperations", "parameters": [{"name": "s", "type": "string"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3005, "task_id": "count-elements-with-maximum-frequency", "difficulty": "Easy", "problem_description": "You are given an array nums consisting of positive integers.\nReturn the total frequencies of elements in nums such that those elements all have the maximum frequency.\nThe frequency of an element is the number of occurrences of that element in the array.\n \nExample 1:\n\nInput: nums = [1,2,2,3,1,4]\nOutput: 4\nExplanation: The elements 1 and 2 have a frequency of 2 which is the maximum frequency in the array.\nSo the number of elements in the array with maximum frequency is 4.\n\nExample 2:\n\nInput: nums = [1,2,3,4,5]\nOutput: 5\nExplanation: All elements of the array have a frequency of 1 which is the maximum.\nSo the number of elements in the array with maximum frequency is 5.\n\n \nConstraints:\n\n1 <= nums.length <= 100\n1 <= nums[i] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [3, 3, 3, 2, 2, 1]) == 3\n assert candidate(nums = [10, 20, 10, 20, 10, 30, 30, 30, 30]) == 4\n assert candidate(nums = [10, 20, 10, 20, 10, 30, 20, 40, 50, 20]) == 4\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4]) == 8\n assert candidate(nums = [1, 2, 2, 3, 1, 4]) == 4\n assert candidate(nums = [5, 5, 5, 5, 1, 1, 2, 2, 3, 3]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7]) == 7\n assert candidate(nums = [1, 1, 2, 2, 3, 3]) == 6\n assert candidate(nums = [1, 1, 1, 2, 2, 3]) == 3\n assert candidate(nums = [10, 20, 20, 10, 30, 30, 30]) == 3\n assert candidate(nums = [5, 5, 5, 5, 5]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [7, 7, 7, 7, 7]) == 5\n assert candidate(nums = [1, 2, 3, 3, 3, 4, 4, 4, 4]) == 4\n assert candidate(nums = [1, 1]) == 2\n assert candidate(nums = [7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9]) == 6\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3]) == 9\n assert candidate(nums = [31, 31, 31, 31, 32, 32, 32, 32, 33, 33, 34, 34, 34, 35, 35, 35, 35]) == 12\n assert candidate(nums = [2, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 7]) == 5\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 4\n assert candidate(nums = [32, 32, 33, 33, 33, 34, 34, 34, 34, 35, 35, 35, 35, 35, 35, 35, 35, 35]) == 9\n assert candidate(nums = [7, 8, 8, 9, 9, 9, 10, 10, 10, 10, 10]) == 5\n assert candidate(nums = [7, 7, 7, 8, 8, 9, 9, 10, 10, 10, 10]) == 4\n assert candidate(nums = [11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 19]) == 4\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4]) == 8\n assert candidate(nums = [99, 99, 99, 99, 98, 98, 98, 97, 97, 96, 96, 95, 95, 95, 95, 95, 95, 95, 95, 95]) == 9\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5]) == 8\n assert candidate(nums = [2, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6]) == 8\n assert candidate(nums = [1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9]) == 30\n assert candidate(nums = [17, 17, 18, 18, 18, 19, 19, 20, 20, 20, 20, 20, 20]) == 6\n assert candidate(nums = [6, 6, 6, 6, 7, 7, 7, 8, 8, 9]) == 4\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5]) == 5\n assert candidate(nums = [3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 18\n assert candidate(nums = [21, 21, 21, 22, 22, 22, 22, 23, 23, 23, 23, 23, 24, 24, 24, 25, 25, 25, 25]) == 5\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 4\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9]) == 27\n assert candidate(nums = [7, 7, 7, 7, 8, 8, 8, 9, 9, 10]) == 4\n assert candidate(nums = [6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 10]) == 4\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6]) == 7\n assert candidate(nums = [6, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 10]) == 5\n assert candidate(nums = [10, 20, 20, 30, 30, 30, 40, 40, 40, 40, 50, 50, 50, 50, 50]) == 5\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 4\n assert candidate(nums = [6, 6, 6, 6, 6, 7, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 11, 11]) == 5\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5]) == 7\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6]) == 8\n assert candidate(nums = [7, 7, 8, 8, 9, 9, 9, 10, 10, 10, 10]) == 4\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4]) == 4\n assert candidate(nums = [6, 6, 6, 7, 7, 8, 8, 8, 9, 9, 10, 10]) == 6\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 5, 5, 6, 6, 6, 7, 7, 8, 8, 8, 9, 9, 9, 9, 9]) == 5\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 99, 99, 98, 98, 97, 97, 96, 96, 95, 95, 94, 94, 93, 93, 92, 92, 91, 91]) == 6\n assert candidate(nums = [25, 26, 27, 28, 29, 29, 30, 30, 30, 30, 31, 31, 31, 31, 31, 31, 31]) == 7\n assert candidate(nums = [10, 20, 20, 30, 30, 30, 40, 40, 40, 40]) == 4\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 9\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 10\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8]) == 25\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 20\n assert candidate(nums = [36, 36, 36, 37, 37, 37, 37, 38, 38, 38, 38, 38, 39, 39, 39, 39, 39, 39, 39, 39, 39]) == 9\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 10\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 16\n assert candidate(nums = [1, 2, 3, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 21\n assert candidate(nums = [7, 7, 7, 7, 8, 8, 8, 9, 9, 9, 9, 9, 10]) == 5\n assert candidate(nums = [2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == 12\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4]) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 5, 5, 5, 5, 5, 5]) == 6\n assert candidate(nums = [6, 6, 6, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == 12\n assert candidate(nums = [36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 36, 37, 38, 39]) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 5, 5, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == 15\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5]) == 12\n assert candidate(nums = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 20\n assert candidate(nums = [6, 6, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9]) == 10\n assert candidate(nums = [30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 35, 36, 36, 36, 37, 37, 37, 37, 38, 38, 39]) == 4\n assert candidate(nums = [10, 20, 20, 30, 30, 30, 40, 40, 40, 40, 50, 50, 50, 50, 50, 60, 60, 60, 60, 60]) == 10\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 9\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]) == 6\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14]) == 28\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 41\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7]) == 6\n assert candidate(nums = [50, 50, 51, 51, 52, 52, 53, 53, 54, 54, 55, 55, 56, 56, 57, 57, 58, 58, 59, 59, 60, 60, 60, 60]) == 4\n assert candidate(nums = [7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9]) == 5\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5]) == 7\n assert candidate(nums = [21, 21, 22, 22, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24]) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 16\n assert candidate(nums = [10, 20, 20, 30, 30, 30, 40, 40, 40, 40, 50, 50, 50, 50, 50, 60, 60, 60, 60, 60, 60, 70, 70, 70, 70, 70, 70, 70]) == 7\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 9\n assert candidate(nums = [11, 12, 12, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 15]) == 5\n assert candidate(nums = [6, 6, 6, 6, 7, 7, 8, 8, 8, 9, 9, 9, 10]) == 4\n assert candidate(nums = [10, 10, 20, 20, 20, 30, 30, 30, 30, 40, 40, 40, 40, 40]) == 5\n assert candidate(nums = [14, 15, 14, 15, 14, 15, 16, 16, 16, 17, 18, 18, 18, 19, 19, 19, 19]) == 4\n assert candidate(nums = [31, 31, 31, 31, 32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 34, 34, 35, 35, 35, 35]) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 20\n assert candidate(nums = [7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10]) == 12\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 5, 5, 6, 6, 6, 7, 8, 8, 8, 8]) == 8\n assert candidate(nums = [9, 9, 9, 9, 9, 8, 8, 8, 8, 7, 7, 7, 6, 6, 5, 4, 3, 2, 1]) == 5\n assert candidate(nums = [10, 20, 20, 30, 30, 30, 30, 40, 40, 40, 40]) == 8\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8]) == 6\n assert candidate(nums = [7, 7, 7, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10]) == 8\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5]) == 4\n assert candidate(nums = [21, 21, 21, 22, 22, 23, 23, 23, 23, 24, 24, 24, 24, 25, 25, 25, 25, 25]) == 5\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9]) == 8\n assert candidate(nums = [41, 41, 41, 42, 42, 42, 42, 43, 43, 44, 44, 44, 44, 45, 45, 45, 45, 45]) == 5\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 10, 10, 10, 10]) == 12\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 5]) == 8\n assert candidate(nums = [40, 40, 40, 41, 41, 41, 42, 42, 42, 42, 43, 43, 44, 44, 44, 45, 45, 45, 46, 46, 47, 47, 47, 47]) == 8\n assert candidate(nums = [11, 12, 13, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16]) == 5\n assert candidate(nums = [7, 7, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10]) == 8\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == 10\n assert candidate(nums = [6, 6, 6, 6, 7, 7, 7, 8, 8, 9, 9, 10, 11, 12, 12, 12, 13, 13, 13, 13]) == 8\n assert candidate(nums = [10, 10, 10, 20, 20, 30, 30, 30, 40, 40, 40, 40]) == 4\n assert candidate(nums = [26, 27, 28, 29, 30, 26, 27, 28, 29, 30, 26, 27, 28, 29, 30, 26, 27, 28, 29]) == 16\n assert candidate(nums = [51, 51, 52, 52, 52, 53, 53, 53, 53, 54, 54, 54, 54, 55, 55, 55, 55, 55, 55]) == 6\n assert candidate(nums = [40, 41, 42, 42, 43, 43, 43, 44, 44, 44, 44, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45]) == 10\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 4]) == 4\n assert candidate(nums = [61, 61, 61, 61, 62, 62, 62, 62, 62, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 64]) == 7\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maxFrequencyElements", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxFrequencyElements(vector& nums) {", "container": "Solution", "callable": "maxFrequencyElements", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3006, "task_id": "find-beautiful-indices-in-the-given-array-i", "difficulty": "Medium", "problem_description": "You are given a 0-indexed string s, a string a, a string b, and an integer k.\nAn index i is beautiful if:\n\n0 <= i <= s.length - a.length\ns[i..(i + a.length - 1)] == a\nThere exists an index j such that:\n\t\n0 <= j <= s.length - b.length\ns[j..(j + b.length - 1)] == b\n|j - i| <= k\n\n\n\nReturn the array that contains beautiful indices in sorted order from smallest to largest.\n \nExample 1:\n\nInput: s = \"isawsquirrelnearmysquirrelhouseohmy\", a = \"my\", b = \"squirrel\", k = 15\nOutput: [16,33]\nExplanation: There are 2 beautiful indices: [16,33].\n- The index 16 is beautiful as s[16..17] == \"my\" and there exists an index 4 with s[4..11] == \"squirrel\" and |16 - 4| <= 15.\n- The index 33 is beautiful as s[33..34] == \"my\" and there exists an index 18 with s[18..25] == \"squirrel\" and |33 - 18| <= 15.\nThus we return [16,33] as the result.\n\nExample 2:\n\nInput: s = \"abcd\", a = \"a\", b = \"a\", k = 4\nOutput: [0]\nExplanation: There is 1 beautiful index: [0].\n- The index 0 is beautiful as s[0..0] == \"a\" and there exists an index 0 with s[0..0] == \"a\" and |0 - 0| <= 4.\nThus we return [0] as the result.\n\n \nConstraints:\n\n1 <= k <= s.length <= 105\n1 <= a.length, b.length <= 10\ns, a, and b contain only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"beautifulbeautifulbeautiful\",a = \"ful\",b = \"aut\",k = 5) == [6, 15, 24]\n assert candidate(s = \"hellobeautifulworld\",a = \"be\",b = \"autiful\",k = 5) == [5]\n assert candidate(s = \"beautifulbeautifulbeautiful\",a = \"ful\",b = \"uti\",k = 5) == [6, 15, 24]\n assert candidate(s = \"hellohellohello\",a = \"he\",b = \"lo\",k = 3) == [0, 5, 10]\n assert candidate(s = \"beautifulday\",a = \"day\",b = \"beat\",k = 10) == []\n assert candidate(s = \"abababab\",a = \"ab\",b = \"ba\",k = 2) == [0, 2, 4, 6]\n assert candidate(s = \"abcabcabcabc\",a = \"ab\",b = \"bc\",k = 3) == [0, 3, 6, 9]\n assert candidate(s = \"hellohellohello\",a = \"he\",b = \"lo\",k = 2) == [5, 10]\n assert candidate(s = \"abcd\",a = \"a\",b = \"a\",k = 4) == [0]\n assert candidate(s = \"aaaaaa\",a = \"aa\",b = \"aaa\",k = 2) == [0, 1, 2, 3, 4]\n assert candidate(s = \"isawsquirrelnearmysquirrelhouseohmy\",a = \"my\",b = \"squirrel\",k = 15) == [16, 33]\n assert candidate(s = \"abababab\",a = \"ab\",b = \"ba\",k = 1) == [0, 2, 4, 6]\n assert candidate(s = \"hellotherehello\",a = \"he\",b = \"lo\",k = 5) == [0, 6, 10]\n assert candidate(s = \"teststringteststring\",a = \"test\",b = \"ing\",k = 10) == [0, 10]\n assert candidate(s = \"abcabcabcabc\",a = \"abc\",b = \"cab\",k = 3) == [0, 3, 6, 9]\n assert candidate(s = \"beautifulbeautiful\",a = \"ful\",b = \"uti\",k = 5) == [6, 15]\n assert candidate(s = \"hellobeautifulworld\",a = \"bea\",b = \"ful\",k = 7) == [5]\n assert candidate(s = \"overlappingoverlappingoverlapping\",a = \"over\",b = \"lapping\",k = 10) == [0, 11, 22]\n assert candidate(s = \"overlappingoverlappingoverlapping\",a = \"over\",b = \"lap\",k = 5) == [0, 11, 22]\n assert candidate(s = \"randomstringwithrandomstringinside\",a = \"random\",b = \"inside\",k = 25) == [16]\n assert candidate(s = \"qwertyuiopqwertyuiop\",a = \"erty\",b = \"rtyu\",k = 8) == [2, 12]\n assert candidate(s = \"abababababab\",a = \"aba\",b = \"bab\",k = 2) == [0, 2, 4, 6, 8]\n assert candidate(s = \"repeatedwordrepeatedwordrepeated\",a = \"word\",b = \"repeated\",k = 10) == [8, 20]\n assert candidate(s = \"xyxxyxyxyxyxxyxyxyxy\",a = \"xy\",b = \"yx\",k = 4) == [0, 3, 5, 7, 9, 12, 14, 16, 18]\n assert candidate(s = \"mississippi\",a = \"iss\",b = \"sis\",k = 3) == [1, 4]\n assert candidate(s = \"uniquestringswithvariouslengthsandcharacters\",a = \"strings\",b = \"length\",k = 25) == [6]\n assert candidate(s = \"longestsubstringhereandthere\",a = \"long\",b = \"here\",k = 12) == []\n assert candidate(s = \"bananaananabanana\",a = \"ana\",b = \"nan\",k = 4) == [1, 3, 6, 8, 12, 14]\n assert candidate(s = \"mississippi\",a = \"issi\",b = \"sip\",k = 4) == [4]\n assert candidate(s = \"aaaaaabaaaaaabaaaaaabaaaaaabaaaaaabaaaaaabaaaaaab\",a = \"aa\",b = \"bb\",k = 5) == []\n assert candidate(s = \"xylophonexylophonexylophone\",a = \"xylo\",b = \"phone\",k = 7) == [0, 9, 18]\n assert candidate(s = \"mississippi\",a = \"issi\",b = \"issi\",k = 3) == [1, 4]\n assert candidate(s = \"mississippi\",a = \"issi\",b = \"issi\",k = 2) == [1, 4]\n assert candidate(s = \"xyzxyzxyzxyzxyzxyzxyzxyz\",a = \"xyz\",b = \"zyx\",k = 2) == []\n assert candidate(s = \"racecaracecaracecar\",a = \"ace\",b = \"cec\",k = 7) == [1, 7, 13]\n assert candidate(s = \"abababababababa\",a = \"aba\",b = \"bab\",k = 3) == [0, 2, 4, 6, 8, 10, 12]\n assert candidate(s = \"overlappingoverlappingoverlapping\",a = \"lapping\",b = \"over\",k = 10) == [4, 15, 26]\n assert candidate(s = \"thelongestwordinenglishdictionary\",a = \"word\",b = \"english\",k = 15) == [10]\n assert candidate(s = \"repeatthisstringmanytimesrepeatthisstringmanytimes\",a = \"this\",b = \"many\",k = 25) == [6, 31]\n assert candidate(s = \"bananaananabanana\",a = \"ana\",b = \"nana\",k = 6) == [1, 3, 6, 8, 12, 14]\n assert candidate(s = \"alibabaibabaibaba\",a = \"ali\",b = \"iba\",k = 5) == [0]\n assert candidate(s = \"bananaananabananananabanana\",a = \"ana\",b = \"nana\",k = 5) == [1, 3, 6, 8, 12, 14, 16, 18, 22, 24]\n assert candidate(s = \"overlappingstringsoverlapping\",a = \"lap\",b = \"ing\",k = 10) == [4, 22]\n assert candidate(s = \"squirrelmysquirrelhouseohmysquirrel\",a = \"squirrel\",b = \"house\",k = 20) == [0, 10, 27]\n assert candidate(s = \"thisisaverylongstringthatcontainsmultipleinstancesofthesamepattern\",a = \"this\",b = \"that\",k = 25) == [0]\n assert candidate(s = \"abcdefgabcdefgabcdefg\",a = \"abc\",b = \"defg\",k = 15) == [0, 7, 14]\n assert candidate(s = \"abababababababababab\",a = \"aba\",b = \"bab\",k = 5) == [0, 2, 4, 6, 8, 10, 12, 14, 16]\n assert candidate(s = \"xyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy\",a = \"xy\",b = \"yx\",k = 2) == [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]\n assert candidate(s = \"abababababababababababababababababab\",a = \"aba\",b = \"bab\",k = 2) == [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",a = \"abc\",b = \"xyz\",k = 20) == []\n assert candidate(s = \"complexexamplecomplexexample\",a = \"complex\",b = \"exam\",k = 15) == [0, 14]\n assert candidate(s = \"fuzzywuzzy\",a = \"fuz\",b = \"uzz\",k = 3) == [0]\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",a = \"zzz\",b = \"zzz\",k = 2) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]\n assert candidate(s = \"findingbeautifulindices\",a = \"find\",b = \"ind\",k = 7) == [0]\n assert candidate(s = \"aaaaaaabaaaaaa\",a = \"aa\",b = \"aaa\",k = 5) == [0, 1, 2, 3, 4, 5, 8, 9, 10, 11, 12]\n assert candidate(s = \"repeatedsubstringsarecool\",a = \"are\",b = \"cool\",k = 10) == [18]\n assert candidate(s = \"longstringwithmultipleoccurrencesofaandb\",a = \"multiple\",b = \"occurrences\",k = 30) == [14]\n assert candidate(s = \"overlappingoverlapping\",a = \"over\",b = \"lap\",k = 8) == [0, 11]\n assert candidate(s = \"repeatedpatternsrepeatedpatternsrepeatedpatterns\",a = \"repeated\",b = \"patterns\",k = 20) == [0, 16, 32]\n assert candidate(s = \"mississippiissiisipiissipississippi\",a = \"issi\",b = \"ippi\",k = 10) == [1, 4, 11, 25, 28]\n assert candidate(s = \"ababababababababababababababababa\",a = \"aba\",b = \"bab\",k = 4) == [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]\n assert candidate(s = \"mississippiississippiississippi\",a = \"issi\",b = \"miss\",k = 12) == [1, 4, 11]\n assert candidate(s = \"xyxyxyxyxyxy\",a = \"xyx\",b = \"yxy\",k = 4) == [0, 2, 4, 6, 8]\n assert candidate(s = \"abcdefghijabcdefghij\",a = \"def\",b = \"ghi\",k = 10) == [3, 13]\n assert candidate(s = \"mississippi\",a = \"iss\",b = \"issi\",k = 4) == [1, 4]\n assert candidate(s = \"onetwothreefourfivesixseveneightnine\",a = \"one\",b = \"two\",k = 5) == [0]\n assert candidate(s = \"aaaaaaaaaabaaaaaaaaaabaaaaaaaaaab\",a = \"aaaaaa\",b = \"aaab\",k = 15) == [0, 1, 2, 3, 4, 11, 12, 13, 14, 15, 22, 23, 24, 25, 26]\n assert candidate(s = \"programmingisfun\",a = \"fun\",b = \"ing\",k = 10) == [13]\n assert candidate(s = \"abracadabra\",a = \"abr\",b = \"cad\",k = 8) == [0, 7]\n assert candidate(s = \"abcdefghijabcdefghijabcdefghij\",a = \"cdef\",b = \"ghij\",k = 5) == [2, 12, 22]\n assert candidate(s = \"repeatedrepeatedrepeated\",a = \"peat\",b = \"peat\",k = 3) == [2, 10, 18]\n assert candidate(s = \"abcdefabcdefabcdefabcdefabcdef\",a = \"cdef\",b = \"ab\",k = 8) == [2, 8, 14, 20, 26]\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",a = \"zzz\",b = \"zz\",k = 1) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]\n assert candidate(s = \"abcdefghijabcdefghijabcdefghij\",a = \"abc\",b = \"efg\",k = 15) == [0, 10, 20]\n assert candidate(s = \"abcdefghijabcdefghij\",a = \"abc\",b = \"efg\",k = 12) == [0, 10]\n assert candidate(s = \"thisisaverylongstringwithaverylongsubstring\",a = \"very\",b = \"long\",k = 20) == [7, 26]\n assert candidate(s = \"squirrelmysquirrelhouse\",a = \"my\",b = \"squirrel\",k = 10) == [8]\n assert candidate(s = \"bananaananabananananana\",a = \"ana\",b = \"nan\",k = 5) == [1, 3, 6, 8, 12, 14, 16, 18, 20]\n assert candidate(s = \"mississippi\",a = \"iss\",b = \"sip\",k = 4) == [4]\n assert candidate(s = \"abababababab\",a = \"aba\",b = \"bab\",k = 3) == [0, 2, 4, 6, 8]\n assert candidate(s = \"beautifulbeautifulbeautifulbeautiful\",a = \"bea\",b = \"ful\",k = 15) == [0, 9, 18, 27]\n assert candidate(s = \"thisisaverylongstringwithrepeatedsubstringsandlongoccurrencesofpatterns\",a = \"long\",b = \"pattern\",k = 30) == [46]\n assert candidate(s = \"beautifuldaybeautifulday\",a = \"day\",b = \"beau\",k = 12) == [9, 21]\n assert candidate(s = \"xyzxyzxyzxyzxyzxyzxyzxyzxyzxyz\",a = \"xyz\",b = \"yzx\",k = 2) == [0, 3, 6, 9, 12, 15, 18, 21, 24, 27]\n assert candidate(s = \"thisisaverylongstringwithmultiplesubstrings\",a = \"very\",b = \"string\",k = 20) == [7]\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",a = \"zz\",b = \"zzz\",k = 5) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]\n assert candidate(s = \"xyxyxyxyxyxyxyxyxyxy\",a = \"xy\",b = \"yx\",k = 3) == [0, 2, 4, 6, 8, 10, 12, 14, 16, 18]\n assert candidate(s = \"aaaaabaaaabaaaaaaaba\",a = \"aa\",b = \"aaa\",k = 5) == [0, 1, 2, 3, 6, 7, 8, 11, 12, 13, 14, 15, 16]\n assert candidate(s = \"abcdefghijabcdefghijabcdefghij\",a = \"abc\",b = \"efg\",k = 8) == [0, 10, 20]\n assert candidate(s = \"repeatedrepeatedrepeated\",a = \"repe\",b = \"ated\",k = 6) == [0, 8, 16]\n assert candidate(s = \"racecar\",a = \"race\",b = \"car\",k = 5) == [0]\n assert candidate(s = \"thisissomereallylongstringwithsomerepetitions\",a = \"some\",b = \"long\",k = 15) == [6, 30]\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",a = \"abc\",b = \"xyz\",k = 10) == []\n assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcdefghij\",a = \"ghi\",b = \"def\",k = 8) == [6, 16, 26, 36]\n assert candidate(s = \"quickbrownfoxjumpsoverthelazydog\",a = \"quick\",b = \"lazy\",k = 20) == []\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",a = \"mnop\",b = \"qrst\",k = 10) == [12]\n assert candidate(s = \"onetwothreefourfivesixseveneightnine\",a = \"two\",b = \"nine\",k = 20) == []\n assert candidate(s = \"thisisaverylongstringwithmultiplesubstrings\",a = \"very\",b = \"string\",k = 10) == [7]\n assert candidate(s = \"complexstringwithmultipleoccurrences\",a = \"with\",b = \"occurrences\",k = 28) == [13]\n assert candidate(s = \"patternmatchingexamplepatternmatchingexamplepatternmatchingexample\",a = \"example\",b = \"pattern\",k = 50) == [15, 37, 59]\n assert candidate(s = \"aaabbbcccaaa\",a = \"aaa\",b = \"bbb\",k = 5) == [0]\n assert candidate(s = \"thisisaverylongstringfortesting\",a = \"very\",b = \"long\",k = 12) == [7]\n assert candidate(s = \"bananaananabay\",a = \"ana\",b = \"nana\",k = 4) == [1, 3, 6, 8]\n assert candidate(s = \"abababababababababab\",a = \"aba\",b = \"bab\",k = 2) == [0, 2, 4, 6, 8, 10, 12, 14, 16]\n assert candidate(s = \"bananaananabananananabanana\",a = \"ana\",b = \"nan\",k = 5) == [1, 3, 6, 8, 12, 14, 16, 18, 22, 24]\n assert candidate(s = \"thisissomethingreallylongthatshouldtestthelimits\",a = \"test\",b = \"limits\",k = 25) == [35]\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmqwertyuiop\",a = \"qwerty\",b = \"poi\",k = 15) == []\n assert candidate(s = \"bananaananabanana\",a = \"ana\",b = \"na\",k = 5) == [1, 3, 6, 8, 12, 14]\n assert candidate(s = \"abcdefghijabcdefghijabcdefghij\",a = \"def\",b = \"ghi\",k = 10) == [3, 13, 23]\n assert candidate(s = \"thisisaverylongstringwithmultiplesubstrings\",a = \"long\",b = \"string\",k = 10) == [11]\n assert candidate(s = \"qwertyuiopqwertyuiopqwertyuiop\",a = \"qwerty\",b = \"uiop\",k = 6) == [0, 10, 20]\n assert candidate(s = \"mississippi\",a = \"issi\",b = \"iss\",k = 5) == [1, 4]\n assert candidate(s = \"aabbccddeeffgghhiijjkk\",a = \"abc\",b = \"def\",k = 10) == []\n assert candidate(s = \"abababababababababab\",a = \"aba\",b = \"bab\",k = 4) == [0, 2, 4, 6, 8, 10, 12, 14, 16]\n assert candidate(s = \"pneumonoultramicroscopicsilicovolcanoconiosis\",a = \"micro\",b = \"scopic\",k = 30) == [13]\n"}, "metadata": {"canonical_parameter_names": ["s", "a", "b", "k"], "leetcode_dataset_entry_point": "Solution().beautifulIndices", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector beautifulIndices(string s, string a, string b, int k) {", "container": "Solution", "callable": "beautifulIndices", "parameters": [{"name": "s", "type": "string"}, {"name": "a", "type": "string"}, {"name": "b", "type": "string"}, {"name": "k", "type": "int"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3007, "task_id": "maximum-number-that-sum-of-the-prices-is-less-than-or-equal-to-k", "difficulty": "Medium", "problem_description": "You are given an integer k and an integer x. The price of a number num is calculated by the count of set bits at positions x, 2x, 3x, etc., in its binary representation, starting from the least significant bit. The following table contains examples of how price is calculated.\n\n\n\nx\nnum\nBinary Representation\nPrice\n\n\n1\n13\n000001101\n3\n\n\n2\n13\n000001101\n1\n\n\n2\n233\n011101001\n3\n\n\n3\n13\n000001101\n1\n\n\n3\n362\n101101010\n2\n\n\n\nThe accumulated price of num is the total price of numbers from 1 to num. num is considered cheap if its accumulated price is less than or equal to k.\nReturn the greatest cheap number.\n \nExample 1:\n\nInput: k = 9, x = 1\nOutput: 6\nExplanation:\nAs shown in the table below, 6 is the greatest cheap number.\n\n\n\nx\nnum\nBinary Representation\nPrice\nAccumulated Price\n\n\n1\n1\n001\n1\n1\n\n\n1\n2\n010\n1\n2\n\n\n1\n3\n011\n2\n4\n\n\n1\n4\n100\n1\n5\n\n\n1\n5\n101\n2\n7\n\n\n1\n6\n110\n2\n9\n\n\n1\n7\n111\n3\n12\n\n\n\n\nExample 2:\n\nInput: k = 7, x = 2\nOutput: 9\nExplanation:\nAs shown in the table below, 9 is the greatest cheap number.\n\n\n\nx\nnum\nBinary Representation\nPrice\nAccumulated Price\n\n\n2\n1\n0001\n0\n0\n\n\n2\n2\n0010\n1\n1\n\n\n2\n3\n0011\n1\n2\n\n\n2\n4\n0100\n0\n2\n\n\n2\n5\n0101\n0\n2\n\n\n2\n6\n0110\n1\n3\n\n\n2\n7\n0111\n1\n4\n\n\n2\n8\n1000\n1\n5\n\n\n2\n9\n1001\n1\n6\n\n\n2\n10\n1010\n2\n8\n\n\n\n\n \nConstraints:\n\n1 <= k <= 1015\n1 <= x <= 8\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(k = 15,x = 1) == 9\n assert candidate(k = 5,x = 2) == 8\n assert candidate(k = 100000000000000,x = 8) == 40104798005951\n assert candidate(k = 500,x = 6) == 1011\n assert candidate(k = 20,x = 2) == 23\n assert candidate(k = 5,x = 1) == 4\n assert candidate(k = 15,x = 4) == 30\n assert candidate(k = 7,x = 2) == 9\n assert candidate(k = 100,x = 4) == 153\n assert candidate(k = 15,x = 3) == 30\n assert candidate(k = 10,x = 3) == 21\n assert candidate(k = 9,x = 1) == 6\n assert candidate(k = 1000,x = 7) == 2023\n assert candidate(k = 1000,x = 6) == 2023\n assert candidate(k = 1000000000000000,x = 8) == 343778878348159\n assert candidate(k = 100,x = 5) == 211\n assert candidate(k = 1000000,x = 8) == 1016223\n assert candidate(k = 9876543210,x = 2) == 1335770905\n assert candidate(k = 75000000000000,x = 5) == 18535653792058\n assert candidate(k = 1000000,x = 2) == 229535\n assert candidate(k = 37500000000000,x = 6) == 11028437048759\n assert candidate(k = 8,x = 8) == 135\n assert candidate(k = 200000000000000,x = 4) == 36505448274943\n assert candidate(k = 1000,x = 8) == 2023\n assert candidate(k = 987654321,x = 5) == 396332511\n assert candidate(k = 65536,x = 2) == 19343\n assert candidate(k = 123456789,x = 7) == 82565716\n assert candidate(k = 987654321,x = 3) == 225159917\n assert candidate(k = 500,x = 4) == 505\n assert candidate(k = 876543210,x = 4) == 252864144\n assert candidate(k = 300,x = 2) == 174\n assert candidate(k = 75,x = 7) == 202\n assert candidate(k = 987654321,x = 7) == 502583375\n assert candidate(k = 10000,x = 5) == 10079\n assert candidate(k = 67890,x = 4) == 40389\n assert candidate(k = 888888888,x = 1) == 68597981\n assert candidate(k = 750,x = 6) == 1517\n assert candidate(k = 89,x = 4) == 144\n assert candidate(k = 512,x = 5) == 687\n assert candidate(k = 25000,x = 4) == 16839\n assert candidate(k = 100000000000000,x = 1) == 4779296144709\n assert candidate(k = 1000000000000,x = 2) == 112964310932\n assert candidate(k = 50,x = 5) == 113\n assert candidate(k = 999999999999999,x = 6) == 253657567778409\n assert candidate(k = 150000000000000,x = 4) == 27972811528487\n assert candidate(k = 500000000,x = 5) == 200231279\n assert candidate(k = 3000000000,x = 7) == 1522191359\n assert candidate(k = 1000000,x = 4) == 505131\n assert candidate(k = 1000,x = 3) == 751\n assert candidate(k = 1023,x = 1) == 254\n assert candidate(k = 456789123456789,x = 5) == 101944274868895\n assert candidate(k = 111111111111111,x = 7) == 37402810498266\n assert candidate(k = 500000000000000,x = 2) == 44975429102831\n assert candidate(k = 123456789012345,x = 7) == 41467248081098\n assert candidate(k = 35791,x = 6) == 36150\n assert candidate(k = 99999999999999,x = 8) == 40104798005950\n assert candidate(k = 50000000000000,x = 7) == 16799267244329\n assert candidate(k = 50,x = 1) == 22\n assert candidate(k = 1000000000000000,x = 7) == 320446066360319\n assert candidate(k = 500,x = 5) == 675\n assert candidate(k = 100000000000000,x = 5) == 23566547569891\n assert candidate(k = 86420,x = 1) == 12978\n assert candidate(k = 1000000,x = 1) == 120205\n assert candidate(k = 9375000000000,x = 8) == 3858234249087\n assert candidate(k = 125,x = 8) == 252\n assert candidate(k = 5000,x = 6) == 5927\n assert candidate(k = 200,x = 5) == 407\n assert candidate(k = 12345678912345,x = 7) == 4155872352796\n assert candidate(k = 50,x = 2) == 41\n assert candidate(k = 500000000000000,x = 6) == 142592321015807\n assert candidate(k = 1000000000,x = 6) == 500668855\n assert candidate(k = 2,x = 1) == 2\n assert candidate(k = 897654321000,x = 3) == 151072975789\n assert candidate(k = 123456789,x = 2) == 20934568\n assert candidate(k = 87654321098765,x = 5) == 21067518135670\n assert candidate(k = 150,x = 5) == 309\n assert candidate(k = 1000000000,x = 5) == 400458607\n assert candidate(k = 7777777777777,x = 8) == 3142572550626\n assert candidate(k = 1024,x = 6) == 2047\n assert candidate(k = 100000000,x = 7) == 66778015\n assert candidate(k = 500,x = 3) == 379\n assert candidate(k = 500000000000000,x = 8) == 183136759108959\n assert candidate(k = 999999999999999,x = 8) == 343778878348158\n assert candidate(k = 8000000000000,x = 6) == 2550830257769\n assert candidate(k = 1000,x = 2) == 504\n assert candidate(k = 500,x = 7) == 1011\n assert candidate(k = 1000000,x = 7) == 1000639\n assert candidate(k = 64,x = 4) == 127\n assert candidate(k = 999999999999999,x = 7) == 320446066360318\n assert candidate(k = 987654321,x = 2) == 150736664\n assert candidate(k = 300000000000000,x = 3) == 40423774188390\n assert candidate(k = 25,x = 6) == 56\n assert candidate(k = 99999999999999,x = 1) == 4779296144709\n assert candidate(k = 256,x = 3) == 255\n assert candidate(k = 1000000,x = 3) == 350061\n assert candidate(k = 128,x = 2) == 95\n assert candidate(k = 333333333333333,x = 5) == 74563043705932\n assert candidate(k = 200,x = 6) == 423\n assert candidate(k = 1000000000000000,x = 1) == 44470852534271\n assert candidate(k = 123456789012345,x = 2) == 11594690512161\n assert candidate(k = 10000000000000,x = 2) == 1010190497191\n assert candidate(k = 97531,x = 7) == 97788\n assert candidate(k = 2048,x = 7) == 4159\n assert candidate(k = 800000000000000,x = 1) == 35598682963967\n assert candidate(k = 987654321,x = 4) == 284658738\n assert candidate(k = 75319,x = 8) == 85174\n assert candidate(k = 43210,x = 2) == 12987\n assert candidate(k = 250000000,x = 8) == 166950655\n assert candidate(k = 24680,x = 5) == 20551\n assert candidate(k = 1,x = 1) == 1\n assert candidate(k = 123456789,x = 5) == 52351833\n assert candidate(k = 4096,x = 8) == 8319\n assert candidate(k = 1000000,x = 5) == 611931\n assert candidate(k = 1000000,x = 6) == 696703\n assert candidate(k = 100,x = 3) == 109\n assert candidate(k = 10,x = 8) == 137\n assert candidate(k = 12345,x = 3) == 6589\n assert candidate(k = 123456789,x = 3) == 31193134\n assert candidate(k = 1,x = 8) == 128\n assert candidate(k = 123456789,x = 6) == 62823067\n assert candidate(k = 2000000000,x = 6) == 846978196\n assert candidate(k = 23,x = 3) == 36\n assert candidate(k = 2147483647,x = 7) == 1073741822\n assert candidate(k = 30,x = 3) == 41\n assert candidate(k = 18750000000000,x = 7) == 6615951850383\n assert candidate(k = 75,x = 1) == 30\n"}, "metadata": {"canonical_parameter_names": ["k", "x"], "leetcode_dataset_entry_point": "Solution().findMaximumNumber", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "long long findMaximumNumber(long long k, int x) {", "container": "Solution", "callable": "findMaximumNumber", "parameters": [{"name": "k", "type": "long long"}, {"name": "x", "type": "int"}], "return_type": "long long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3008, "task_id": "find-beautiful-indices-in-the-given-array-ii", "difficulty": "Hard", "problem_description": "You are given a 0-indexed string s, a string a, a string b, and an integer k.\nAn index i is beautiful if:\n\n0 <= i <= s.length - a.length\ns[i..(i + a.length - 1)] == a\nThere exists an index j such that:\n\t\n0 <= j <= s.length - b.length\ns[j..(j + b.length - 1)] == b\n|j - i| <= k\n\n\n\nReturn the array that contains beautiful indices in sorted order from smallest to largest.\n \nExample 1:\n\nInput: s = \"isawsquirrelnearmysquirrelhouseohmy\", a = \"my\", b = \"squirrel\", k = 15\nOutput: [16,33]\nExplanation: There are 2 beautiful indices: [16,33].\n- The index 16 is beautiful as s[16..17] == \"my\" and there exists an index 4 with s[4..11] == \"squirrel\" and |16 - 4| <= 15.\n- The index 33 is beautiful as s[33..34] == \"my\" and there exists an index 18 with s[18..25] == \"squirrel\" and |33 - 18| <= 15.\nThus we return [16,33] as the result.\n\nExample 2:\n\nInput: s = \"abcd\", a = \"a\", b = \"a\", k = 4\nOutput: [0]\nExplanation: There is 1 beautiful index: [0].\n- The index 0 is beautiful as s[0..0] == \"a\" and there exists an index 0 with s[0..0] == \"a\" and |0 - 0| <= 4.\nThus we return [0] as the result.\n\n \nConstraints:\n\n1 <= k <= s.length <= 5 * 105\n1 <= a.length, b.length <= 5 * 105\ns, a, and b contain only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"beautifulbeautifulbeautiful\",a = \"ful\",b = \"uti\",k = 5) == [6, 15, 24]\n assert candidate(s = \"abcabcabcabcabc\",a = \"abc\",b = \"bca\",k = 3) == [0, 3, 6, 9, 12]\n assert candidate(s = \"mississippi\",a = \"issi\",b = \"ippi\",k = 4) == [4]\n assert candidate(s = \"abcabcabc\",a = \"abc\",b = \"cab\",k = 3) == [0, 3, 6]\n assert candidate(s = \"abcabcabc\",a = \"abc\",b = \"cab\",k = 2) == [0, 3, 6]\n assert candidate(s = \"aaaaaaa\",a = \"aa\",b = \"aa\",k = 2) == [0, 1, 2, 3, 4, 5]\n assert candidate(s = \"beautifuldayinbeautifultown\",a = \"day\",b = \"town\",k = 10) == []\n assert candidate(s = \"hellohellohello\",a = \"he\",b = \"lo\",k = 2) == [5, 10]\n assert candidate(s = \"abcd\",a = \"a\",b = \"a\",k = 4) == [0]\n assert candidate(s = \"isawsquirrelnearmysquirrelhouseohmy\",a = \"my\",b = \"squirrel\",k = 15) == [16, 33]\n assert candidate(s = \"hellobeautifulworld\",a = \"bea\",b = \"ful\",k = 5) == []\n assert candidate(s = \"ababababa\",a = \"aba\",b = \"bab\",k = 2) == [0, 2, 4, 6]\n assert candidate(s = \"hellohellohello\",a = \"he\",b = \"lo\",k = 5) == [0, 5, 10]\n assert candidate(s = \"bananaananabananaba\",a = \"ana\",b = \"nana\",k = 3) == [1, 3, 6, 8, 12, 14]\n assert candidate(s = \"babababababababababa\",a = \"aba\",b = \"bab\",k = 2) == [1, 3, 5, 7, 9, 11, 13, 15, 17]\n assert candidate(s = \"sequenceofcharacters\",a = \"que\",b = \"nce\",k = 4) == [2]\n assert candidate(s = \"abababababab\",a = \"aba\",b = \"bab\",k = 2) == [0, 2, 4, 6, 8]\n assert candidate(s = \"mississippimississippi\",a = \"issi\",b = \"ippi\",k = 6) == [1, 4, 12, 15]\n assert candidate(s = \"mississippi\",a = \"issi\",b = \"issip\",k = 5) == [1, 4]\n assert candidate(s = \"zzzzzzzzzzzzzzz\",a = \"zzz\",b = \"zzz\",k = 3) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n assert candidate(s = \"qwertyuiopqwertyuiop\",a = \"qwerty\",b = \"uiop\",k = 4) == [10]\n assert candidate(s = \"xyxxyxyxyxyxyxyxyx\",a = \"xy\",b = \"yx\",k = 4) == [0, 3, 5, 7, 9, 11, 13, 15]\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzz\",a = \"zzz\",b = \"zzzz\",k = 5) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]\n assert candidate(s = \"abcdefgabcdefgabcdefgabcdefgabcdefg\",a = \"abc\",b = \"def\",k = 12) == [0, 7, 14, 21, 28]\n assert candidate(s = \"repeatedrepeatedrepeated\",a = \"pea\",b = \"eat\",k = 6) == [2, 10, 18]\n assert candidate(s = \"ababababababababab\",a = \"aba\",b = \"bab\",k = 1) == [0, 2, 4, 6, 8, 10, 12, 14]\n assert candidate(s = \"qwertyuiopqwertyuiopqwertyuiop\",a = \"qwerty\",b = \"uiop\",k = 15) == [0, 10, 20]\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",a = \"zzz\",b = \"zzz\",k = 250000) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49]\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnm\",a = \"erty\",b = \"ghjk\",k = 10) == []\n assert candidate(s = \"abcdefghijabcdefghijabcdefghij\",a = \"def\",b = \"jabcdefghi\",k = 12) == [3, 13, 23]\n assert candidate(s = \"bananaananabayana\",a = \"ana\",b = \"anaba\",k = 6) == [3, 6, 8, 14]\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",a = \"mnop\",b = \"qrst\",k = 10) == []\n assert candidate(s = \"longstringwithrepeatedpatternsandpatterns\",a = \"pattern\",b = \"patterns\",k = 10) == [22, 33]\n assert candidate(s = \"mississippi\",a = \"iss\",b = \"sis\",k = 4) == [1, 4]\n assert candidate(s = \"bananaananabananabanana\",a = \"ana\",b = \"anana\",k = 5) == [1, 3, 6, 8, 12, 14, 18, 20]\n assert candidate(s = \"qwertyuiopqwertyuiop\",a = \"rty\",b = \"tyu\",k = 6) == [3, 13]\n assert candidate(s = \"xyzyzyzyzyzyzyz\",a = \"zyz\",b = \"yzy\",k = 4) == [2, 4, 6, 8, 10, 12]\n assert candidate(s = \"thisisaverylongstringwithvariouswords\",a = \"word\",b = \"words\",k = 20) == [32]\n assert candidate(s = \"zzzzzzzzzzzzzzzzz\",a = \"zzz\",b = \"zzz\",k = 1) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(s = \"xyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy\",a = \"xyxy\",b = \"yxyx\",k = 6) == [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50]\n assert candidate(s = \"xyzzxyzzxyzzxyzz\",a = \"zz\",b = \"xy\",k = 4) == [2, 6, 10, 14]\n assert candidate(s = \"abababababababa\",a = \"aba\",b = \"bab\",k = 5) == [0, 2, 4, 6, 8, 10, 12]\n assert candidate(s = \"abcdabcdabcdabcd\",a = \"abcd\",b = \"dcba\",k = 8) == []\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmqwertyuiop\",a = \"asdf\",b = \"ghjk\",k = 10) == [10]\n assert candidate(s = \"lkjsdhflksjdhflksjdhflksjdhf\",a = \"ksj\",b = \"jdh\",k = 10) == [8, 15, 22]\n assert candidate(s = \"thisisaverylongstringwithmultiplesubstrings\",a = \"string\",b = \"multiplesubstrings\",k = 20) == [15, 36]\n assert candidate(s = \"abcdefghijabcdefghijabcdefghij\",a = \"ghi\",b = \"def\",k = 3) == [6, 16, 26]\n assert candidate(s = \"abababababababababababababababababababababababababab\",a = \"abab\",b = \"baba\",k = 5) == [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48]\n assert candidate(s = \"qwertyuiopqwertyuiopqwertyuiop\",a = \"qwe\",b = \"rty\",k = 5) == [0, 10, 20]\n assert candidate(s = \"mississippi\",a = \"issi\",b = \"ippi\",k = 5) == [4]\n assert candidate(s = \"bananaananabananana\",a = \"ana\",b = \"nana\",k = 7) == [1, 3, 6, 8, 12, 14, 16]\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",a = \"abc\",b = \"xyz\",k = 20) == []\n assert candidate(s = \"hellohellohellohello\",a = \"llo\",b = \"hel\",k = 7) == [2, 7, 12, 17]\n assert candidate(s = \"bananaananabananabanana\",a = \"ana\",b = \"nan\",k = 5) == [1, 3, 6, 8, 12, 14, 18, 20]\n assert candidate(s = \"repeatedrepeatedrepeated\",a = \"repeated\",b = \"atedrepe\",k = 9) == [0, 8, 16]\n assert candidate(s = \"mississippi\",a = \"iss\",b = \"sip\",k = 5) == [1, 4]\n assert candidate(s = \"aabbccddeeffgghhiijj\",a = \"abcd\",b = \"bcde\",k = 4) == []\n assert candidate(s = \"mississippi\",a = \"iss\",b = \"sis\",k = 2) == [1, 4]\n assert candidate(s = \"patternpatternpatternpattern\",a = \"pattern\",b = \"ternpat\",k = 15) == [0, 7, 14, 21]\n assert candidate(s = \"abcdefghijabcdefghij\",a = \"abc\",b = \"def\",k = 10) == [0, 10]\n assert candidate(s = \"mississippiississipi\",a = \"iss\",b = \"issi\",k = 4) == [1, 4, 11, 14]\n assert candidate(s = \"abacabadabacaba\",a = \"aba\",b = \"aca\",k = 8) == [0, 4, 8, 12]\n assert candidate(s = \"ababababababababab\",a = \"aba\",b = \"bab\",k = 6) == [0, 2, 4, 6, 8, 10, 12, 14]\n assert candidate(s = \"xyzxyzxyzxyzxyzxyz\",a = \"xyz\",b = \"zyx\",k = 5) == []\n assert candidate(s = \"ababababababababab\",a = \"aba\",b = \"bab\",k = 5) == [0, 2, 4, 6, 8, 10, 12, 14]\n assert candidate(s = \"bananaananabanananananabanana\",a = \"ana\",b = \"nana\",k = 8) == [1, 3, 6, 8, 12, 14, 16, 18, 20, 24, 26]\n assert candidate(s = \"overlappingoverlapping\",a = \"over\",b = \"lap\",k = 5) == [0, 11]\n assert candidate(s = \"banana\",a = \"ana\",b = \"nan\",k = 2) == [1, 3]\n assert candidate(s = \"longstringwithsubstring\",a = \"with\",b = \"subs\",k = 10) == [10]\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",a = \"xyz\",b = \"uvw\",k = 3) == [23]\n assert candidate(s = \"mississippi\",a = \"iss\",b = \"issi\",k = 3) == [1, 4]\n assert candidate(s = \"aaaaabbbbbbbcccccc\",a = \"bbbb\",b = \"cccc\",k = 6) == [6, 7, 8]\n assert candidate(s = \"abcdefghijabcdefghij\",a = \"efgh\",b = \"ghij\",k = 5) == [4, 14]\n assert candidate(s = \"repeatedpatternrepeatedpattern\",a = \"repe\",b = \"atte\",k = 8) == [15]\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",a = \"mnopqr\",b = \"ghijkl\",k = 15) == [12, 38]\n assert candidate(s = \"abracadabraabracadabra\",a = \"abra\",b = \"cad\",k = 5) == [0, 7, 11, 18]\n assert candidate(s = \"foobarfoobarfoobar\",a = \"foo\",b = \"bar\",k = 6) == [0, 6, 12]\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",a = \"def\",b = \"xyz\",k = 15) == []\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",a = \"zz\",b = \"zz\",k = 1) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]\n assert candidate(s = \"hellohellohellohello\",a = \"hel\",b = \"ell\",k = 4) == [0, 5, 10, 15]\n assert candidate(s = \"complexstringwithmultipleoverlaps\",a = \"over\",b = \"overlap\",k = 12) == [25]\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",a = \"zzz\",b = \"zzzz\",k = 3) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]\n assert candidate(s = \"abracadabraabracadabra\",a = \"cad\",b = \"bra\",k = 8) == [4, 15]\n assert candidate(s = \"xyxyxyxyxyxyxyxyxyxyxy\",a = \"xyx\",b = \"yxy\",k = 3) == [0, 2, 4, 6, 8, 10, 12, 14, 16, 18]\n assert candidate(s = \"abcdefghijabcdefghij\",a = \"def\",b = \"ghi\",k = 8) == [3, 13]\n assert candidate(s = \"bananaananabanana\",a = \"ana\",b = \"naa\",k = 7) == [1, 3, 6, 8]\n assert candidate(s = \"racecaracecaracecaracecar\",a = \"ace\",b = \"cec\",k = 4) == [1, 7, 13, 19]\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnm\",a = \"qwerty\",b = \"zxcvbn\",k = 10) == [26]\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcd\",a = \"abc\",b = \"bcd\",k = 1) == [0, 4, 8, 12, 16, 20, 24]\n assert candidate(s = \"abcdefghijabcdefghij\",a = \"abc\",b = \"cde\",k = 10) == [0, 10]\n assert candidate(s = \"mississippi\",a = \"issi\",b = \"issip\",k = 2) == [4]\n assert candidate(s = \"xyzxyzxyzxyzxyzxyz\",a = \"xyz\",b = \"zyx\",k = 4) == []\n assert candidate(s = \"repeatedrepeatedrepeatedrepeated\",a = \"repeated\",b = \"eatedr\",k = 18) == [0, 8, 16, 24]\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\",a = \"abcabc\",b = \"bcabca\",k = 12) == [0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42]\n assert candidate(s = \"xyxyxyxyxyxyxyxyxy\",a = \"xyxy\",b = \"xyxyxy\",k = 8) == [0, 2, 4, 6, 8, 10, 12, 14]\n assert candidate(s = \"abababababababab\",a = \"ab\",b = \"ba\",k = 2) == [0, 2, 4, 6, 8, 10, 12, 14]\n assert candidate(s = \"abababababab\",a = \"aba\",b = \"bab\",k = 5) == [0, 2, 4, 6, 8]\n assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcdefghij\",a = \"cde\",b = \"efg\",k = 5) == [2, 12, 22, 32]\n assert candidate(s = \"abcdefgabcdefgabcdefg\",a = \"def\",b = \"abc\",k = 10) == [3, 10, 17]\n assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\",a = \"ghij\",b = \"efgh\",k = 20) == [6, 16, 26, 36, 46]\n assert candidate(s = \"hellohellohello\",a = \"hello\",b = \"ohell\",k = 6) == [0, 5, 10]\n assert candidate(s = \"aabbccddeeffaabbccddeeff\",a = \"abb\",b = \"bbc\",k = 2) == [1, 13]\n assert candidate(s = \"ababababababababab\",a = \"aba\",b = \"bab\",k = 4) == [0, 2, 4, 6, 8, 10, 12, 14]\n assert candidate(s = \"abcdefghijabcdefghijabcdefghij\",a = \"def\",b = \"ghi\",k = 3) == [3, 13, 23]\n assert candidate(s = \"repeatedsubstringrepeatedsubstring\",a = \"substring\",b = \"substr\",k = 15) == [8, 25]\n assert candidate(s = \"abcabcabcabcabcabc\",a = \"abc\",b = \"abcabc\",k = 5) == [0, 3, 6, 9, 12, 15]\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmqwerty\",a = \"erty\",b = \"asdf\",k = 10) == [2]\n assert candidate(s = \"abcdefghijabcdefghijabcdefghij\",a = \"abc\",b = \"efg\",k = 10) == [0, 10, 20]\n assert candidate(s = \"abacabadabacaba\",a = \"aba\",b = \"aca\",k = 5) == [0, 4, 8, 12]\n assert candidate(s = \"hellohellohellohellohellohellohello\",a = \"hello\",b = \"elloh\",k = 20) == [0, 5, 10, 15, 20, 25, 30]\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\",a = \"abc\",b = \"cab\",k = 2) == [0, 3, 6, 9, 12, 15, 18, 21, 24, 27]\n assert candidate(s = \"mississippiississippiississippiississippiississippi\",a = \"issi\",b = \"issip\",k = 15) == [1, 4, 11, 14, 21, 24, 31, 34, 41, 44]\n assert candidate(s = \"hellohellohellohello\",a = \"hello\",b = \"lohel\",k = 7) == [0, 5, 10, 15]\n assert candidate(s = \"hellohellohellohello\",a = \"ell\",b = \"ell\",k = 2) == [1, 6, 11, 16]\n assert candidate(s = \"abcdefghijabcdefghijabcdefghij\",a = \"abc\",b = \"ghi\",k = 7) == [0, 10, 20]\n assert candidate(s = \"thisisaverylongstringwithmanywords\",a = \"very\",b = \"with\",k = 15) == [7]\n assert candidate(s = \"hellohellohellohello\",a = \"hello\",b = \"hello\",k = 0) == [0, 5, 10, 15]\n assert candidate(s = \"mississippiississippi\",a = \"issi\",b = \"ippi\",k = 10) == [1, 4, 11, 14]\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",a = \"zzz\",b = \"zzzz\",k = 8) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]\n assert candidate(s = \"bananaanananabanananabanananabanananabananana\",a = \"anan\",b = \"nana\",k = 8) == [1, 6, 8, 14, 16, 22, 24, 30, 32, 38, 40]\n assert candidate(s = \"xyxxyxyxyxxyxyxyxyxyxy\",a = \"xyx\",b = \"xyxy\",k = 4) == [0, 3, 5, 7, 10, 12, 14, 16, 18]\n assert candidate(s = \"abcdefghijabcdefghijabcdefghij\",a = \"abc\",b = \"ghi\",k = 5) == [10, 20]\n"}, "metadata": {"canonical_parameter_names": ["s", "a", "b", "k"], "leetcode_dataset_entry_point": "Solution().beautifulIndices", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector beautifulIndices(string s, string a, string b, int k) {", "container": "Solution", "callable": "beautifulIndices", "parameters": [{"name": "s", "type": "string"}, {"name": "a", "type": "string"}, {"name": "b", "type": "string"}, {"name": "k", "type": "int"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3010, "task_id": "divide-an-array-into-subarrays-with-minimum-cost-i", "difficulty": "Easy", "problem_description": "You are given an array of integers nums of length n.\nThe cost of an array is the value of its first element. For example, the cost of [1,2,3] is 1 while the cost of [3,4,1] is 3.\nYou need to divide nums into 3 disjoint contiguous subarrays.\nReturn the minimum possible sum of the cost of these subarrays.\n \nExample 1:\n\nInput: nums = [1,2,3,12]\nOutput: 6\nExplanation: The best possible way to form 3 subarrays is: [1], [2], and [3,12] at a total cost of 1 + 2 + 3 = 6.\nThe other possible ways to form 3 subarrays are:\n- [1], [2,3], and [12] at a total cost of 1 + 2 + 12 = 15.\n- [1,2], [3], and [12] at a total cost of 1 + 3 + 12 = 16.\n\nExample 2:\n\nInput: nums = [5,4,3]\nOutput: 12\nExplanation: The best possible way to form 3 subarrays is: [5], [4], and [3] at a total cost of 5 + 4 + 3 = 12.\nIt can be shown that 12 is the minimum cost achievable.\n\nExample 3:\n\nInput: nums = [10,3,1,1]\nOutput: 12\nExplanation: The best possible way to form 3 subarrays is: [10,3], [1], and [1] at a total cost of 10 + 1 + 1 = 12.\nIt can be shown that 12 is the minimum cost achievable.\n\n \nConstraints:\n\n3 <= n <= 50\n1 <= nums[i] <= 50\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [30, 20, 10, 40, 50]) == 60\n assert candidate(nums = [50, 49, 48, 47, 46, 45]) == 141\n assert candidate(nums = [5, 4, 3]) == 12\n assert candidate(nums = [40, 30, 20, 10, 5]) == 55\n assert candidate(nums = [50, 1, 50, 1, 50]) == 52\n assert candidate(nums = [4, 5, 2, 3, 1, 6]) == 7\n assert candidate(nums = [3, 1, 2, 4, 5]) == 6\n assert candidate(nums = [1, 5, 2, 4, 3]) == 6\n assert candidate(nums = [10, 3, 1, 1]) == 12\n assert candidate(nums = [10, 20, 30, 40, 50]) == 60\n assert candidate(nums = [5, 1, 4, 2, 3]) == 8\n assert candidate(nums = [2, 1, 4, 3, 5]) == 6\n assert candidate(nums = [40, 30, 20, 10, 50]) == 70\n assert candidate(nums = [30, 20, 10, 50, 40]) == 60\n assert candidate(nums = [1, 2, 3, 12]) == 6\n assert candidate(nums = [1, 3, 2, 5, 4]) == 6\n assert candidate(nums = [15, 20, 10, 25, 30]) == 45\n assert candidate(nums = [3, 1, 2, 2, 5]) == 6\n assert candidate(nums = [20, 10, 30, 5, 45]) == 35\n assert candidate(nums = [3, 3, 3, 3, 3]) == 9\n assert candidate(nums = [1, 50, 2, 49, 3]) == 6\n assert candidate(nums = [15, 25, 35, 5, 10]) == 30\n assert candidate(nums = [30, 10, 20, 5, 25, 40, 15]) == 45\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 6\n assert candidate(nums = [50, 25, 10, 5, 1, 2, 3, 4]) == 53\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 600\n assert candidate(nums = [5, 1, 9, 2, 8, 3, 7, 4, 6]) == 8\n assert candidate(nums = [30, 20, 10, 5, 1, 2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 24, 25, 26, 27, 28, 29]) == 33\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 6\n assert candidate(nums = [50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 53\n assert candidate(nums = [4, 3, 2, 1, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40]) == 7\n assert candidate(nums = [20, 15, 10, 5, 1, 2, 3, 4]) == 23\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 18\n assert candidate(nums = [5, 1, 4, 2, 8, 3]) == 8\n assert candidate(nums = [30, 20, 10, 5, 15, 25, 35, 40, 45, 50]) == 45\n assert candidate(nums = [10, 20, 30, 40, 50, 1, 2, 3, 4, 5]) == 13\n assert candidate(nums = [45, 40, 35, 30, 25, 20, 15, 10, 5]) == 60\n assert candidate(nums = [15, 10, 5, 3, 8, 2, 7]) == 20\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7, 9, 5, 0, 2, 8, 8, 4, 1, 9, 7, 1, 6, 9, 3, 9, 9, 3, 7, 5, 1, 0]) == 3\n assert candidate(nums = [15, 3, 18, 6, 7, 9, 2]) == 20\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, 13, 14]) == 13\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 30\n assert candidate(nums = [4, 2, 9, 1, 7, 3, 5]) == 7\n assert candidate(nums = [30, 25, 20, 15, 10, 5, 4, 3, 2, 1, 100, 200, 300]) == 33\n assert candidate(nums = [2, 3, 1, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 6\n assert candidate(nums = [1, 49, 2, 48, 3, 47, 4, 46, 5, 45, 6, 44, 7, 43, 8, 42, 9, 41, 10, 40, 11, 39, 12, 38, 13, 37, 14, 36, 15, 35]) == 6\n assert candidate(nums = [45, 30, 15, 5, 1, 50, 40, 35, 25, 20]) == 51\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 3\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40]) == 131\n assert candidate(nums = [50, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 53\n assert candidate(nums = [3, 2, 1, 50, 49, 48, 47, 46, 45]) == 6\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 3\n assert candidate(nums = [30, 10, 20, 5, 25, 40, 15, 50, 2, 1]) == 33\n assert candidate(nums = [23, 12, 7, 3, 1, 8, 4, 9, 5, 10, 6, 11]) == 27\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 43, 36, 29, 22]) == 42\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 53\n assert candidate(nums = [40, 30, 20, 10, 5, 15, 25, 35, 45, 50, 60, 70, 80]) == 55\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == 6\n assert candidate(nums = [5, 1, 3, 2, 4, 6, 8, 7, 9, 11]) == 8\n assert candidate(nums = [45, 21, 32, 18, 9, 40, 35]) == 72\n assert candidate(nums = [45, 20, 10, 5, 15, 25, 35, 40]) == 60\n assert candidate(nums = [1, 50, 2, 49, 3, 48, 4, 47, 5, 46, 6, 45, 7, 44, 8]) == 6\n assert candidate(nums = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 15, 14, 13, 12, 11]) == 8\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 3\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 45\n assert candidate(nums = [49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 52\n assert candidate(nums = [42, 28, 36, 12, 45, 50, 10, 20, 30]) == 64\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 50]) == 13\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15]) == 61\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 15\n assert candidate(nums = [5, 2, 1, 3, 8, 7, 6]) == 8\n assert candidate(nums = [30, 10, 20, 30, 10, 20, 30]) == 50\n assert candidate(nums = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 28\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 6\n assert candidate(nums = [30, 20, 10, 40, 50, 60, 70]) == 60\n assert candidate(nums = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50]) == 30\n assert candidate(nums = [1, 3, 5, 2, 4, 6, 8, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 6\n assert candidate(nums = [34, 12, 45, 37, 26, 48, 22, 39, 14, 47]) == 60\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 13\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 9\n assert candidate(nums = [20, 30, 10, 40, 50, 15, 25, 35, 45, 5]) == 35\n assert candidate(nums = [42, 15, 22, 7, 31, 19, 9]) == 58\n assert candidate(nums = [20, 15, 10, 5, 1, 6, 11, 16, 21]) == 26\n assert candidate(nums = [50, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 53\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 6\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 60\n assert candidate(nums = [50, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]) == 53\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 5\n assert candidate(nums = [7, 3, 1, 6, 2, 5, 4, 8, 9, 10]) == 10\n assert candidate(nums = [25, 10, 5, 20, 15, 30, 25, 10, 5, 20, 15]) == 35\n assert candidate(nums = [42, 31, 23, 17, 8, 4, 5, 13, 29, 38, 11]) == 51\n assert candidate(nums = [25, 50, 15, 40, 10, 30, 20, 25, 35]) == 50\n assert candidate(nums = [23, 19, 17, 29, 25, 31, 13, 11, 15, 21]) == 47\n assert candidate(nums = [15, 10, 20, 5, 30, 25]) == 30\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 12\n assert candidate(nums = [1, 10, 3, 8, 2, 5, 4]) == 6\n assert candidate(nums = [47, 42, 37, 32, 27, 22, 17, 12, 7, 2, 49, 44, 39, 34, 29, 24, 19, 14, 9, 4, 1, 3, 8, 13, 18, 23, 28, 33, 38, 43, 48]) == 50\n assert candidate(nums = [8, 2, 6, 4, 7, 1, 3, 5]) == 11\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1]) == 12\n assert candidate(nums = [15, 25, 35, 10, 5, 45, 40, 30, 20]) == 30\n assert candidate(nums = [45, 1, 42, 2, 44, 3, 43]) == 48\n assert candidate(nums = [25, 10, 5, 1, 9, 3, 8, 12]) == 29\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 50, 49, 48]) == 18\n assert candidate(nums = [45, 15, 25, 35, 5, 10, 55]) == 60\n assert candidate(nums = [25, 5, 15, 10, 30, 20, 40, 50, 35]) == 40\n assert candidate(nums = [10, 20, 30, 40, 50, 1, 2, 3, 4, 5]) == 13\n assert candidate(nums = [49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20]) == 90\n assert candidate(nums = [23, 15, 34, 10, 5, 40, 30, 20, 1, 2, 3]) == 26\n assert candidate(nums = [49, 1, 48, 2, 47, 3, 46, 4, 45, 5]) == 52\n assert candidate(nums = [5, 9, 12, 1, 6, 3, 7, 8, 4, 10, 2, 11]) == 8\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49]) == 15\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 50]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 6\n assert candidate(nums = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]) == 24\n assert candidate(nums = [5, 4, 3, 2, 1, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31]) == 8\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minimumCost", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumCost(vector& nums) {", "container": "Solution", "callable": "minimumCost", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3011, "task_id": "find-if-array-can-be-sorted", "difficulty": "Medium", "problem_description": "You are given a 0-indexed array of positive integers nums.\nIn one operation, you can swap any two adjacent elements if they have the same number of set bits. You are allowed to do this operation any number of times (including zero).\nReturn true if you can sort the array in ascending order, else return false.\n \nExample 1:\n\nInput: nums = [8,4,2,30,15]\nOutput: true\nExplanation: Let's look at the binary representation of every element. The numbers 2, 4, and 8 have one set bit each with binary representation \"10\", \"100\", and \"1000\" respectively. The numbers 15 and 30 have four set bits each with binary representation \"1111\" and \"11110\".\nWe can sort the array using 4 operations:\n- Swap nums[0] with nums[1]. This operation is valid because 8 and 4 have one set bit each. The array becomes [4,8,2,30,15].\n- Swap nums[1] with nums[2]. This operation is valid because 8 and 2 have one set bit each. The array becomes [4,2,8,30,15].\n- Swap nums[0] with nums[1]. This operation is valid because 4 and 2 have one set bit each. The array becomes [2,4,8,30,15].\n- Swap nums[3] with nums[4]. This operation is valid because 30 and 15 have four set bits each. The array becomes [2,4,8,15,30].\nThe array has become sorted, hence we return true.\nNote that there may be other sequences of operations which also sort the array.\n\nExample 2:\n\nInput: nums = [1,2,3,4,5]\nOutput: true\nExplanation: The array is already sorted, hence we return true.\n\nExample 3:\n\nInput: nums = [3,16,8,4,2]\nOutput: false\nExplanation: It can be shown that it is not possible to sort the input array using any number of operations.\n\n \nConstraints:\n\n1 <= nums.length <= 100\n1 <= nums[i] <= 28\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 3, 2, 7, 6, 5, 4, 8]) == False\n assert candidate(nums = [31, 14, 7, 3, 1]) == False\n assert candidate(nums = [5, 3, 1, 4, 2]) == False\n assert candidate(nums = [5, 3, 9, 6, 12]) == True\n assert candidate(nums = [4, 4, 4, 4, 4]) == True\n assert candidate(nums = [8, 4, 2, 30, 15]) == True\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1]) == False\n assert candidate(nums = [30, 30, 30, 30, 30]) == True\n assert candidate(nums = [8, 8, 8, 8, 8]) == True\n assert candidate(nums = [16, 8, 4, 2, 32, 1]) == True\n assert candidate(nums = [1, 2, 3, 4, 5]) == True\n assert candidate(nums = [2, 1, 4, 3, 8, 6]) == False\n assert candidate(nums = [28, 14, 7, 3, 1, 2, 4, 8, 16]) == False\n assert candidate(nums = [2, 1, 4, 3, 8, 7, 6, 5]) == False\n assert candidate(nums = [16, 8, 4, 2, 1]) == True\n assert candidate(nums = [5, 3, 9, 6, 12, 4, 8]) == False\n assert candidate(nums = [7, 14, 28, 21, 18]) == False\n assert candidate(nums = [15, 30, 60, 120, 240]) == True\n assert candidate(nums = [2, 2, 2, 2, 2, 2]) == True\n assert candidate(nums = [1, 1, 1, 1, 1]) == True\n assert candidate(nums = [5, 3, 6, 8, 2]) == False\n assert candidate(nums = [2, 4, 8, 16, 32]) == True\n assert candidate(nums = [10, 12, 15, 7, 3]) == False\n assert candidate(nums = [31, 29, 28, 27, 26]) == False\n assert candidate(nums = [3, 16, 8, 4, 2]) == False\n assert candidate(nums = [4, 2, 1, 3, 8, 6]) == False\n assert candidate(nums = [31, 15, 7, 3, 1]) == False\n assert candidate(nums = [31, 15, 7, 3, 1, 2, 4, 8, 16]) == False\n assert candidate(nums = [16, 8, 4, 2, 30, 15]) == False\n assert candidate(nums = [28, 14, 7, 3, 1, 14, 28]) == False\n assert candidate(nums = [2, 2, 2, 2, 2]) == True\n assert candidate(nums = [2, 1, 4, 3, 6, 5, 8, 7]) == False\n assert candidate(nums = [15, 15, 15, 15, 15]) == True\n assert candidate(nums = [29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == False\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == True\n assert candidate(nums = [5, 3, 9, 6, 12, 10, 14, 7, 11]) == False\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == True\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == True\n assert candidate(nums = [128, 64, 32, 16, 8, 4, 2, 1, 3, 5, 7, 14, 28, 56, 112]) == False\n assert candidate(nums = [2, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == True\n assert candidate(nums = [10, 13, 11, 14, 15, 7, 8, 12]) == False\n assert candidate(nums = [31, 23, 15, 7, 3, 1, 127, 63, 31, 15, 7, 3, 1]) == False\n assert candidate(nums = [255, 127, 63, 31, 15, 7, 3, 1, 2, 4, 8, 16, 32, 64, 128, 256]) == False\n assert candidate(nums = [15, 30, 21, 28, 7, 14, 3, 6, 12, 24]) == False\n assert candidate(nums = [255, 254, 253, 252, 251, 250, 249, 248, 247, 246]) == False\n assert candidate(nums = [17, 25, 29, 31, 30, 14, 6, 3, 1, 2]) == False\n assert candidate(nums = [255, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == False\n assert candidate(nums = [1, 3, 7, 15, 31, 30, 14, 7, 3, 1, 2, 4, 8, 16, 32]) == False\n assert candidate(nums = [13, 11, 7, 3, 15, 30, 60, 120, 240, 480, 960, 1920, 3840, 7680]) == False\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == False\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == True\n assert candidate(nums = [3, 6, 12, 9, 15, 30, 60, 5, 10]) == False\n assert candidate(nums = [512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15]) == False\n assert candidate(nums = [127, 63, 31, 15, 7, 3, 1, 2, 4, 8, 16, 32, 64, 128]) == False\n assert candidate(nums = [10, 9, 5, 6, 2, 3, 1]) == False\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192]) == True\n assert candidate(nums = [32, 16, 8, 4, 2, 1, 30, 15, 7, 14, 28, 12, 6, 3]) == False\n assert candidate(nums = [5, 3, 6, 12, 24, 48, 96, 192, 3, 6, 12]) == True\n assert candidate(nums = [28, 14, 7, 3, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == True\n assert candidate(nums = [24, 12, 6, 3, 1, 48, 24, 12, 6, 3, 1, 96, 48, 24, 12, 6, 3, 1]) == False\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == True\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]) == True\n assert candidate(nums = [3, 5, 6, 9, 10, 12, 15, 17, 18, 20, 24, 25, 30, 33, 36, 40, 45, 48, 50, 60, 66, 72, 75, 80, 90, 100]) == True\n assert candidate(nums = [8, 16, 2, 4, 1, 32, 64, 128, 256, 512]) == True\n assert candidate(nums = [5, 3, 9, 6, 10, 12, 15]) == True\n assert candidate(nums = [14, 7, 28, 21, 3, 6, 12, 24, 48, 96, 192, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == False\n assert candidate(nums = [25, 10, 5, 3, 1, 2, 4, 8, 16, 32, 64]) == False\n assert candidate(nums = [21, 21, 14, 14, 7, 7, 3, 3, 15, 15, 30, 30, 60, 60, 120, 120, 240, 240]) == False\n assert candidate(nums = [18, 9, 4, 2, 1, 3, 6, 12, 24, 48, 96, 192]) == False\n assert candidate(nums = [1, 16, 2, 8, 32, 4, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == True\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 1, 2, 4, 8, 16, 32, 64]) == True\n assert candidate(nums = [15, 30, 18, 21, 7, 14, 28]) == False\n assert candidate(nums = [31, 15, 7, 3, 1, 2, 4, 8, 16, 32]) == False\n assert candidate(nums = [13, 10, 9, 6, 3, 2, 4, 8, 16]) == False\n assert candidate(nums = [30, 15, 8, 4, 2, 1]) == False\n assert candidate(nums = [64, 32, 16, 8, 4, 2, 1]) == True\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512]) == True\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112]) == True\n assert candidate(nums = [127, 125, 123, 121, 119, 117, 115, 113, 111, 109, 107, 105, 103, 101, 99, 97, 95, 93, 91, 89, 87, 85, 83, 81, 79, 77, 75, 73, 71, 69, 67, 65, 63, 61, 59, 57, 55, 53, 51, 49, 47, 45, 43, 41, 39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == False\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == True\n assert candidate(nums = [15, 30, 1, 2, 4, 8]) == False\n assert candidate(nums = [17, 34, 68, 136, 272, 544, 1088, 2176, 4352, 8704, 17408, 34816]) == True\n assert candidate(nums = [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]) == True\n assert candidate(nums = [255, 254, 252, 248, 240, 224, 192, 128, 64, 32, 16, 8, 4, 2, 1]) == False\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == True\n assert candidate(nums = [31, 15, 7, 3, 1, 30, 28, 14, 6, 2]) == False\n assert candidate(nums = [5, 3, 9, 12, 6, 15, 7]) == False\n assert candidate(nums = [16, 32, 8, 4, 2, 1, 128, 64, 15, 30, 21, 28, 7, 14, 3, 6, 12, 24]) == False\n assert candidate(nums = [13, 11, 7, 3, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == False\n assert candidate(nums = [12, 5, 6, 3, 9, 18, 36, 45]) == True\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135, 144]) == True\n assert candidate(nums = [31, 15, 7, 3, 1, 2, 4, 8, 16, 32, 64]) == False\n assert candidate(nums = [5, 3, 1, 12, 4, 6, 18, 9, 15, 30]) == False\n assert candidate(nums = [8, 4, 2, 30, 15, 7, 14, 28, 21, 18]) == False\n assert candidate(nums = [240, 192, 96, 48, 24, 12, 6, 3, 15, 30, 60, 120, 240, 480, 960]) == False\n assert candidate(nums = [5, 3, 11, 7, 13, 9, 14, 10, 6, 2]) == False\n assert candidate(nums = [31, 15, 7, 3, 1, 2, 4, 8, 16, 32, 64, 128, 256]) == False\n assert candidate(nums = [5, 10, 20, 40, 80, 160, 320, 640, 1280, 2560, 5120, 10240, 20480, 40960, 81920]) == True\n assert candidate(nums = [31, 29, 27, 25, 23, 21, 19, 17, 15]) == False\n assert candidate(nums = [18, 28, 21, 7, 14, 3, 6, 12, 24, 48]) == False\n assert candidate(nums = [8, 4, 2, 16, 8, 4, 2, 1, 32, 16]) == True\n assert candidate(nums = [8, 4, 2, 1, 16, 8, 4, 2, 1, 32, 16, 8, 4, 2, 1]) == True\n assert candidate(nums = [5, 2, 9, 6, 17, 12, 34, 21, 27]) == False\n assert candidate(nums = [3, 19, 11, 5, 13, 7, 15, 31, 29, 27, 23, 19, 15, 7, 3]) == False\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == False\n assert candidate(nums = [8, 4, 2, 1, 16, 8, 4, 2, 1]) == True\n assert candidate(nums = [31, 29, 27, 23, 19, 17, 13, 11, 7, 5, 3]) == False\n assert candidate(nums = [28, 24, 20, 16, 12, 8, 4, 2, 14, 10, 6, 30, 26, 22, 18, 31, 15, 7, 11, 19, 27, 23, 3, 1, 5, 9, 13]) == False\n assert candidate(nums = [255, 127, 63, 31, 15, 7, 3, 1, 2, 4, 8, 16, 32, 64, 128]) == False\n assert candidate(nums = [128, 64, 32, 16, 8, 4, 2, 1, 255, 127, 63, 31, 15, 7, 3, 1]) == False\n assert candidate(nums = [6, 3, 5, 9, 12, 10, 15, 30, 1, 2]) == False\n assert candidate(nums = [31, 15, 7, 3, 1, 2, 4, 8, 16, 32, 64, 128, 256]) == False\n assert candidate(nums = [2, 8, 4, 16, 32, 64, 128, 1, 3]) == False\n assert candidate(nums = [15, 7, 14, 28, 21, 3, 6, 12]) == False\n assert candidate(nums = [5, 3, 9, 6, 12, 18, 24, 30, 31, 15, 7, 14]) == False\n assert candidate(nums = [17, 34, 68, 136, 272, 544, 1088, 2176, 4352, 8704]) == True\n assert candidate(nums = [18, 9, 6, 12, 24, 48, 96, 192, 384, 768, 1536, 3072, 6144, 12288]) == True\n assert candidate(nums = [135, 144, 117, 126, 99, 108, 90, 81, 72, 63, 54, 45, 36, 27, 18, 9]) == False\n assert candidate(nums = [10, 6, 5, 3, 2, 4, 8, 16, 32]) == False\n assert candidate(nums = [100, 50, 25, 12, 6, 3, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == False\n assert candidate(nums = [11, 7, 13, 5, 3, 9, 1, 2, 4]) == False\n assert candidate(nums = [5, 3, 12, 9, 18, 30, 24]) == False\n assert candidate(nums = [1, 3, 2, 6, 4, 12, 8, 24, 16, 48, 32, 96, 64, 192, 128, 384]) == False\n assert candidate(nums = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101]) == True\n assert candidate(nums = [128, 64, 32, 16, 8, 4, 2, 1]) == True\n assert candidate(nums = [5, 10, 15, 7, 14, 28, 31, 27, 23, 11, 22, 44, 88, 176, 352]) == False\n assert candidate(nums = [255, 127, 63, 31, 15, 7, 3, 1, 254, 126, 62, 30, 14, 6, 2, 0]) == False\n assert candidate(nums = [3, 5, 7, 9, 11, 13, 15, 31, 30, 29, 27, 25, 23, 21, 19]) == False\n assert candidate(nums = [1, 8, 4, 2, 16, 32, 64, 128, 256]) == True\n assert candidate(nums = [5, 3, 12, 15, 30, 60, 240]) == True\n assert candidate(nums = [63, 55, 47, 39, 31, 23, 15, 7, 3, 1]) == False\n assert candidate(nums = [32, 16, 8, 4, 2, 1, 128, 64, 32, 16, 8, 4, 2, 1]) == True\n assert candidate(nums = [100, 200, 50, 25, 125, 625, 3125, 15625, 78125, 390625]) == False\n assert candidate(nums = [15, 30, 15, 30, 15, 30, 15, 30, 15, 30, 15, 30, 15, 30, 15, 30]) == True\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().canSortArray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool canSortArray(vector& nums) {", "container": "Solution", "callable": "canSortArray", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3012, "task_id": "minimize-length-of-array-using-operations", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums containing positive integers.\nYour task is to minimize the length of nums by performing the following operations any number of times (including zero):\n\nSelect two distinct indices i and j from nums, such that nums[i] > 0 and nums[j] > 0.\nInsert the result of nums[i] % nums[j] at the end of nums.\nDelete the elements at indices i and j from nums.\n\nReturn an integer denoting the minimum length of nums after performing the operation any number of times.\n \nExample 1:\n\nInput: nums = [1,4,3,1]\nOutput: 1\nExplanation: One way to minimize the length of the array is as follows:\nOperation 1: Select indices 2 and 1, insert nums[2] % nums[1] at the end and it becomes [1,4,3,1,3], then delete elements at indices 2 and 1.\nnums becomes [1,1,3].\nOperation 2: Select indices 1 and 2, insert nums[1] % nums[2] at the end and it becomes [1,1,3,1], then delete elements at indices 1 and 2.\nnums becomes [1,1].\nOperation 3: Select indices 1 and 0, insert nums[1] % nums[0] at the end and it becomes [1,1,0], then delete elements at indices 1 and 0.\nnums becomes [0].\nThe length of nums cannot be reduced further. Hence, the answer is 1.\nIt can be shown that 1 is the minimum achievable length. \nExample 2:\n\nInput: nums = [5,5,5,10,5]\nOutput: 2\nExplanation: One way to minimize the length of the array is as follows:\nOperation 1: Select indices 0 and 3, insert nums[0] % nums[3] at the end and it becomes [5,5,5,10,5,5], then delete elements at indices 0 and 3.\nnums becomes [5,5,5,5]. \nOperation 2: Select indices 2 and 3, insert nums[2] % nums[3] at the end and it becomes [5,5,5,5,0], then delete elements at indices 2 and 3. \nnums becomes [5,5,0]. \nOperation 3: Select indices 0 and 1, insert nums[0] % nums[1] at the end and it becomes [5,5,0,0], then delete elements at indices 0 and 1.\nnums becomes [0,0].\nThe length of nums cannot be reduced further. Hence, the answer is 2.\nIt can be shown that 2 is the minimum achievable length. \nExample 3:\n\nInput: nums = [2,3,4]\nOutput: 1\nExplanation: One way to minimize the length of the array is as follows: \nOperation 1: Select indices 1 and 2, insert nums[1] % nums[2] at the end and it becomes [2,3,4,3], then delete elements at indices 1 and 2.\nnums becomes [2,3].\nOperation 2: Select indices 1 and 0, insert nums[1] % nums[0] at the end and it becomes [2,3,1], then delete elements at indices 1 and 0.\nnums becomes [1].\nThe length of nums cannot be reduced further. Hence, the answer is 1.\nIt can be shown that 1 is the minimum achievable length.\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [3, 3, 3, 3, 3, 3]) == 3\n assert candidate(nums = [5, 5, 5, 10, 5]) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 5\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 6\n assert candidate(nums = [3, 9, 27, 81, 243]) == 1\n assert candidate(nums = [7, 7, 7, 7, 7]) == 3\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 5\n assert candidate(nums = [1, 1, 1, 1, 1]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6]) == 1\n assert candidate(nums = [1, 4, 3, 1]) == 1\n assert candidate(nums = [100, 200, 300, 400, 500]) == 1\n assert candidate(nums = [1000000000, 1000000000, 1000000000]) == 2\n assert candidate(nums = [10, 20, 30, 40, 50]) == 1\n assert candidate(nums = [3, 3, 3, 3, 3]) == 3\n assert candidate(nums = [7, 14, 28, 35]) == 1\n assert candidate(nums = [2, 3, 4]) == 1\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 3\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110]) == 1\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 1\n assert candidate(nums = [5, 10, 15, 20, 25, 30]) == 1\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 1\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36]) == 1\n assert candidate(nums = [17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17]) == 10\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110]) == 1\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65]) == 1\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1000]) == 1\n assert candidate(nums = [1000000000, 999999999, 888888888, 777777777, 666666666]) == 1\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 1\n assert candidate(nums = [13, 13, 13, 26, 26, 26, 39, 39, 39, 52, 52, 52, 65, 65, 65]) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]) == 1\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 1\n assert candidate(nums = [17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17]) == 15\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59]) == 1\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9]) == 2\n assert candidate(nums = [7, 21, 35, 49, 63, 77, 91, 105, 119, 133, 147, 161, 175, 189, 203]) == 1\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == 1\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144, 152, 160]) == 1\n assert candidate(nums = [17, 17, 34, 34, 51, 51, 68, 68, 85, 85, 102, 102, 119, 119, 136, 136, 153, 153, 170, 170]) == 1\n assert candidate(nums = [21, 42, 63, 84, 105, 126, 147, 168, 189, 210, 231, 252, 273, 294, 315, 336, 357, 378, 399, 420]) == 1\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]) == 1\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 220]) == 1\n assert candidate(nums = [71, 142, 213, 284, 355, 426, 497, 568, 639, 710]) == 1\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130]) == 1\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 3]) == 2\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42]) == 1\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == 1\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70]) == 1\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169, 182, 195, 208, 221, 234, 247, 260]) == 1\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 220]) == 1\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000]) == 1\n assert candidate(nums = [21, 42, 63, 84, 105, 126, 147, 168, 189, 210]) == 1\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == 1\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 1\n assert candidate(nums = [29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29]) == 15\n assert candidate(nums = [100, 150, 200, 250, 300, 350, 400, 450, 500]) == 1\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010, 1111, 1212, 1313, 1414, 1515]) == 1\n assert candidate(nums = [100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000]) == 1\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 1\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == 1\n assert candidate(nums = [19, 38, 57, 76, 95, 114, 133, 152, 171, 190, 209, 228, 247, 266, 285, 304, 323, 342, 361, 380]) == 1\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == 1\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512]) == 1\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120]) == 1\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65]) == 1\n assert candidate(nums = [12, 15, 18, 21, 24, 27, 30, 33, 36, 39]) == 1\n assert candidate(nums = [19, 38, 57, 76, 95, 114, 133, 152, 171, 190]) == 1\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110]) == 1\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70]) == 1\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 220, 231, 242, 253, 264, 275]) == 1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 1\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165]) == 1\n assert candidate(nums = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 84, 88, 92, 96, 100]) == 1\n assert candidate(nums = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610]) == 1\n assert candidate(nums = [23, 46, 69, 92, 115, 138, 161, 184, 207, 230]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1\n assert candidate(nums = [7, 14, 28, 56, 112, 224, 448]) == 1\n assert candidate(nums = [19, 38, 57, 76, 95, 114, 133, 152, 171, 190, 209, 228]) == 1\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110]) == 1\n assert candidate(nums = [1000000001, 1000000002, 1000000003, 1000000004, 1000000005]) == 1\n assert candidate(nums = [23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 25]) == 1\n assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136, 153, 170]) == 1\n assert candidate(nums = [12, 12, 12, 24, 24, 24, 36, 36, 36, 48, 48, 48, 60, 60, 60, 72, 72, 72, 84, 84, 84]) == 2\n assert candidate(nums = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48]) == 1\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156]) == 1\n assert candidate(nums = [7, 14, 28, 56, 112]) == 1\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143]) == 1\n assert candidate(nums = [7, 7, 7, 7, 14, 14, 14, 14, 28, 28, 28, 28]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 1\n assert candidate(nums = [7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53]) == 1\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 1\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45]) == 1\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]) == 1\n assert candidate(nums = [21, 21, 21, 42, 42, 42, 63, 63, 63, 84, 84, 84, 105, 105, 105, 126, 126, 126]) == 2\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000]) == 1\n assert candidate(nums = [11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13]) == 1\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 1\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169, 182, 195, 208, 221, 234, 247, 260]) == 1\n assert candidate(nums = [1000000000, 2000000000, 3000000000, 4000000000, 5000000000]) == 1\n assert candidate(nums = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1\n assert candidate(nums = [13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15]) == 1\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140]) == 1\n assert candidate(nums = [101, 101, 101, 101, 101, 102, 102, 102, 102, 102, 103, 103, 103, 103, 103]) == 1\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]) == 1\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 1\n assert candidate(nums = [29, 58, 87, 116, 145, 174, 203, 232, 261, 290]) == 1\n assert candidate(nums = [7, 14, 21, 28, 35, 42]) == 1\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 240, 255, 270, 285, 300]) == 1\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135]) == 1\n assert candidate(nums = [41, 82, 123, 164, 205, 246, 287, 328, 369, 410]) == 1\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135, 144, 153, 162]) == 1\n assert candidate(nums = [8, 4, 2, 1, 16, 8, 4, 2, 1, 32, 16, 8, 4, 2, 1]) == 2\n assert candidate(nums = [13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13]) == 8\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205]) == 1\n assert candidate(nums = [23, 46, 69, 92, 115, 138, 161, 184, 207, 230, 253, 276, 299, 322, 345, 368, 391, 414, 437, 460]) == 1\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049, 177147, 531441, 1594323]) == 1\n assert candidate(nums = [17, 17, 17, 34, 34, 34, 51, 51, 51, 68, 68, 68, 85, 85, 85, 102, 102, 102]) == 2\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 1\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96]) == 1\n assert candidate(nums = [19, 38, 57, 76, 95, 114, 133, 152, 171, 190, 209, 228, 247, 266, 285]) == 1\n assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136, 153]) == 1\n assert candidate(nums = [15, 15, 15, 30, 30, 30, 60, 60, 60, 120, 120, 120]) == 2\n assert candidate(nums = [7, 13, 19, 25, 31, 37, 43, 49, 55, 61, 67, 73, 79, 85, 91, 97]) == 1\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049]) == 1\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 1\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010]) == 1\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55]) == 1\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 1\n assert candidate(nums = [8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 1\n assert candidate(nums = [53, 53, 53, 53, 53, 53, 54, 54, 54, 54, 54, 54, 55, 55, 55, 55, 55, 55]) == 1\n assert candidate(nums = [89, 178, 267, 356, 445, 534, 623, 712, 801, 890]) == 1\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minimumArrayLength", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumArrayLength(vector& nums) {", "container": "Solution", "callable": "minimumArrayLength", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3013, "task_id": "divide-an-array-into-subarrays-with-minimum-cost-ii", "difficulty": "Hard", "problem_description": "You are given a 0-indexed array of integers nums of length n, and two positive integers k and dist.\nThe cost of an array is the value of its first element. For example, the cost of [1,2,3] is 1 while the cost of [3,4,1] is 3.\nYou need to divide nums into k disjoint contiguous subarrays, such that the difference between the starting index of the second subarray and the starting index of the kth subarray should be less than or equal to dist. In other words, if you divide nums into the subarrays nums[0..(i1 - 1)], nums[i1..(i2 - 1)], ..., nums[ik-1..(n - 1)], then ik-1 - i1 <= dist.\nReturn the minimum possible sum of the cost of these subarrays.\n \nExample 1:\n\nInput: nums = [1,3,2,6,4,2], k = 3, dist = 3\nOutput: 5\nExplanation: The best possible way to divide nums into 3 subarrays is: [1,3], [2,6,4], and [2]. This choice is valid because ik-1 - i1 is 5 - 2 = 3 which is equal to dist. The total cost is nums[0] + nums[2] + nums[5] which is 1 + 2 + 2 = 5.\nIt can be shown that there is no possible way to divide nums into 3 subarrays at a cost lower than 5.\n\nExample 2:\n\nInput: nums = [10,1,2,2,2,1], k = 4, dist = 3\nOutput: 15\nExplanation: The best possible way to divide nums into 4 subarrays is: [10], [1], [2], and [2,2,1]. This choice is valid because ik-1 - i1 is 3 - 1 = 2 which is less than dist. The total cost is nums[0] + nums[1] + nums[2] + nums[3] which is 10 + 1 + 2 + 2 = 15.\nThe division [10], [1], [2,2,2], and [1] is not valid, because the difference between ik-1 and i1 is 5 - 1 = 4, which is greater than dist.\nIt can be shown that there is no possible way to divide nums into 4 subarrays at a cost lower than 15.\n\nExample 3:\n\nInput: nums = [10,8,18,9], k = 3, dist = 1\nOutput: 36\nExplanation: The best possible way to divide nums into 4 subarrays is: [10], [8], and [18,9]. This choice is valid because ik-1 - i1 is 2 - 1 = 1 which is equal to dist.The total cost is nums[0] + nums[1] + nums[2] which is 10 + 8 + 18 = 36.\nThe division [10], [8,18], and [9] is not valid, because the difference between ik-1 and i1 is 3 - 1 = 2, which is greater than dist.\nIt can be shown that there is no possible way to divide nums into 3 subarrays at a cost lower than 36.\n\n \nConstraints:\n\n3 <= n <= 105\n1 <= nums[i] <= 109\n3 <= k <= n\nk - 2 <= dist <= n - 2\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [7, 8, 9, 10, 5, 6],k = 3,dist = 4) == 18\n assert candidate(nums = [5, 4, 3, 2, 1],k = 2,dist = 2) == 6\n assert candidate(nums = [1, 3, 2, 6, 4, 2],k = 3,dist = 3) == 5\n assert candidate(nums = [10, 8, 18, 9],k = 3,dist = 1) == 36\n assert candidate(nums = [5, 1, 4, 3, 2],k = 3,dist = 2) == 9\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4,dist = 4) == 15\n assert candidate(nums = [7, 8, 9, 10, 11, 12],k = 3,dist = 4) == 24\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5,dist = 4) == 15\n assert candidate(nums = [10, 1, 2, 2, 2, 1],k = 4,dist = 3) == 15\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7, 9, 5, 0, 2, 8, 8, 4, 1, 9, 7, 1, 6, 9, 3, 9, 9, 3, 7, 5, 1, 0],k = 15,dist = 20) == 45\n assert candidate(nums = [5, 1, 4, 2, 8, 7, 3, 6, 9, 10],k = 4,dist = 5) == 11\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 5,dist = 4) == 50\n assert candidate(nums = [100, 200, 10, 20, 30, 40, 50, 5, 15, 25, 35, 45],k = 5,dist = 6) == 150\n assert candidate(nums = [100, 101, 102, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88],k = 7,dist = 9) == 643\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5,dist = 4) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5,dist = 5) == 5\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],k = 3,dist = 5) == 6\n assert candidate(nums = [100, 200, 300, 400, 500, 1, 2, 3, 4, 5],k = 3,dist = 9) == 103\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 8,dist = 8) == 36\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80],k = 10,dist = 10) == 855\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 1, 2, 3, 4, 5],k = 6,dist = 9) == 1000000015\n assert candidate(nums = [31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],k = 7,dist = 6) == 259\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10,dist = 10) == 65\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 15,dist = 15) == 120\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 8,dist = 6) == 36\n assert candidate(nums = [5, 1, 9, 3, 7, 2, 8, 6, 4, 10, 11, 12],k = 5,dist = 6) == 17\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 7,dist = 7) == 28\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10,dist = 10) == 65\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 8,dist = 6) == 360\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5,dist = 3) == 19\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 100],k = 10,dist = 15) == 145\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 1, 9, 10],k = 4,dist = 5) == 12\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 4,dist = 3) == 100\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 10,dist = 15) == 550\n assert candidate(nums = [1, 9, 2, 8, 3, 7, 4, 6, 5, 10, 11, 12, 13, 14, 15],k = 7,dist = 8) == 28\n assert candidate(nums = [1, 3, 2, 6, 4, 2, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],k = 6,dist = 5) == 17\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 10,dist = 12) == 550\n assert candidate(nums = [5, 3, 8, 1, 4, 9, 2, 6, 7],k = 4,dist = 5) == 11\n assert candidate(nums = [1, 1000000000, 2, 1000000000, 3, 1000000000, 4, 1000000000, 5],k = 5,dist = 4) == 1000000010\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23],k = 6,dist = 7) == 36\n assert candidate(nums = [100, 200, 300, 400, 500, 1, 2, 3, 4, 5],k = 6,dist = 9) == 115\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10,dist = 10) == 55\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 7,dist = 10) == 280\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9],k = 5,dist = 5) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10,dist = 10) == 55\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 6,dist = 7) == 2100\n assert candidate(nums = [1, 9, 2, 8, 3, 7, 4, 6, 5, 10],k = 5,dist = 4) == 17\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5,dist = 10) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 8,dist = 7) == 36\n assert candidate(nums = [1, 3, 5, 2, 8, 7, 4, 6, 9, 10],k = 4,dist = 5) == 10\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10,dist = 10) == 1000000045\n assert candidate(nums = [100, 200, 150, 10, 50, 300, 400, 250, 350, 100, 500],k = 6,dist = 8) == 610\n assert candidate(nums = [10, 20, 30, 40, 50, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16],k = 8,dist = 7) == 38\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10,dist = 10) == 10\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10,dist = 10) == 1000000045\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 15,dist = 15) == 15\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91],k = 5,dist = 10) == 15\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5,dist = 5) == 25\n assert candidate(nums = [100, 200, 10, 20, 30, 40, 50, 60, 70, 80, 90],k = 6,dist = 6) == 250\n assert candidate(nums = [15, 3, 8, 7, 5, 2, 9, 1, 10, 4, 6, 11, 13, 12],k = 5,dist = 5) == 27\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 20,dist = 20) == 100\n assert candidate(nums = [3, 1, 2, 1, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2],k = 7,dist = 6) == 13\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6],k = 10,dist = 10) == 35\n assert candidate(nums = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 6,dist = 5) == 24\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5],k = 5,dist = 7) == 15\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 8,dist = 10) == 72\n assert candidate(nums = [100, 99, 98, 97, 96, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 7,dist = 7) == 121\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10,dist = 9) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5,dist = 5) == 11\n assert candidate(nums = [5, 1, 9, 2, 8, 3, 7, 4, 6, 10, 11, 12, 13, 14, 15],k = 7,dist = 8) == 28\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],k = 6,dist = 7) == 105\n assert candidate(nums = [3, 1, 2, 1, 3, 2, 1, 3, 2, 1],k = 4,dist = 4) == 7\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 10,dist = 10) == 550\n assert candidate(nums = [100, 1, 50, 2, 99, 3, 49, 4, 98, 5],k = 5,dist = 5) == 155\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5,dist = 3) == 19\n assert candidate(nums = [5, 1, 3, 8, 12, 7, 9, 2, 6, 4],k = 4,dist = 5) == 16\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],k = 5,dist = 5) == 7\n assert candidate(nums = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10,dist = 10) == 70\n assert candidate(nums = [9, 3, 7, 2, 8, 6, 5, 1, 4, 10],k = 4,dist = 5) == 16\n assert candidate(nums = [10, 20, 30, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 6,dist = 5) == 25\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 7,dist = 10) == 49\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 10,dist = 15) == 55\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 5,dist = 5) == 15\n assert candidate(nums = [15, 20, 25, 10, 30, 35, 5, 40, 45, 4, 50],k = 6,dist = 7) == 89\n assert candidate(nums = [200, 190, 180, 170, 160, 150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 10,dist = 10) == 650\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10,dist = 20) == 34\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 15,dist = 15) == 135\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5,dist = 15) == 16\n assert candidate(nums = [5, 8, 3, 9, 2, 7, 4, 6, 1, 0, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 7,dist = 15) == 21\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 6,dist = 7) == 210\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3],k = 7,dist = 10) == 19\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 5,dist = 3) == 200\n assert candidate(nums = [9, 3, 1, 5, 2, 8, 6, 7, 4, 10],k = 5,dist = 5) == 20\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 5,dist = 12) == 30\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 15,dist = 25) == 76\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5,dist = 5) == 25\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 6,dist = 8) == 30\n assert candidate(nums = [5, 1, 4, 2, 3, 6, 8, 7, 9, 10],k = 4,dist = 6) == 11\n assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5,dist = 8) == 101\n assert candidate(nums = [5, 3, 8, 12, 4, 6, 7, 10, 2, 9],k = 4,dist = 6) == 17\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],k = 9,dist = 10) == 25\n assert candidate(nums = [200, 100, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],k = 5,dist = 10) == 1500\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5,dist = 4) == 15\n assert candidate(nums = [1000000000, 1, 1000000000, 1, 1000000000],k = 3,dist = 3) == 1000000002\n assert candidate(nums = [5, 1, 4, 2, 8, 7, 3],k = 4,dist = 5) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 6,dist = 7) == 21\n assert candidate(nums = [7, 8, 9, 10, 5, 6, 2, 3, 4, 1],k = 5,dist = 5) == 17\n assert candidate(nums = [5, 4, 3, 2, 1],k = 3,dist = 4) == 8\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 3,dist = 5) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5,dist = 5) == 15\n assert candidate(nums = [5, 3, 8, 1, 4, 7, 9, 2],k = 4,dist = 4) == 12\n assert candidate(nums = [5, 1, 3, 7, 9, 2, 6, 8, 4],k = 4,dist = 5) == 11\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 4,dist = 2) == 20\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5,dist = 5) == 19\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3,dist = 7) == 6\n assert candidate(nums = [5, 1, 4, 2, 3, 6, 7, 8, 9],k = 4,dist = 5) == 11\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 3,dist = 2) == 15\n assert candidate(nums = [1, 9, 2, 8, 3, 7, 4, 6, 5, 10],k = 4,dist = 5) == 10\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9],k = 6,dist = 5) == 16\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 3,dist = 4) == 12\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 3,dist = 6) == 12\n assert candidate(nums = [50, 40, 30, 20, 10, 1, 2, 3, 4, 5],k = 4,dist = 5) == 56\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5,dist = 5) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 6,dist = 10) == 21\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 3,dist = 7) == 3\n assert candidate(nums = [5, 2, 3, 1, 4, 6, 7, 8, 9],k = 5,dist = 4) == 15\n assert candidate(nums = [100, 200, 300, 400, 500],k = 3,dist = 2) == 600\n assert candidate(nums = [7, 3, 5, 10, 6, 9],k = 4,dist = 5) == 21\n assert candidate(nums = [9, 7, 5, 3, 1],k = 4,dist = 3) == 18\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3],k = 5,dist = 5) == 15\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 6,dist = 7) == 210\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3,dist = 5) == 6\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 3,dist = 2) == 3\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 5,dist = 5) == 11\n assert candidate(nums = [7, 9, 3, 1, 5, 6, 2],k = 5,dist = 5) == 18\n assert candidate(nums = [5, 4, 3, 2, 1, 6, 7, 8, 9],k = 3,dist = 4) == 8\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5,dist = 4) == 19\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 5,dist = 5) == 15\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 4,dist = 6) == 100\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000],k = 3,dist = 4) == 111\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 6,dist = 5) == 2100\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1],k = 3,dist = 2) == 3\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1],k = 3,dist = 4) == 10\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3],k = 3,dist = 5) == 9\n assert candidate(nums = [5, 1, 4, 3, 2],k = 3,dist = 2) == 9\n assert candidate(nums = [10, 8, 18, 9],k = 3,dist = 1) == 36\n assert candidate(nums = [7, 8, 9, 10, 2, 1, 3, 4, 5, 6],k = 4,dist = 4) == 13\n assert candidate(nums = [5, 1, 4, 2, 8, 3, 7, 6],k = 4,dist = 4) == 11\n assert candidate(nums = [5, 1, 4, 3, 2, 6, 7],k = 3,dist = 4) == 8\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 3,dist = 7) == 9\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 5,dist = 6) == 1500\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900],k = 4,dist = 7) == 1000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5,dist = 6) == 15\n assert candidate(nums = [7, 8, 9, 10, 2, 1, 3, 4, 5, 6],k = 4,dist = 5) == 13\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5,dist = 10) == 15\n assert candidate(nums = [1, 3, 2, 6, 4, 2],k = 3,dist = 3) == 5\n assert candidate(nums = [3, 1, 5, 2, 4, 6, 8, 7],k = 3,dist = 4) == 6\n assert candidate(nums = [7, 8, 9, 10, 11, 12],k = 4,dist = 5) == 34\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5,dist = 10) == 5\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 3,dist = 4) == 9\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96],k = 5,dist = 5) == 107\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7],k = 5,dist = 5) == 15\n assert candidate(nums = [7, 1, 5, 3, 6, 4, 8, 2],k = 5,dist = 5) == 20\n assert candidate(nums = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10],k = 5,dist = 5) == 19\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5,dist = 4) == 25\n assert candidate(nums = [5, 4, 3, 2, 1],k = 3,dist = 2) == 8\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 3,dist = 7) == 600\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4,dist = 6) == 10\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900],k = 4,dist = 4) == 1000\n assert candidate(nums = [5, 1, 3, 8, 6, 7, 4, 2],k = 4,dist = 4) == 15\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5,dist = 6) == 150\n assert candidate(nums = [7, 8, 9, 1, 2, 3, 4, 5, 6],k = 5,dist = 5) == 17\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 3,dist = 8) == 600\n assert candidate(nums = [7, 8, 9, 10, 2, 1],k = 4,dist = 4) == 18\n assert candidate(nums = [1000000000, 1000000000, 1000000000],k = 3,dist = 2) == 3000000000\n assert candidate(nums = [5, 1, 4, 2, 3],k = 3,dist = 4) == 8\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9],k = 4,dist = 4) == 9\n assert candidate(nums = [5, 1, 3, 7, 9, 2, 6, 4, 8],k = 4,dist = 5) == 11\n assert candidate(nums = [9, 3, 7, 6, 2, 5, 8, 4],k = 5,dist = 4) == 25\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4,dist = 4) == 10\n assert candidate(nums = [5, 1, 3, 7, 9, 2, 6, 8, 4, 10],k = 5,dist = 4) == 18\n assert candidate(nums = [10, 1, 2, 2, 2, 1],k = 4,dist = 3) == 15\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5,dist = 5) == 25\n assert candidate(nums = [3, 2, 1, 4, 5, 6, 7, 8, 9, 10],k = 4,dist = 5) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4,dist = 5) == 10\n assert candidate(nums = [100, 200, 300, 400, 500, 600],k = 3,dist = 2) == 600\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63],k = 4,dist = 6) == 70\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4,dist = 5) == 15\n assert candidate(nums = [5, 1, 4, 2, 3],k = 3,dist = 4) == 8\n assert candidate(nums = [5, 1, 4, 2, 8, 3],k = 4,dist = 4) == 11\n assert candidate(nums = [5, 1, 4, 2, 8, 3],k = 3,dist = 4) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],k = 3,dist = 6) == 6\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7],k = 7,dist = 6) == 19\n"}, "metadata": {"canonical_parameter_names": ["nums", "k", "dist"], "leetcode_dataset_entry_point": "Solution().minimumCost", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "long long minimumCost(vector& nums, int k, int dist) {", "container": "Solution", "callable": "minimumCost", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "k", "type": "int"}, {"name": "dist", "type": "int"}], "return_type": "long long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3014, "task_id": "minimum-number-of-pushes-to-type-word-i", "difficulty": "Easy", "problem_description": "You are given a string word containing distinct lowercase English letters.\nTelephone keypads have keys mapped with distinct collections of lowercase English letters, which can be used to form words by pushing them. For example, the key 2 is mapped with [\"a\",\"b\",\"c\"], we need to push the key one time to type \"a\", two times to type \"b\", and three times to type \"c\" .\nIt is allowed to remap the keys numbered 2 to 9 to distinct collections of letters. The keys can be remapped to any amount of letters, but each letter must be mapped to exactly one key. You need to find the minimum number of times the keys will be pushed to type the string word.\nReturn the minimum number of pushes needed to type word after remapping the keys.\nAn example mapping of letters to keys on a telephone keypad is given below. Note that 1, *, #, and 0 do not map to any letters.\n\n \nExample 1:\n\n\nInput: word = \"abcde\"\nOutput: 5\nExplanation: The remapped keypad given in the image provides the minimum cost.\n\"a\" -> one push on key 2\n\"b\" -> one push on key 3\n\"c\" -> one push on key 4\n\"d\" -> one push on key 5\n\"e\" -> one push on key 6\nTotal cost is 1 + 1 + 1 + 1 + 1 = 5.\nIt can be shown that no other mapping can provide a lower cost.\n\nExample 2:\n\n\nInput: word = \"xycdefghij\"\nOutput: 12\nExplanation: The remapped keypad given in the image provides the minimum cost.\n\"x\" -> one push on key 2\n\"y\" -> two pushes on key 2\n\"c\" -> one push on key 3\n\"d\" -> two pushes on key 3\n\"e\" -> one push on key 4\n\"f\" -> one push on key 5\n\"g\" -> one push on key 6\n\"h\" -> one push on key 7\n\"i\" -> one push on key 8\n\"j\" -> one push on key 9\nTotal cost is 1 + 2 + 1 + 2 + 1 + 1 + 1 + 1 + 1 + 1 = 12.\nIt can be shown that no other mapping can provide a lower cost.\n\n \nConstraints:\n\n1 <= word.length <= 26\nword consists of lowercase English letters.\nAll letters in word are distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word = \"ghijkl\") == 6\n assert candidate(word = \"npqrstvwxy\") == 12\n assert candidate(word = \"abcdefghi\") == 10\n assert candidate(word = \"vwxyz\") == 5\n assert candidate(word = \"abcdefghijklmnopq\") == 27\n assert candidate(word = \"abcdefghijklmnopqrs\") == 33\n assert candidate(word = \"abcdefghijklmnopqrstu\") == 39\n assert candidate(word = \"pqrstu\") == 6\n assert candidate(word = \"abcdefghijkl\") == 16\n assert candidate(word = \"abcdefghijk\") == 14\n assert candidate(word = \"pqrstuvw\") == 8\n assert candidate(word = \"defghi\") == 6\n assert candidate(word = \"abcdefghijklm\") == 18\n assert candidate(word = \"efghijkl\") == 8\n assert candidate(word = \"abcdef\") == 6\n assert candidate(word = \"abcdefghijklmn\") == 20\n assert candidate(word = \"qrstuvw\") == 7\n assert candidate(word = \"uvwxyza\") == 7\n assert candidate(word = \"bcdefg\") == 6\n assert candidate(word = \"tuvwxy\") == 6\n assert candidate(word = \"qrstuv\") == 6\n assert candidate(word = \"tuvwxyz\") == 7\n assert candidate(word = \"wxyzabc\") == 7\n assert candidate(word = \"abcdefghij\") == 12\n assert candidate(word = \"nopqrs\") == 6\n assert candidate(word = \"nopqrst\") == 7\n assert candidate(word = \"xycdefghij\") == 12\n assert candidate(word = \"hijklmno\") == 8\n assert candidate(word = \"mnopqrstu\") == 10\n assert candidate(word = \"vwxyza\") == 6\n assert candidate(word = \"abcdefghijklmnopqr\") == 30\n assert candidate(word = \"abcdefghijkmnopqrstuvwxyzabc\") == 64\n assert candidate(word = \"rstvwxy\") == 7\n assert candidate(word = \"zabcdef\") == 7\n assert candidate(word = \"abcdefghijklmnop\") == 24\n assert candidate(word = \"klmnopq\") == 7\n assert candidate(word = \"stuvwx\") == 6\n assert candidate(word = \"mnop\") == 4\n assert candidate(word = \"xyz\") == 3\n assert candidate(word = \"qrstuvwx\") == 8\n assert candidate(word = \"abcdefghijlkmnopqrstuvwxyz\") == 56\n assert candidate(word = \"yz\") == 2\n assert candidate(word = \"lmnopqrs\") == 8\n assert candidate(word = \"ab\") == 2\n assert candidate(word = \"abcde\") == 5\n assert candidate(word = \"abcd\") == 4\n assert candidate(word = \"abcdefg\") == 7\n assert candidate(word = \"a\") == 1\n assert candidate(word = \"ijklmn\") == 6\n assert candidate(word = \"klmnop\") == 6\n assert candidate(word = \"mnopqr\") == 6\n assert candidate(word = \"ghijklm\") == 7\n assert candidate(word = \"ijklmnop\") == 8\n assert candidate(word = \"zabcde\") == 6\n assert candidate(word = \"abcdefghijklmnopqrst\") == 36\n assert candidate(word = \"abc\") == 3\n assert candidate(word = \"opqrstuv\") == 8\n assert candidate(word = \"hijklm\") == 6\n assert candidate(word = \"abcdefghijklmnopqrstuv\") == 42\n assert candidate(word = \"abcdefghijkmnopqrstuvwx\") == 45\n assert candidate(word = \"defghij\") == 7\n assert candidate(word = \"efghij\") == 6\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyz\") == 56\n assert candidate(word = \"mnopqrstuvwxyz\") == 20\n assert candidate(word = \"yzabcdef\") == 8\n assert candidate(word = \"defghijkl\") == 10\n assert candidate(word = \"jklmno\") == 6\n assert candidate(word = \"abcdefgh\") == 8\n assert candidate(word = \"bcdfghjkl\") == 10\n assert candidate(word = \"bcdefghijklmnopqrstuvwxyzafe\") == 64\n assert candidate(word = \"abcdefghijklmnopqrstuvwx\") == 48\n assert candidate(word = \"nopqrstuvwxyz\") == 18\n assert candidate(word = \"stuvwxyzabcdefghij\") == 30\n assert candidate(word = \"wxyzabcdefghijklmnopqrstuv\") == 56\n assert candidate(word = \"xyzmnopqrstuabc\") == 22\n assert candidate(word = \"stuvwxyzabcdefghijkl\") == 36\n assert candidate(word = \"qrstuvwxyzabcdefghij\") == 36\n assert candidate(word = \"nopqrstuvwxyzabcdefghijk\") == 48\n assert candidate(word = \"lmnopqrstuvwxyzabc\") == 30\n assert candidate(word = \"opqrstuvwxyzabcde\") == 27\n assert candidate(word = \"uvwxyzabcdefghijklmnopqrstuvwxy\") == 76\n assert candidate(word = \"lmnopqrstuvwxyzabcdefghijk\") == 56\n assert candidate(word = \"zxcvbnmlkjhgfedcba\") == 30\n assert candidate(word = \"xyzabcdefghijklmnop\") == 33\n assert candidate(word = \"qrstuvwxyzzzzz\") == 20\n assert candidate(word = \"abcdefghijlmnopqrstuvwxyz\") == 52\n assert candidate(word = \"jklmnopqrstuvwx\") == 22\n assert candidate(word = \"klmnopqrstuvwxyzabcdefghij\") == 56\n assert candidate(word = \"zxcvbnmlkjhgfdsapoiuytrewq\") == 56\n assert candidate(word = \"nopqrstuvwxyzabcdefghijklmno\") == 64\n assert candidate(word = \"opqrstuvwxyzabcdefghijklmnop\") == 64\n assert candidate(word = \"nopqrstuvwxyzabcdefghijklm\") == 56\n assert candidate(word = \"pqrstuvwxy\") == 12\n assert candidate(word = \"efghijklmnop\") == 16\n assert candidate(word = \"yzabcdefghijklmnopqrstuvwx\") == 56\n assert candidate(word = \"tuvxyzabcdefghijklmnopqrs\") == 52\n assert candidate(word = \"mnopqrstuvwxzyabc\") == 27\n assert candidate(word = \"lmnopqrstu\") == 12\n assert candidate(word = \"bdfhjlnprtvxz\") == 18\n assert candidate(word = \"mnopqrstuvwxyzabc\") == 27\n assert candidate(word = \"mnopqrst\") == 8\n assert candidate(word = \"mnopqrstuvwxzy\") == 20\n assert candidate(word = \"abcdpqrs\") == 8\n assert candidate(word = \"abcdefghijklmnopqrstuvwxzy\") == 56\n assert candidate(word = \"aeiouaeiou\") == 12\n assert candidate(word = \"xyzabcdefghijklmnopqrstuvwx\") == 60\n assert candidate(word = \"abcdefgxyz\") == 12\n assert candidate(word = \"defghijklmnopqrstuvwxyzabc\") == 56\n assert candidate(word = \"klmnopqrstuabcdefghij\") == 39\n assert candidate(word = \"abcdefghijkmnop\") == 22\n assert candidate(word = \"abcdefgxyzijklmnop\") == 30\n assert candidate(word = \"stuvxyzabcdefghijklmnopqr\") == 52\n assert candidate(word = \"ghijklmnopqrstuvwxyzabcde\") == 52\n assert candidate(word = \"zyxcvbnm\") == 8\n assert candidate(word = \"nopqrstuvwxyzabcdefghijkl\") == 52\n assert candidate(word = \"abcdefghjklmno\") == 20\n assert candidate(word = \"hijklmnopqrstuvwxyz\") == 33\n assert candidate(word = \"vwxyzabcd\") == 10\n assert candidate(word = \"pqrstuvwlmnoefghij\") == 30\n assert candidate(word = \"yzabcdefghijklmnopqrstuvwxy\") == 60\n assert candidate(word = \"zabcdefghijklmnopq\") == 30\n assert candidate(word = \"defghijklmnopqrstuvwxyza\") == 48\n assert candidate(word = \"opqrstuvwxyzabcdefghijklmn\") == 56\n assert candidate(word = \"mnopqrstuvwxyzabcdefghijxyz\") == 60\n assert candidate(word = \"mnopqrstuvwxyzaefghijkl\") == 45\n assert candidate(word = \"wxyzabcdefghijklmnopqrstuvwxy\") == 68\n assert candidate(word = \"abcdefghijmnopqrstuvwxyz\") == 48\n assert candidate(word = \"bcdefghijklmnopqrstuvwxyza\") == 56\n assert candidate(word = \"xyzabc\") == 6\n assert candidate(word = \"poiuytrewq\") == 12\n assert candidate(word = \"bcdfghjklmnpqrstvwxyz\") == 39\n assert candidate(word = \"qwertyuiop\") == 12\n assert candidate(word = \"abcdefhijklmno\") == 20\n assert candidate(word = \"qrstuvwxyz\") == 12\n assert candidate(word = \"uvwxyzaeiou\") == 14\n assert candidate(word = \"abcdefghilmnopqrstuvwxyz\") == 48\n assert candidate(word = \"abcdefghijxyzklmnopqr\") == 39\n assert candidate(word = \"xyzdefghijklmnopqrstuvw\") == 45\n assert candidate(word = \"abcdefghijkmnopqrst\") == 33\n assert candidate(word = \"wxyzabcdefghijklmnopqrst\") == 48\n assert candidate(word = \"tuvwxyzabcdefghijklmnopqrs\") == 56\n assert candidate(word = \"qrstuvwxyzabcdefghijklmnop\") == 56\n assert candidate(word = \"ghijklmnopqrstuvwxyzab\") == 42\n assert candidate(word = \"nopqrstuvwxyzabc\") == 24\n assert candidate(word = \"abcdefghiklmnopqrstuvwxyz\") == 52\n assert candidate(word = \"yzabcd\") == 6\n assert candidate(word = \"ghijklmnopqrstu\") == 22\n assert candidate(word = \"vwxyzabcdefghijklmnopqrstu\") == 56\n assert candidate(word = \"vwxyzabcdefghijklmnopq\") == 42\n assert candidate(word = \"zabcdefghijklmnop\") == 27\n assert candidate(word = \"ijklmnopqrstuvwxyzabcdefgh\") == 56\n assert candidate(word = \"lkjihgfedcba\") == 16\n assert candidate(word = \"klmno\") == 5\n assert candidate(word = \"pqrstuvwxyzabcdefghijklmno\") == 56\n assert candidate(word = \"stuvwxyzabcdefghijklmnopqr\") == 56\n assert candidate(word = \"abcdefg hijklmnop qrstuv wxyz\") == 68\n assert candidate(word = \"lmnopqrstuvwxyz\") == 22\n assert candidate(word = \"rstuvxyzabcdefghijklmnopqrst\") == 64\n assert candidate(word = \"qrstuvwxyza\") == 14\n assert candidate(word = \"abcdefghilmnopqr\") == 24\n assert candidate(word = \"yzabcdefghijklmnopqrstuvw\") == 52\n assert candidate(word = \"xyzabcdefghijklmnopq\") == 36\n assert candidate(word = \"bcdefghijklmnopqrstuvwx\") == 45\n assert candidate(word = \"abcdefghijklmnopqrstuvmnop\") == 56\n assert candidate(word = \"zxcvbnm\") == 7\n assert candidate(word = \"xyzabcdefghijklmnopqrstuvw\") == 56\n assert candidate(word = \"qrstuvwxyzabcdefg\") == 27\n assert candidate(word = \"abcdefghijkmnopqrstuvwxy\") == 48\n assert candidate(word = \"abcdefghilmnopqrstuvwxyzz\") == 52\n assert candidate(word = \"defghijklmnopqrstu\") == 30\n assert candidate(word = \"vwxyzabcdefghijklmno\") == 36\n assert candidate(word = \"vwxyzabcdefghijklmnopqrstuvwx\") == 68\n assert candidate(word = \"zxcvbnmasdfghjklqwertyuiop\") == 56\n assert candidate(word = \"mnopqrstuv\") == 12\n assert candidate(word = \"zabcdefghijklmnopqrstuvwxy\") == 56\n assert candidate(word = \"defghijklmnopqrstuabcdefgh\") == 56\n assert candidate(word = \"asdfghjkl\") == 10\n assert candidate(word = \"abcdefghijklmno\") == 22\n assert candidate(word = \"ghijklmnopqrstuvwxyzabcdef\") == 56\n assert candidate(word = \"yzabcdefghijklmnop\") == 30\n assert candidate(word = \"qrstuvwxyzabcdefghijklmnoprstuvw\") == 80\n assert candidate(word = \"rstuvwxyzabcdefghijklmnopq\") == 56\n assert candidate(word = \"zabcdefghijklmnopqrstuvwx\") == 52\n assert candidate(word = \"nopqrstuvwxyzabcd\") == 27\n assert candidate(word = \"bcdefghijkl\") == 14\n assert candidate(word = \"nopqrstuvwxyzabcde\") == 30\n assert candidate(word = \"abcdefhijklmnopqrstuvwxyz\") == 52\n assert candidate(word = \"abcdefghijkmnopqrstuv\") == 39\n assert candidate(word = \"tuvwx\") == 5\n assert candidate(word = \"pqrstuvwxyzabcdef\") == 27\n assert candidate(word = \"jklmnopqrst\") == 14\n assert candidate(word = \"bcdefghijklmnopqrstvwxyz\") == 48\n assert candidate(word = \"lkjhgfdsa\") == 10\n assert candidate(word = \"pqrstuvwxyzabc\") == 20\n assert candidate(word = \"jklmnopqr\") == 10\n assert candidate(word = \"uvwxyzabcdefghijklmnopqrst\") == 56\n assert candidate(word = \"qrstuvwlmnop\") == 16\n assert candidate(word = \"acdegikmoqsuwy\") == 20\n assert candidate(word = \"pqrstuvwxyza\") == 16\n assert candidate(word = \"qrstuabcdefghijk\") == 24\n assert candidate(word = \"mnopqrstuvwx\") == 16\n assert candidate(word = \"hgfedcba\") == 8\n"}, "metadata": {"canonical_parameter_names": ["word"], "leetcode_dataset_entry_point": "Solution().minimumPushes", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumPushes(string word) {", "container": "Solution", "callable": "minimumPushes", "parameters": [{"name": "word", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3015, "task_id": "count-the-number-of-houses-at-a-certain-distance-i", "difficulty": "Medium", "problem_description": "You are given three positive integers n, x, and y.\nIn a city, there exist houses numbered 1 to n connected by n streets. There is a street connecting the house numbered i with the house numbered i + 1 for all 1 <= i <= n - 1 . An additional street connects the house numbered x with the house numbered y.\nFor each k, such that 1 <= k <= n, you need to find the number of pairs of houses (house1, house2) such that the minimum number of streets that need to be traveled to reach house2 from house1 is k.\nReturn a 1-indexed array result of length n where result[k] represents the total number of pairs of houses such that the minimum streets required to reach one house from the other is k.\nNote that x and y can be equal.\n \nExample 1:\n\n\nInput: n = 3, x = 1, y = 3\nOutput: [6,0,0]\nExplanation: Let's look at each pair of houses:\n- For the pair (1, 2), we can go from house 1 to house 2 directly.\n- For the pair (2, 1), we can go from house 2 to house 1 directly.\n- For the pair (1, 3), we can go from house 1 to house 3 directly.\n- For the pair (3, 1), we can go from house 3 to house 1 directly.\n- For the pair (2, 3), we can go from house 2 to house 3 directly.\n- For the pair (3, 2), we can go from house 3 to house 2 directly.\n\nExample 2:\n\n\nInput: n = 5, x = 2, y = 4\nOutput: [10,8,2,0,0]\nExplanation: For each distance k the pairs are:\n- For k == 1, the pairs are (1, 2), (2, 1), (2, 3), (3, 2), (2, 4), (4, 2), (3, 4), (4, 3), (4, 5), and (5, 4).\n- For k == 2, the pairs are (1, 3), (3, 1), (1, 4), (4, 1), (2, 5), (5, 2), (3, 5), and (5, 3).\n- For k == 3, the pairs are (1, 5), and (5, 1).\n- For k == 4 and k == 5, there are no pairs.\n\nExample 3:\n\n\nInput: n = 4, x = 1, y = 1\nOutput: [6,4,2,0]\nExplanation: For each distance k the pairs are:\n- For k == 1, the pairs are (1, 2), (2, 1), (2, 3), (3, 2), (3, 4), and (4, 3).\n- For k == 2, the pairs are (1, 3), (3, 1), (2, 4), and (4, 2).\n- For k == 3, the pairs are (1, 4), and (4, 1).\n- For k == 4, there are no pairs.\n\n \nConstraints:\n\n2 <= n <= 100\n1 <= x, y <= n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 10,x = 4,y = 9) == [20, 24, 22, 14, 8, 2, 0, 0, 0, 0]\n assert candidate(n = 10,x = 4,y = 6) == [20, 18, 16, 14, 10, 6, 4, 2, 0, 0]\n assert candidate(n = 10,x = 3,y = 7) == [20, 24, 20, 16, 8, 2, 0, 0, 0, 0]\n assert candidate(n = 10,x = 3,y = 8) == [20, 24, 24, 16, 6, 0, 0, 0, 0, 0]\n assert candidate(n = 4,x = 1,y = 1) == [6, 4, 2, 0]\n assert candidate(n = 100,x = 1,y = 100) == [200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 5,x = 2,y = 4) == [10, 8, 2, 0, 0]\n assert candidate(n = 8,x = 1,y = 8) == [16, 16, 16, 8, 0, 0, 0, 0]\n assert candidate(n = 9,x = 5,y = 5) == [16, 14, 12, 10, 8, 6, 4, 2, 0]\n assert candidate(n = 6,x = 2,y = 5) == [12, 12, 6, 0, 0, 0]\n assert candidate(n = 3,x = 1,y = 3) == [6, 0, 0]\n assert candidate(n = 100,x = 50,y = 51) == [198, 196, 194, 192, 190, 188, 186, 184, 182, 180, 178, 176, 174, 172, 170, 168, 166, 164, 162, 160, 158, 156, 154, 152, 150, 148, 146, 144, 142, 140, 138, 136, 134, 132, 130, 128, 126, 124, 122, 120, 118, 116, 114, 112, 110, 108, 106, 104, 102, 100, 98, 96, 94, 92, 90, 88, 86, 84, 82, 80, 78, 76, 74, 72, 70, 68, 66, 64, 62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0]\n assert candidate(n = 10,x = 4,y = 7) == [20, 20, 18, 16, 10, 4, 2, 0, 0, 0]\n assert candidate(n = 2,x = 1,y = 2) == [2, 0]\n assert candidate(n = 7,x = 3,y = 7) == [14, 16, 8, 4, 0, 0, 0]\n assert candidate(n = 100,x = 50,y = 50) == [198, 196, 194, 192, 190, 188, 186, 184, 182, 180, 178, 176, 174, 172, 170, 168, 166, 164, 162, 160, 158, 156, 154, 152, 150, 148, 146, 144, 142, 140, 138, 136, 134, 132, 130, 128, 126, 124, 122, 120, 118, 116, 114, 112, 110, 108, 106, 104, 102, 100, 98, 96, 94, 92, 90, 88, 86, 84, 82, 80, 78, 76, 74, 72, 70, 68, 66, 64, 62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0]\n assert candidate(n = 12,x = 1,y = 12) == [24, 24, 24, 24, 24, 12, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 30,x = 10,y = 25) == [60, 64, 70, 76, 82, 88, 92, 78, 60, 54, 46, 36, 26, 18, 12, 6, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 65,x = 2,y = 3) == [128, 126, 124, 122, 120, 118, 116, 114, 112, 110, 108, 106, 104, 102, 100, 98, 96, 94, 92, 90, 88, 86, 84, 82, 80, 78, 76, 74, 72, 70, 68, 66, 64, 62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0]\n assert candidate(n = 90,x = 15,y = 85) == [180, 184, 190, 196, 202, 208, 212, 214, 216, 218, 220, 222, 224, 226, 228, 228, 226, 224, 222, 220, 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, 76, 68, 60, 52, 44, 36, 32, 28, 24, 20, 16, 12, 8, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 70,x = 20,y = 60) == [140, 144, 150, 156, 162, 168, 174, 180, 186, 192, 198, 202, 204, 206, 208, 210, 212, 214, 216, 218, 136, 126, 116, 106, 96, 86, 76, 66, 56, 46, 36, 32, 28, 24, 20, 16, 12, 8, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 100,x = 50,y = 90) == [200, 204, 210, 216, 222, 228, 234, 240, 246, 252, 258, 262, 264, 266, 268, 270, 272, 274, 276, 278, 198, 192, 186, 180, 174, 168, 162, 156, 150, 144, 138, 136, 134, 132, 130, 128, 126, 124, 122, 120, 118, 116, 114, 112, 110, 108, 106, 104, 102, 100, 96, 90, 84, 78, 72, 66, 60, 54, 48, 42, 36, 32, 28, 24, 20, 16, 12, 8, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 35,x = 17,y = 28) == [70, 74, 80, 86, 92, 86, 76, 74, 70, 64, 58, 52, 46, 42, 40, 38, 36, 32, 26, 20, 14, 8, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 25,x = 10,y = 15) == [50, 54, 54, 50, 48, 46, 44, 42, 40, 38, 34, 26, 18, 14, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0]\n assert candidate(n = 50,x = 20,y = 40) == [100, 104, 110, 116, 122, 128, 134, 140, 146, 152, 116, 112, 106, 100, 94, 88, 82, 76, 70, 64, 56, 50, 44, 38, 32, 26, 20, 14, 8, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 70,x = 68,y = 69) == [138, 136, 134, 132, 130, 128, 126, 124, 122, 120, 118, 116, 114, 112, 110, 108, 106, 104, 102, 100, 98, 96, 94, 92, 90, 88, 86, 84, 82, 80, 78, 76, 74, 72, 70, 68, 66, 64, 62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0]\n assert candidate(n = 35,x = 17,y = 21) == [70, 74, 70, 68, 66, 64, 62, 60, 58, 56, 54, 52, 50, 48, 46, 42, 36, 32, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0]\n assert candidate(n = 30,x = 1,y = 29) == [60, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 95,x = 5,y = 90) == [190, 194, 200, 206, 212, 216, 216, 214, 212, 210, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 122, 32, 24, 16, 8, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 7,x = 3,y = 3) == [12, 10, 8, 6, 4, 2, 0]\n assert candidate(n = 22,x = 3,y = 19) == [44, 48, 54, 58, 58, 56, 54, 54, 20, 12, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 32,x = 5,y = 27) == [64, 68, 74, 80, 86, 90, 90, 88, 86, 84, 82, 36, 28, 20, 12, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 18,x = 9,y = 5) == [36, 40, 36, 34, 32, 28, 22, 20, 18, 16, 12, 6, 4, 2, 0, 0, 0, 0]\n assert candidate(n = 40,x = 1,y = 40) == [80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 8,x = 2,y = 7) == [16, 20, 16, 4, 0, 0, 0, 0]\n assert candidate(n = 18,x = 5,y = 9) == [36, 40, 36, 34, 32, 28, 22, 20, 18, 16, 12, 6, 4, 2, 0, 0, 0, 0]\n assert candidate(n = 100,x = 40,y = 60) == [200, 204, 210, 216, 222, 228, 234, 240, 246, 252, 216, 214, 212, 210, 208, 206, 204, 202, 200, 198, 196, 194, 192, 190, 188, 186, 184, 182, 180, 178, 176, 174, 172, 170, 168, 166, 164, 162, 160, 158, 154, 146, 136, 126, 116, 106, 96, 86, 76, 66, 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 99,x = 50,y = 99) == [198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 222, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 196, 146, 144, 142, 140, 138, 136, 134, 132, 130, 128, 126, 124, 122, 120, 118, 116, 114, 112, 110, 108, 106, 104, 102, 100, 98, 94, 90, 86, 82, 78, 74, 70, 66, 62, 58, 54, 50, 46, 42, 38, 34, 30, 26, 22, 18, 14, 10, 6, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 70,x = 18,y = 50) == [140, 144, 150, 156, 162, 168, 174, 180, 186, 192, 198, 204, 210, 216, 222, 228, 168, 166, 162, 156, 150, 142, 132, 122, 112, 102, 92, 82, 72, 62, 52, 42, 32, 22, 16, 10, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 50,x = 1,y = 50) == [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 100,x = 35,y = 95) == [200, 204, 210, 216, 222, 228, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 270, 272, 274, 276, 278, 158, 152, 146, 140, 134, 126, 120, 114, 108, 102, 96, 92, 88, 84, 80, 76, 72, 68, 64, 60, 56, 52, 48, 44, 40, 36, 32, 28, 24, 20, 16, 12, 8, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 25,x = 1,y = 25) == [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 30,x = 15,y = 15) == [58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0]\n assert candidate(n = 25,x = 7,y = 18) == [50, 54, 60, 66, 72, 66, 56, 52, 44, 34, 24, 14, 6, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 60,x = 20,y = 55) == [120, 124, 130, 136, 142, 148, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 138, 100, 94, 86, 76, 66, 58, 52, 46, 42, 38, 34, 30, 26, 22, 18, 14, 10, 6, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 50,x = 25,y = 25) == [98, 96, 94, 92, 90, 88, 86, 84, 82, 80, 78, 76, 74, 72, 70, 68, 66, 64, 62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0]\n assert candidate(n = 24,x = 12,y = 12) == [46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0]\n assert candidate(n = 60,x = 35,y = 45) == [120, 124, 130, 136, 142, 126, 124, 122, 120, 118, 116, 114, 112, 110, 108, 106, 102, 96, 90, 84, 78, 76, 74, 72, 70, 68, 66, 64, 62, 60, 58, 56, 54, 52, 50, 46, 40, 34, 28, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 70,x = 30,y = 65) == [140, 144, 150, 156, 162, 168, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 158, 120, 114, 108, 102, 96, 92, 90, 88, 86, 84, 82, 80, 76, 70, 64, 58, 52, 46, 42, 38, 34, 30, 26, 22, 18, 14, 10, 6, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 48,x = 6,y = 43) == [96, 100, 106, 112, 118, 124, 126, 124, 122, 120, 118, 116, 116, 116, 116, 116, 116, 116, 78, 36, 28, 20, 12, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 25,x = 7,y = 20) == [50, 54, 60, 66, 72, 78, 68, 50, 40, 30, 20, 10, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 40,x = 30,y = 30) == [78, 76, 74, 72, 70, 68, 66, 64, 62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0]\n assert candidate(n = 100,x = 30,y = 80) == [200, 204, 210, 216, 222, 228, 234, 240, 246, 252, 258, 264, 270, 276, 282, 288, 294, 300, 306, 312, 318, 322, 324, 326, 328, 228, 222, 216, 210, 204, 196, 186, 176, 166, 156, 146, 136, 126, 116, 106, 96, 86, 76, 66, 56, 46, 40, 34, 28, 22, 16, 12, 8, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 50,x = 20,y = 35) == [100, 104, 110, 116, 122, 128, 134, 124, 110, 108, 106, 104, 102, 100, 98, 96, 92, 86, 80, 74, 66, 56, 46, 38, 32, 26, 20, 16, 14, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 45,x = 10,y = 40) == [90, 94, 100, 106, 112, 118, 122, 124, 126, 128, 128, 126, 124, 122, 120, 56, 48, 40, 32, 24, 16, 12, 8, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 75,x = 15,y = 60) == [150, 154, 160, 166, 172, 178, 184, 190, 196, 202, 208, 214, 220, 226, 232, 236, 236, 234, 232, 230, 228, 226, 178, 126, 116, 106, 96, 86, 76, 66, 56, 48, 40, 32, 24, 16, 8, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 50,x = 12,y = 35) == [100, 104, 110, 116, 122, 128, 134, 140, 146, 152, 158, 140, 116, 110, 104, 98, 90, 80, 70, 60, 50, 40, 30, 22, 16, 10, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 30,x = 10,y = 20) == [60, 64, 70, 76, 82, 66, 64, 62, 60, 58, 54, 46, 36, 26, 16, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 60,x = 10,y = 55) == [120, 124, 130, 136, 142, 148, 152, 154, 156, 158, 158, 156, 154, 152, 150, 148, 148, 148, 148, 148, 148, 148, 102, 52, 44, 36, 28, 20, 14, 10, 6, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 18,x = 8,y = 15) == [36, 40, 46, 44, 36, 30, 24, 20, 16, 10, 4, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 15,x = 3,y = 13) == [30, 34, 40, 42, 40, 16, 8, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 50,x = 5,y = 45) == [100, 104, 110, 116, 122, 126, 126, 124, 122, 120, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 36, 28, 20, 12, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 20,x = 7,y = 15) == [40, 44, 50, 56, 44, 42, 38, 30, 20, 10, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 100,x = 30,y = 95) == [200, 204, 210, 216, 222, 228, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 270, 272, 274, 276, 278, 278, 276, 208, 136, 126, 116, 108, 100, 94, 90, 86, 82, 78, 74, 70, 66, 62, 58, 54, 50, 46, 42, 38, 34, 30, 26, 22, 18, 14, 10, 6, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 40,x = 15,y = 35) == [80, 84, 90, 96, 102, 108, 112, 114, 116, 118, 78, 72, 66, 60, 54, 46, 40, 34, 28, 22, 16, 12, 8, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 85,x = 25,y = 80) == [170, 174, 180, 186, 192, 198, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 222, 224, 226, 228, 230, 232, 234, 236, 238, 238, 236, 178, 116, 106, 96, 88, 80, 74, 70, 66, 62, 58, 54, 50, 46, 42, 38, 34, 30, 26, 22, 18, 14, 10, 6, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 35,x = 15,y = 25) == [70, 74, 80, 86, 92, 76, 74, 72, 70, 68, 66, 62, 56, 50, 44, 36, 30, 24, 18, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 90,x = 40,y = 80) == [180, 184, 190, 196, 202, 208, 214, 220, 226, 232, 238, 242, 244, 246, 248, 250, 252, 254, 256, 258, 178, 172, 166, 160, 154, 148, 142, 136, 130, 124, 118, 116, 114, 112, 110, 108, 106, 104, 102, 100, 96, 90, 84, 78, 72, 66, 60, 54, 48, 42, 36, 32, 28, 24, 20, 16, 12, 8, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 55,x = 10,y = 45) == [110, 114, 120, 126, 132, 138, 144, 150, 156, 162, 166, 166, 164, 162, 160, 158, 156, 118, 76, 66, 56, 48, 40, 32, 24, 16, 8, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 80,x = 25,y = 75) == [160, 164, 170, 176, 182, 188, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 222, 224, 226, 228, 126, 116, 106, 96, 86, 76, 72, 68, 64, 60, 56, 52, 48, 44, 40, 36, 32, 28, 24, 20, 16, 12, 8, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 40,x = 15,y = 25) == [80, 84, 90, 96, 102, 86, 84, 82, 80, 78, 76, 74, 72, 70, 68, 64, 56, 46, 36, 26, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 70,x = 30,y = 50) == [140, 144, 150, 156, 162, 168, 174, 180, 186, 192, 156, 154, 152, 150, 148, 146, 144, 142, 140, 138, 136, 132, 126, 120, 114, 108, 102, 96, 90, 84, 76, 70, 64, 58, 52, 46, 40, 34, 28, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 80,x = 40,y = 50) == [160, 164, 170, 176, 182, 166, 164, 162, 160, 158, 156, 154, 152, 150, 148, 146, 144, 142, 140, 138, 136, 134, 132, 130, 128, 126, 124, 122, 120, 118, 116, 112, 106, 100, 94, 88, 86, 84, 82, 80, 76, 70, 64, 58, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 20,x = 10,y = 10) == [38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0]\n assert candidate(n = 65,x = 5,y = 60) == [130, 134, 140, 146, 152, 156, 156, 154, 152, 150, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 92, 32, 24, 16, 8, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 70,x = 25,y = 55) == [140, 144, 150, 156, 162, 168, 174, 180, 186, 192, 198, 204, 210, 216, 222, 166, 162, 156, 150, 144, 138, 132, 126, 120, 114, 106, 96, 86, 76, 66, 56, 50, 44, 38, 32, 26, 20, 14, 8, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 30,x = 15,y = 20) == [60, 64, 64, 60, 58, 56, 54, 52, 50, 48, 46, 42, 36, 32, 30, 26, 20, 16, 14, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0]\n assert candidate(n = 20,x = 7,y = 14) == [40, 44, 50, 48, 42, 40, 38, 32, 22, 12, 6, 4, 2, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 24,x = 4,y = 21) == [48, 52, 58, 64, 66, 64, 62, 60, 42, 20, 12, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 50,x = 25,y = 26) == [98, 96, 94, 92, 90, 88, 86, 84, 82, 80, 78, 76, 74, 72, 70, 68, 66, 64, 62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0]\n assert candidate(n = 15,x = 7,y = 8) == [28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0]\n assert candidate(n = 80,x = 40,y = 60) == [160, 164, 170, 176, 182, 188, 194, 200, 206, 212, 176, 174, 172, 170, 168, 166, 164, 162, 160, 158, 156, 152, 146, 140, 134, 128, 122, 116, 110, 104, 98, 96, 94, 92, 90, 88, 86, 84, 82, 80, 76, 70, 64, 58, 52, 46, 40, 34, 28, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 55,x = 15,y = 50) == [110, 114, 120, 126, 132, 138, 142, 144, 146, 148, 150, 152, 154, 156, 158, 158, 156, 118, 76, 66, 56, 48, 40, 34, 30, 26, 22, 18, 14, 10, 6, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 15,x = 3,y = 12) == [30, 34, 40, 44, 34, 18, 8, 2, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 50,x = 20,y = 30) == [100, 104, 110, 116, 122, 106, 104, 102, 100, 98, 96, 94, 92, 90, 88, 86, 84, 82, 80, 78, 74, 66, 56, 46, 36, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 100,x = 50,y = 95) == [200, 204, 210, 216, 222, 228, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 218, 170, 164, 158, 152, 146, 142, 140, 138, 136, 134, 132, 130, 128, 126, 124, 122, 120, 118, 116, 114, 112, 110, 108, 106, 104, 102, 100, 96, 90, 84, 78, 72, 66, 62, 58, 54, 50, 46, 42, 38, 34, 30, 26, 22, 18, 14, 10, 6, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 100,x = 50,y = 75) == [200, 204, 210, 216, 222, 228, 234, 240, 246, 252, 258, 264, 244, 220, 218, 216, 214, 212, 210, 208, 206, 204, 202, 200, 198, 196, 192, 186, 180, 174, 168, 162, 156, 150, 144, 138, 132, 126, 122, 120, 118, 116, 114, 112, 110, 108, 106, 104, 102, 100, 96, 90, 84, 78, 72, 66, 60, 54, 48, 42, 36, 30, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 64,x = 7,y = 57) == [128, 132, 138, 144, 150, 156, 162, 166, 166, 164, 162, 160, 158, 156, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 52, 44, 36, 28, 20, 12, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 12,x = 2,y = 11) == [24, 28, 30, 28, 18, 4, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 50,x = 25,y = 45) == [100, 104, 110, 116, 122, 128, 132, 134, 136, 138, 98, 92, 86, 80, 74, 68, 66, 64, 62, 60, 58, 56, 54, 52, 50, 46, 40, 34, 28, 22, 16, 12, 8, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 25,x = 10,y = 20) == [50, 54, 60, 66, 72, 56, 52, 46, 40, 34, 26, 20, 14, 8, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 90,x = 40,y = 85) == [180, 184, 190, 196, 202, 208, 212, 214, 216, 218, 220, 222, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 198, 150, 144, 138, 132, 126, 122, 120, 118, 116, 114, 112, 110, 108, 106, 104, 102, 100, 96, 90, 84, 78, 72, 66, 62, 58, 54, 50, 46, 42, 38, 34, 30, 26, 22, 18, 14, 10, 6, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 20,x = 5,y = 15) == [40, 44, 50, 56, 62, 44, 36, 26, 16, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 45,x = 23,y = 23) == [88, 86, 84, 82, 80, 78, 76, 74, 72, 70, 68, 66, 64, 62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0]\n assert candidate(n = 100,x = 10,y = 90) == [200, 204, 210, 216, 222, 228, 234, 240, 246, 252, 256, 256, 254, 252, 250, 248, 246, 244, 242, 240, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 76, 68, 60, 52, 44, 36, 28, 20, 12, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 80,x = 30,y = 65) == [160, 164, 170, 176, 182, 188, 194, 200, 206, 212, 218, 224, 230, 236, 242, 248, 252, 218, 180, 174, 168, 162, 156, 150, 144, 138, 132, 126, 120, 114, 106, 96, 86, 78, 72, 66, 60, 54, 48, 42, 36, 30, 24, 18, 12, 6, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 25,x = 5,y = 20) == [50, 54, 60, 66, 72, 76, 76, 58, 36, 26, 16, 8, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 75,x = 25,y = 60) == [150, 154, 160, 166, 172, 178, 184, 190, 196, 202, 208, 214, 220, 226, 232, 238, 242, 208, 170, 164, 158, 152, 146, 140, 134, 126, 116, 106, 96, 86, 76, 66, 56, 48, 42, 36, 30, 24, 18, 12, 6, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 30,x = 15,y = 25) == [60, 64, 70, 76, 82, 66, 62, 56, 50, 44, 38, 36, 34, 32, 30, 26, 20, 14, 8, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 96,x = 9,y = 85) == [192, 196, 202, 208, 214, 220, 226, 232, 238, 242, 244, 246, 246, 244, 242, 240, 238, 236, 234, 232, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 76, 68, 60, 52, 44, 36, 28, 20, 12, 8, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 60,x = 15,y = 15) == [118, 116, 114, 112, 110, 108, 106, 104, 102, 100, 98, 96, 94, 92, 90, 88, 86, 84, 82, 80, 78, 76, 74, 72, 70, 68, 66, 64, 62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0]\n assert candidate(n = 60,x = 10,y = 50) == [120, 124, 130, 136, 142, 148, 154, 160, 166, 172, 176, 176, 174, 172, 170, 168, 166, 164, 162, 160, 76, 68, 60, 52, 44, 36, 28, 20, 12, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 40,x = 20,y = 30) == [80, 84, 90, 96, 102, 86, 84, 82, 80, 78, 76, 72, 66, 60, 54, 48, 46, 44, 42, 40, 36, 30, 24, 18, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 80,x = 8,y = 73) == [160, 164, 170, 176, 182, 188, 194, 200, 202, 200, 198, 196, 194, 192, 190, 188, 188, 188, 188, 188, 188, 188, 188, 188, 188, 188, 188, 188, 188, 188, 188, 188, 122, 52, 44, 36, 28, 20, 12, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 80,x = 40,y = 75) == [160, 164, 170, 176, 182, 188, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 178, 140, 134, 128, 122, 116, 112, 110, 108, 106, 104, 102, 100, 98, 96, 94, 92, 90, 88, 86, 84, 82, 80, 76, 70, 64, 58, 52, 46, 42, 38, 34, 30, 26, 22, 18, 14, 10, 6, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 18,x = 1,y = 18) == [36, 36, 36, 36, 36, 36, 36, 36, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 40,x = 5,y = 35) == [80, 84, 90, 96, 102, 106, 106, 104, 102, 100, 98, 98, 98, 98, 98, 36, 28, 20, 12, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 80,x = 20,y = 75) == [160, 164, 170, 176, 182, 188, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 218, 216, 214, 212, 210, 208, 208, 152, 92, 84, 76, 68, 60, 54, 50, 46, 42, 38, 34, 30, 26, 22, 18, 14, 10, 6, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 50,x = 1,y = 49) == [100, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 90,x = 30,y = 85) == [180, 184, 190, 196, 202, 208, 212, 214, 216, 218, 220, 222, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 198, 140, 134, 126, 116, 106, 98, 92, 86, 82, 78, 74, 70, 66, 62, 58, 54, 50, 46, 42, 38, 34, 30, 26, 22, 18, 14, 10, 6, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 60,x = 20,y = 40) == [120, 124, 130, 136, 142, 148, 154, 160, 166, 172, 136, 134, 132, 130, 128, 126, 124, 122, 120, 118, 114, 106, 96, 86, 76, 66, 56, 46, 36, 26, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 18,x = 3,y = 16) == [36, 40, 46, 48, 46, 44, 30, 12, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 30,x = 5,y = 25) == [60, 64, 70, 76, 82, 86, 86, 84, 82, 80, 36, 28, 20, 12, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 75,x = 10,y = 70) == [150, 154, 160, 166, 172, 178, 182, 184, 186, 188, 188, 186, 184, 182, 180, 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, 56, 48, 40, 32, 24, 16, 12, 8, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n"}, "metadata": {"canonical_parameter_names": ["n", "x", "y"], "leetcode_dataset_entry_point": "Solution().countOfPairs", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector countOfPairs(int n, int x, int y) {", "container": "Solution", "callable": "countOfPairs", "parameters": [{"name": "n", "type": "int"}, {"name": "x", "type": "int"}, {"name": "y", "type": "int"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3016, "task_id": "minimum-number-of-pushes-to-type-word-ii", "difficulty": "Medium", "problem_description": "You are given a string word containing lowercase English letters.\nTelephone keypads have keys mapped with distinct collections of lowercase English letters, which can be used to form words by pushing them. For example, the key 2 is mapped with [\"a\",\"b\",\"c\"], we need to push the key one time to type \"a\", two times to type \"b\", and three times to type \"c\" .\nIt is allowed to remap the keys numbered 2 to 9 to distinct collections of letters. The keys can be remapped to any amount of letters, but each letter must be mapped to exactly one key. You need to find the minimum number of times the keys will be pushed to type the string word.\nReturn the minimum number of pushes needed to type word after remapping the keys.\nAn example mapping of letters to keys on a telephone keypad is given below. Note that 1, *, #, and 0 do not map to any letters.\n\n \nExample 1:\n\n\nInput: word = \"abcde\"\nOutput: 5\nExplanation: The remapped keypad given in the image provides the minimum cost.\n\"a\" -> one push on key 2\n\"b\" -> one push on key 3\n\"c\" -> one push on key 4\n\"d\" -> one push on key 5\n\"e\" -> one push on key 6\nTotal cost is 1 + 1 + 1 + 1 + 1 = 5.\nIt can be shown that no other mapping can provide a lower cost.\n\nExample 2:\n\n\nInput: word = \"xyzxyzxyzxyz\"\nOutput: 12\nExplanation: The remapped keypad given in the image provides the minimum cost.\n\"x\" -> one push on key 2\n\"y\" -> one push on key 3\n\"z\" -> one push on key 4\nTotal cost is 1 * 4 + 1 * 4 + 1 * 4 = 12\nIt can be shown that no other mapping can provide a lower cost.\nNote that the key 9 is not mapped to any letter: it is not necessary to map letters to every key, but to map all the letters.\n\nExample 3:\n\n\nInput: word = \"aabbccddeeffgghhiiiiii\"\nOutput: 24\nExplanation: The remapped keypad given in the image provides the minimum cost.\n\"a\" -> one push on key 2\n\"b\" -> one push on key 3\n\"c\" -> one push on key 4\n\"d\" -> one push on key 5\n\"e\" -> one push on key 6\n\"f\" -> one push on key 7\n\"g\" -> one push on key 8\n\"h\" -> two pushes on key 9\n\"i\" -> one push on key 9\nTotal cost is 1 * 2 + 1 * 2 + 1 * 2 + 1 * 2 + 1 * 2 + 1 * 2 + 1 * 2 + 2 * 2 + 6 * 1 = 24.\nIt can be shown that no other mapping can provide a lower cost.\n\n \nConstraints:\n\n1 <= word.length <= 105\nword consists of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 52\n assert candidate(word = \"abcde\") == 5\n assert candidate(word = \"zyxwvutsrqponmlkjihgfedcba\") == 56\n assert candidate(word = \"mississippi\") == 11\n assert candidate(word = \"qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\") == 52\n assert candidate(word = \"aaaabbbbccccddddeeeeffffgggghhhhiiiiiiiiiijjjjjjjjjjkkkkkkkkkkkllllllllllllmmmmmmmmmmmmmmmnnnnnnnnnnnnnnnnoooooooppppppppppppppppqqqqqqqqqqqqqqqqrrrrrrrrrrrrrrrrrsssssssssssssssstttttttttttttttttuuuuuuuuuuuuuuuuuvvvvvvvvvvvvvvvvvwwwwwwwwwwwwwwwwwxxxxxxxxxyyyyyyyyyyyyyyyyyzzzzzzzzzzzzzzzzz\") == 499\n assert candidate(word = \"hellohellohellohellohellohellohellohellohellohello\") == 50\n assert candidate(word = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabad\") == 88\n assert candidate(word = \"xyzxyzxyzxyz\") == 12\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyz\") == 56\n assert candidate(word = \"a\") == 1\n assert candidate(word = \"aaabbbcccdddeeefffggghhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz\") == 198\n assert candidate(word = \"ababababababababababababababababababababab\") == 42\n assert candidate(word = \"aabbccddeeffgghhiiiiii\") == 24\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 98\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 168\n assert candidate(word = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabad\") == 104\n assert candidate(word = \"ppppppppppppppppppppppppppppppppppppppppppppppppppppqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\") == 104\n assert candidate(word = \"mississippimississippimississippimississippi\") == 44\n assert candidate(word = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 162\n assert candidate(word = \"loremipsumdolorsitametconsecteturadipiscingelitloremipsumdolorsitametconsecteturadipiscingelitloremipsumdolorsitametconsecteturadipiscingelit\") == 183\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyzzzzzzzzzzzzzzzzzzzzzzzz\") == 79\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 143\n assert candidate(word = \"onelongwordwithoutrepetitionsonelongwordwithoutrepetitions\") == 70\n assert candidate(word = \"thequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydog\") == 130\n assert candidate(word = \"uniquelettersabcdefghijklmnopqrstuvwxyzuniqueletters\") == 84\n assert candidate(word = \"aaaaaaaaaabbbbbbbbccccccccddddddddeeeeeeeffffffffggggggghhhhhhhh\") == 64\n assert candidate(word = \"nnnnneeeeffffddddeeeeffffddddddddddddeeeeeeeeeeeeeeeeffffffddddddddddddddeeeeeeeeeeeeeeeeffffffdddddddddddddeeeeeeeeeeeeee\") == 122\n assert candidate(word = \"equalprobabilityabcdefghijklmnopqrstuvwxyz\") == 76\n assert candidate(word = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 136\n assert candidate(word = \"ppppoooolllliiiihhhhggggffffeeeeeeeedddddccccbbbaaa\") == 65\n assert candidate(word = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzz\") == 114\n assert candidate(word = \"qwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnm\") == 112\n assert candidate(word = \"mnbvcxzvbnmzxcvbnmxcvbnmxcvbnmxcvbnmxcvbnmxcvbnmxcvbnmxcvbnmxcvbnmxcvbnmxcvbnmxcvbnmxcvbnmxcvbnmxcvbnm\") == 102\n assert candidate(word = \"aaaabbbbccccddddeeeeffffgggghhhhiiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz\") == 225\n assert candidate(word = \"repeatedrepeatedrepeatedrepeatedrepeatedrepeated\") == 48\n assert candidate(word = \"aabbcdeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 104\n assert candidate(word = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 112\n assert candidate(word = \"frequencydistributionfrequencydistribution\") == 54\n assert candidate(word = \"programmingproblemsolvingprogramming\") == 42\n assert candidate(word = \"qwertyuiopqwertyuiopqwertyuiopqwertyuiopqwertyuiopqwertyuiopqwertyuiopqwertyuiopqwertyuiopqwertyuiopqwertyuiop\") == 132\n assert candidate(word = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 56\n assert candidate(word = \"mississippiissippiissippi\") == 25\n assert candidate(word = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 170\n assert candidate(word = \"abcdefghijklnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 108\n assert candidate(word = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzz\") == 120\n assert candidate(word = \"frequentfrequentfrequentfrequentfrequentfrequentfrequentfrequentfrequentfrequent\") == 80\n"}, "metadata": {"canonical_parameter_names": ["word"], "leetcode_dataset_entry_point": "Solution().minimumPushes", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumPushes(string word) {", "container": "Solution", "callable": "minimumPushes", "parameters": [{"name": "word", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3017, "task_id": "count-the-number-of-houses-at-a-certain-distance-ii", "difficulty": "Hard", "problem_description": "You are given three positive integers n, x, and y.\nIn a city, there exist houses numbered 1 to n connected by n streets. There is a street connecting the house numbered i with the house numbered i + 1 for all 1 <= i <= n - 1 . An additional street connects the house numbered x with the house numbered y.\nFor each k, such that 1 <= k <= n, you need to find the number of pairs of houses (house1, house2) such that the minimum number of streets that need to be traveled to reach house2 from house1 is k.\nReturn a 1-indexed array result of length n where result[k] represents the total number of pairs of houses such that the minimum streets required to reach one house from the other is k.\nNote that x and y can be equal.\n \nExample 1:\n\n\nInput: n = 3, x = 1, y = 3\nOutput: [6,0,0]\nExplanation: Let's look at each pair of houses:\n- For the pair (1, 2), we can go from house 1 to house 2 directly.\n- For the pair (2, 1), we can go from house 2 to house 1 directly.\n- For the pair (1, 3), we can go from house 1 to house 3 directly.\n- For the pair (3, 1), we can go from house 3 to house 1 directly.\n- For the pair (2, 3), we can go from house 2 to house 3 directly.\n- For the pair (3, 2), we can go from house 3 to house 2 directly.\n\nExample 2:\n\n\nInput: n = 5, x = 2, y = 4\nOutput: [10,8,2,0,0]\nExplanation: For each distance k the pairs are:\n- For k == 1, the pairs are (1, 2), (2, 1), (2, 3), (3, 2), (2, 4), (4, 2), (3, 4), (4, 3), (4, 5), and (5, 4).\n- For k == 2, the pairs are (1, 3), (3, 1), (1, 4), (4, 1), (2, 5), (5, 2), (3, 5), and (5, 3).\n- For k == 3, the pairs are (1, 5), and (5, 1).\n- For k == 4 and k == 5, there are no pairs.\n\nExample 3:\n\n\nInput: n = 4, x = 1, y = 1\nOutput: [6,4,2,0]\nExplanation: For each distance k the pairs are:\n- For k == 1, the pairs are (1, 2), (2, 1), (2, 3), (3, 2), (3, 4), and (4, 3).\n- For k == 2, the pairs are (1, 3), (3, 1), (2, 4), and (4, 2).\n- For k == 3, the pairs are (1, 4), and (4, 1).\n- For k == 4, there are no pairs.\n\n \nConstraints:\n\n2 <= n <= 105\n1 <= x, y <= n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 10,x = 3,y = 7) == [20, 24, 20, 16, 8, 2, 0, 0, 0, 0]\n assert candidate(n = 10,x = 3,y = 8) == [20, 24, 24, 16, 6, 0, 0, 0, 0, 0]\n assert candidate(n = 4,x = 1,y = 1) == [6, 4, 2, 0]\n assert candidate(n = 5,x = 2,y = 4) == [10, 8, 2, 0, 0]\n assert candidate(n = 6,x = 2,y = 5) == [12, 12, 6, 0, 0, 0]\n assert candidate(n = 3,x = 1,y = 3) == [6, 0, 0]\n assert candidate(n = 7,x = 1,y = 7) == [14, 14, 14, 0, 0, 0, 0]\n assert candidate(n = 9,x = 2,y = 8) == [18, 22, 24, 8, 0, 0, 0, 0, 0]\n assert candidate(n = 100,x = 50,y = 50) == [198, 196, 194, 192, 190, 188, 186, 184, 182, 180, 178, 176, 174, 172, 170, 168, 166, 164, 162, 160, 158, 156, 154, 152, 150, 148, 146, 144, 142, 140, 138, 136, 134, 132, 130, 128, 126, 124, 122, 120, 118, 116, 114, 112, 110, 108, 106, 104, 102, 100, 98, 96, 94, 92, 90, 88, 86, 84, 82, 80, 78, 76, 74, 72, 70, 68, 66, 64, 62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0]\n assert candidate(n = 50,x = 10,y = 40) == [100, 104, 110, 116, 122, 128, 134, 140, 146, 152, 156, 156, 154, 152, 150, 86, 76, 66, 56, 46, 36, 28, 20, 12, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 30,x = 2,y = 29) == [60, 64, 66, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 36, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 80,x = 40,y = 41) == [158, 156, 154, 152, 150, 148, 146, 144, 142, 140, 138, 136, 134, 132, 130, 128, 126, 124, 122, 120, 118, 116, 114, 112, 110, 108, 106, 104, 102, 100, 98, 96, 94, 92, 90, 88, 86, 84, 82, 80, 78, 76, 74, 72, 70, 68, 66, 64, 62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0]\n assert candidate(n = 25,x = 10,y = 12) == [50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 28, 26, 24, 22, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 0]\n assert candidate(n = 1000,x = 300,y = 700) == [2000, 2004, 2010, 2016, 2022, 2028, 2034, 2040, 2046, 2052, 2058, 2064, 2070, 2076, 2082, 2088, 2094, 2100, 2106, 2112, 2118, 2124, 2130, 2136, 2142, 2148, 2154, 2160, 2166, 2172, 2178, 2184, 2190, 2196, 2202, 2208, 2214, 2220, 2226, 2232, 2238, 2244, 2250, 2256, 2262, 2268, 2274, 2280, 2286, 2292, 2298, 2304, 2310, 2316, 2322, 2328, 2334, 2340, 2346, 2352, 2358, 2364, 2370, 2376, 2382, 2388, 2394, 2400, 2406, 2412, 2418, 2424, 2430, 2436, 2442, 2448, 2454, 2460, 2466, 2472, 2478, 2484, 2490, 2496, 2502, 2508, 2514, 2520, 2526, 2532, 2538, 2544, 2550, 2556, 2562, 2568, 2574, 2580, 2586, 2592, 2598, 2604, 2610, 2616, 2622, 2628, 2634, 2640, 2646, 2652, 2658, 2664, 2670, 2676, 2682, 2688, 2694, 2700, 2706, 2712, 2718, 2724, 2730, 2736, 2742, 2748, 2754, 2760, 2766, 2772, 2778, 2784, 2790, 2796, 2802, 2808, 2814, 2820, 2826, 2832, 2838, 2844, 2850, 2856, 2862, 2868, 2874, 2880, 2886, 2892, 2898, 2904, 2910, 2916, 2922, 2928, 2934, 2940, 2946, 2952, 2958, 2964, 2970, 2976, 2982, 2988, 2994, 3000, 3006, 3012, 3018, 3024, 3030, 3036, 3042, 3048, 3054, 3060, 3066, 3072, 3078, 3084, 3090, 3096, 3102, 3108, 3114, 3120, 3126, 3132, 3138, 3144, 3150, 3156, 3162, 3168, 3174, 3180, 3186, 3192, 2396, 2394, 2392, 2390, 2388, 2386, 2384, 2382, 2380, 2378, 2376, 2374, 2372, 2370, 2368, 2366, 2364, 2362, 2360, 2358, 2356, 2354, 2352, 2350, 2348, 2346, 2344, 2342, 2340, 2338, 2336, 2334, 2332, 2330, 2328, 2326, 2324, 2322, 2320, 2318, 2316, 2314, 2312, 2310, 2308, 2306, 2304, 2302, 2300, 2298, 2296, 2294, 2292, 2290, 2288, 2286, 2284, 2282, 2280, 2278, 2276, 2274, 2272, 2270, 2268, 2266, 2264, 2262, 2260, 2258, 2256, 2254, 2252, 2250, 2248, 2246, 2244, 2242, 2240, 2238, 2236, 2234, 2232, 2230, 2228, 2226, 2224, 2222, 2220, 2218, 2216, 2214, 2212, 2210, 2208, 2206, 2204, 2202, 2200, 2198, 2194, 2186, 2176, 2166, 2156, 2146, 2136, 2126, 2116, 2106, 2096, 2086, 2076, 2066, 2056, 2046, 2036, 2026, 2016, 2006, 1996, 1986, 1976, 1966, 1956, 1946, 1936, 1926, 1916, 1906, 1896, 1886, 1876, 1866, 1856, 1846, 1836, 1826, 1816, 1806, 1796, 1786, 1776, 1766, 1756, 1746, 1736, 1726, 1716, 1706, 1696, 1686, 1676, 1666, 1656, 1646, 1636, 1626, 1616, 1606, 1596, 1586, 1576, 1566, 1556, 1546, 1536, 1526, 1516, 1506, 1496, 1486, 1476, 1466, 1456, 1446, 1436, 1426, 1416, 1406, 1396, 1386, 1376, 1366, 1356, 1346, 1336, 1326, 1316, 1306, 1296, 1286, 1276, 1266, 1256, 1246, 1236, 1226, 1216, 1206, 1196, 1186, 1176, 1166, 1156, 1146, 1136, 1126, 1116, 1106, 1096, 1086, 1076, 1066, 1056, 1046, 1036, 1026, 1016, 1006, 996, 986, 976, 966, 956, 946, 936, 926, 916, 906, 896, 886, 876, 866, 856, 846, 836, 826, 816, 806, 796, 786, 776, 766, 756, 746, 736, 726, 716, 706, 696, 686, 676, 666, 656, 646, 636, 626, 616, 606, 596, 586, 576, 566, 556, 546, 536, 526, 516, 506, 496, 486, 476, 466, 456, 446, 436, 426, 416, 406, 396, 386, 376, 366, 356, 346, 336, 326, 316, 306, 296, 286, 276, 266, 256, 246, 236, 226, 216, 206, 200, 198, 196, 194, 192, 190, 188, 186, 184, 182, 180, 178, 176, 174, 172, 170, 168, 166, 164, 162, 160, 158, 156, 154, 152, 150, 148, 146, 144, 142, 140, 138, 136, 134, 132, 130, 128, 126, 124, 122, 120, 118, 116, 114, 112, 110, 108, 106, 104, 102, 100, 98, 96, 94, 92, 90, 88, 86, 84, 82, 80, 78, 76, 74, 72, 70, 68, 66, 64, 62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 100,x = 2,y = 99) == [200, 204, 206, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, 106, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 200,x = 100,y = 100) == [398, 396, 394, 392, 390, 388, 386, 384, 382, 380, 378, 376, 374, 372, 370, 368, 366, 364, 362, 360, 358, 356, 354, 352, 350, 348, 346, 344, 342, 340, 338, 336, 334, 332, 330, 328, 326, 324, 322, 320, 318, 316, 314, 312, 310, 308, 306, 304, 302, 300, 298, 296, 294, 292, 290, 288, 286, 284, 282, 280, 278, 276, 274, 272, 270, 268, 266, 264, 262, 260, 258, 256, 254, 252, 250, 248, 246, 244, 242, 240, 238, 236, 234, 232, 230, 228, 226, 224, 222, 220, 218, 216, 214, 212, 210, 208, 206, 204, 202, 200, 198, 196, 194, 192, 190, 188, 186, 184, 182, 180, 178, 176, 174, 172, 170, 168, 166, 164, 162, 160, 158, 156, 154, 152, 150, 148, 146, 144, 142, 140, 138, 136, 134, 132, 130, 128, 126, 124, 122, 120, 118, 116, 114, 112, 110, 108, 106, 104, 102, 100, 98, 96, 94, 92, 90, 88, 86, 84, 82, 80, 78, 76, 74, 72, 70, 68, 66, 64, 62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0]\n assert candidate(n = 500,x = 1,y = 500) == [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 25,x = 10,y = 15) == [50, 54, 54, 50, 48, 46, 44, 42, 40, 38, 34, 26, 18, 14, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0]\n assert candidate(n = 500,x = 100,y = 400) == [1000, 1004, 1010, 1016, 1022, 1028, 1034, 1040, 1046, 1052, 1058, 1064, 1070, 1076, 1082, 1088, 1094, 1100, 1106, 1112, 1118, 1124, 1130, 1136, 1142, 1148, 1154, 1160, 1166, 1172, 1178, 1184, 1190, 1196, 1202, 1208, 1214, 1220, 1226, 1232, 1238, 1244, 1250, 1256, 1262, 1268, 1274, 1280, 1286, 1292, 1298, 1304, 1310, 1316, 1322, 1328, 1334, 1340, 1346, 1352, 1358, 1364, 1370, 1376, 1382, 1388, 1394, 1400, 1406, 1412, 1418, 1424, 1430, 1436, 1442, 1448, 1454, 1460, 1466, 1472, 1478, 1484, 1490, 1496, 1502, 1508, 1514, 1520, 1526, 1532, 1538, 1544, 1550, 1556, 1562, 1568, 1574, 1580, 1586, 1592, 1596, 1596, 1594, 1592, 1590, 1588, 1586, 1584, 1582, 1580, 1578, 1576, 1574, 1572, 1570, 1568, 1566, 1564, 1562, 1560, 1558, 1556, 1554, 1552, 1550, 1548, 1546, 1544, 1542, 1540, 1538, 1536, 1534, 1532, 1530, 1528, 1526, 1524, 1522, 1520, 1518, 1516, 1514, 1512, 1510, 1508, 1506, 1504, 1502, 1500, 896, 886, 876, 866, 856, 846, 836, 826, 816, 806, 796, 786, 776, 766, 756, 746, 736, 726, 716, 706, 696, 686, 676, 666, 656, 646, 636, 626, 616, 606, 596, 586, 576, 566, 556, 546, 536, 526, 516, 506, 496, 486, 476, 466, 456, 446, 436, 426, 416, 406, 396, 388, 380, 372, 364, 356, 348, 340, 332, 324, 316, 308, 300, 292, 284, 276, 268, 260, 252, 244, 236, 228, 220, 212, 204, 196, 188, 180, 172, 164, 156, 148, 140, 132, 124, 116, 108, 100, 92, 84, 76, 68, 60, 52, 44, 36, 28, 20, 12, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 100,x = 5,y = 95) == [200, 204, 210, 216, 222, 226, 226, 224, 222, 220, 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, 36, 28, 20, 12, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 75,x = 30,y = 45) == [150, 154, 160, 166, 172, 178, 184, 174, 160, 158, 156, 154, 152, 150, 148, 146, 144, 142, 140, 138, 136, 134, 132, 130, 128, 126, 124, 122, 120, 118, 114, 106, 96, 86, 76, 66, 56, 48, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 500,x = 250,y = 251) == [998, 996, 994, 992, 990, 988, 986, 984, 982, 980, 978, 976, 974, 972, 970, 968, 966, 964, 962, 960, 958, 956, 954, 952, 950, 948, 946, 944, 942, 940, 938, 936, 934, 932, 930, 928, 926, 924, 922, 920, 918, 916, 914, 912, 910, 908, 906, 904, 902, 900, 898, 896, 894, 892, 890, 888, 886, 884, 882, 880, 878, 876, 874, 872, 870, 868, 866, 864, 862, 860, 858, 856, 854, 852, 850, 848, 846, 844, 842, 840, 838, 836, 834, 832, 830, 828, 826, 824, 822, 820, 818, 816, 814, 812, 810, 808, 806, 804, 802, 800, 798, 796, 794, 792, 790, 788, 786, 784, 782, 780, 778, 776, 774, 772, 770, 768, 766, 764, 762, 760, 758, 756, 754, 752, 750, 748, 746, 744, 742, 740, 738, 736, 734, 732, 730, 728, 726, 724, 722, 720, 718, 716, 714, 712, 710, 708, 706, 704, 702, 700, 698, 696, 694, 692, 690, 688, 686, 684, 682, 680, 678, 676, 674, 672, 670, 668, 666, 664, 662, 660, 658, 656, 654, 652, 650, 648, 646, 644, 642, 640, 638, 636, 634, 632, 630, 628, 626, 624, 622, 620, 618, 616, 614, 612, 610, 608, 606, 604, 602, 600, 598, 596, 594, 592, 590, 588, 586, 584, 582, 580, 578, 576, 574, 572, 570, 568, 566, 564, 562, 560, 558, 556, 554, 552, 550, 548, 546, 544, 542, 540, 538, 536, 534, 532, 530, 528, 526, 524, 522, 520, 518, 516, 514, 512, 510, 508, 506, 504, 502, 500, 498, 496, 494, 492, 490, 488, 486, 484, 482, 480, 478, 476, 474, 472, 470, 468, 466, 464, 462, 460, 458, 456, 454, 452, 450, 448, 446, 444, 442, 440, 438, 436, 434, 432, 430, 428, 426, 424, 422, 420, 418, 416, 414, 412, 410, 408, 406, 404, 402, 400, 398, 396, 394, 392, 390, 388, 386, 384, 382, 380, 378, 376, 374, 372, 370, 368, 366, 364, 362, 360, 358, 356, 354, 352, 350, 348, 346, 344, 342, 340, 338, 336, 334, 332, 330, 328, 326, 324, 322, 320, 318, 316, 314, 312, 310, 308, 306, 304, 302, 300, 298, 296, 294, 292, 290, 288, 286, 284, 282, 280, 278, 276, 274, 272, 270, 268, 266, 264, 262, 260, 258, 256, 254, 252, 250, 248, 246, 244, 242, 240, 238, 236, 234, 232, 230, 228, 226, 224, 222, 220, 218, 216, 214, 212, 210, 208, 206, 204, 202, 200, 198, 196, 194, 192, 190, 188, 186, 184, 182, 180, 178, 176, 174, 172, 170, 168, 166, 164, 162, 160, 158, 156, 154, 152, 150, 148, 146, 144, 142, 140, 138, 136, 134, 132, 130, 128, 126, 124, 122, 120, 118, 116, 114, 112, 110, 108, 106, 104, 102, 100, 98, 96, 94, 92, 90, 88, 86, 84, 82, 80, 78, 76, 74, 72, 70, 68, 66, 64, 62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0]\n assert candidate(n = 75,x = 25,y = 75) == [150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 96, 92, 88, 84, 80, 76, 72, 68, 64, 60, 56, 52, 48, 44, 40, 36, 32, 28, 24, 20, 16, 12, 8, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 100,x = 25,y = 75) == [200, 204, 210, 216, 222, 228, 234, 240, 246, 252, 258, 264, 270, 276, 282, 288, 294, 300, 306, 312, 318, 324, 330, 336, 342, 244, 236, 226, 216, 206, 196, 186, 176, 166, 156, 146, 136, 126, 116, 106, 96, 86, 76, 66, 56, 46, 36, 26, 16, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 15,x = 5,y = 12) == [30, 34, 40, 38, 30, 22, 12, 4, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 150,x = 75,y = 76) == [298, 296, 294, 292, 290, 288, 286, 284, 282, 280, 278, 276, 274, 272, 270, 268, 266, 264, 262, 260, 258, 256, 254, 252, 250, 248, 246, 244, 242, 240, 238, 236, 234, 232, 230, 228, 226, 224, 222, 220, 218, 216, 214, 212, 210, 208, 206, 204, 202, 200, 198, 196, 194, 192, 190, 188, 186, 184, 182, 180, 178, 176, 174, 172, 170, 168, 166, 164, 162, 160, 158, 156, 154, 152, 150, 148, 146, 144, 142, 140, 138, 136, 134, 132, 130, 128, 126, 124, 122, 120, 118, 116, 114, 112, 110, 108, 106, 104, 102, 100, 98, 96, 94, 92, 90, 88, 86, 84, 82, 80, 78, 76, 74, 72, 70, 68, 66, 64, 62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0]\n assert candidate(n = 80,x = 5,y = 75) == [160, 164, 170, 176, 182, 186, 186, 184, 182, 180, 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, 36, 28, 20, 12, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 100,x = 40,y = 60) == [200, 204, 210, 216, 222, 228, 234, 240, 246, 252, 216, 214, 212, 210, 208, 206, 204, 202, 200, 198, 196, 194, 192, 190, 188, 186, 184, 182, 180, 178, 176, 174, 172, 170, 168, 166, 164, 162, 160, 158, 154, 146, 136, 126, 116, 106, 96, 86, 76, 66, 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 50,x = 1,y = 50) == [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 500,x = 250,y = 250) == [998, 996, 994, 992, 990, 988, 986, 984, 982, 980, 978, 976, 974, 972, 970, 968, 966, 964, 962, 960, 958, 956, 954, 952, 950, 948, 946, 944, 942, 940, 938, 936, 934, 932, 930, 928, 926, 924, 922, 920, 918, 916, 914, 912, 910, 908, 906, 904, 902, 900, 898, 896, 894, 892, 890, 888, 886, 884, 882, 880, 878, 876, 874, 872, 870, 868, 866, 864, 862, 860, 858, 856, 854, 852, 850, 848, 846, 844, 842, 840, 838, 836, 834, 832, 830, 828, 826, 824, 822, 820, 818, 816, 814, 812, 810, 808, 806, 804, 802, 800, 798, 796, 794, 792, 790, 788, 786, 784, 782, 780, 778, 776, 774, 772, 770, 768, 766, 764, 762, 760, 758, 756, 754, 752, 750, 748, 746, 744, 742, 740, 738, 736, 734, 732, 730, 728, 726, 724, 722, 720, 718, 716, 714, 712, 710, 708, 706, 704, 702, 700, 698, 696, 694, 692, 690, 688, 686, 684, 682, 680, 678, 676, 674, 672, 670, 668, 666, 664, 662, 660, 658, 656, 654, 652, 650, 648, 646, 644, 642, 640, 638, 636, 634, 632, 630, 628, 626, 624, 622, 620, 618, 616, 614, 612, 610, 608, 606, 604, 602, 600, 598, 596, 594, 592, 590, 588, 586, 584, 582, 580, 578, 576, 574, 572, 570, 568, 566, 564, 562, 560, 558, 556, 554, 552, 550, 548, 546, 544, 542, 540, 538, 536, 534, 532, 530, 528, 526, 524, 522, 520, 518, 516, 514, 512, 510, 508, 506, 504, 502, 500, 498, 496, 494, 492, 490, 488, 486, 484, 482, 480, 478, 476, 474, 472, 470, 468, 466, 464, 462, 460, 458, 456, 454, 452, 450, 448, 446, 444, 442, 440, 438, 436, 434, 432, 430, 428, 426, 424, 422, 420, 418, 416, 414, 412, 410, 408, 406, 404, 402, 400, 398, 396, 394, 392, 390, 388, 386, 384, 382, 380, 378, 376, 374, 372, 370, 368, 366, 364, 362, 360, 358, 356, 354, 352, 350, 348, 346, 344, 342, 340, 338, 336, 334, 332, 330, 328, 326, 324, 322, 320, 318, 316, 314, 312, 310, 308, 306, 304, 302, 300, 298, 296, 294, 292, 290, 288, 286, 284, 282, 280, 278, 276, 274, 272, 270, 268, 266, 264, 262, 260, 258, 256, 254, 252, 250, 248, 246, 244, 242, 240, 238, 236, 234, 232, 230, 228, 226, 224, 222, 220, 218, 216, 214, 212, 210, 208, 206, 204, 202, 200, 198, 196, 194, 192, 190, 188, 186, 184, 182, 180, 178, 176, 174, 172, 170, 168, 166, 164, 162, 160, 158, 156, 154, 152, 150, 148, 146, 144, 142, 140, 138, 136, 134, 132, 130, 128, 126, 124, 122, 120, 118, 116, 114, 112, 110, 108, 106, 104, 102, 100, 98, 96, 94, 92, 90, 88, 86, 84, 82, 80, 78, 76, 74, 72, 70, 68, 66, 64, 62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0]\n assert candidate(n = 30,x = 15,y = 15) == [58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0]\n assert candidate(n = 50,x = 25,y = 25) == [98, 96, 94, 92, 90, 88, 86, 84, 82, 80, 78, 76, 74, 72, 70, 68, 66, 64, 62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0]\n assert candidate(n = 20,x = 4,y = 18) == [40, 44, 50, 54, 54, 52, 50, 20, 12, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 100,x = 50,y = 51) == [198, 196, 194, 192, 190, 188, 186, 184, 182, 180, 178, 176, 174, 172, 170, 168, 166, 164, 162, 160, 158, 156, 154, 152, 150, 148, 146, 144, 142, 140, 138, 136, 134, 132, 130, 128, 126, 124, 122, 120, 118, 116, 114, 112, 110, 108, 106, 104, 102, 100, 98, 96, 94, 92, 90, 88, 86, 84, 82, 80, 78, 76, 74, 72, 70, 68, 66, 64, 62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0]\n assert candidate(n = 300,x = 150,y = 151) == [598, 596, 594, 592, 590, 588, 586, 584, 582, 580, 578, 576, 574, 572, 570, 568, 566, 564, 562, 560, 558, 556, 554, 552, 550, 548, 546, 544, 542, 540, 538, 536, 534, 532, 530, 528, 526, 524, 522, 520, 518, 516, 514, 512, 510, 508, 506, 504, 502, 500, 498, 496, 494, 492, 490, 488, 486, 484, 482, 480, 478, 476, 474, 472, 470, 468, 466, 464, 462, 460, 458, 456, 454, 452, 450, 448, 446, 444, 442, 440, 438, 436, 434, 432, 430, 428, 426, 424, 422, 420, 418, 416, 414, 412, 410, 408, 406, 404, 402, 400, 398, 396, 394, 392, 390, 388, 386, 384, 382, 380, 378, 376, 374, 372, 370, 368, 366, 364, 362, 360, 358, 356, 354, 352, 350, 348, 346, 344, 342, 340, 338, 336, 334, 332, 330, 328, 326, 324, 322, 320, 318, 316, 314, 312, 310, 308, 306, 304, 302, 300, 298, 296, 294, 292, 290, 288, 286, 284, 282, 280, 278, 276, 274, 272, 270, 268, 266, 264, 262, 260, 258, 256, 254, 252, 250, 248, 246, 244, 242, 240, 238, 236, 234, 232, 230, 228, 226, 224, 222, 220, 218, 216, 214, 212, 210, 208, 206, 204, 202, 200, 198, 196, 194, 192, 190, 188, 186, 184, 182, 180, 178, 176, 174, 172, 170, 168, 166, 164, 162, 160, 158, 156, 154, 152, 150, 148, 146, 144, 142, 140, 138, 136, 134, 132, 130, 128, 126, 124, 122, 120, 118, 116, 114, 112, 110, 108, 106, 104, 102, 100, 98, 96, 94, 92, 90, 88, 86, 84, 82, 80, 78, 76, 74, 72, 70, 68, 66, 64, 62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0]\n assert candidate(n = 1000,x = 500,y = 500) == [1998, 1996, 1994, 1992, 1990, 1988, 1986, 1984, 1982, 1980, 1978, 1976, 1974, 1972, 1970, 1968, 1966, 1964, 1962, 1960, 1958, 1956, 1954, 1952, 1950, 1948, 1946, 1944, 1942, 1940, 1938, 1936, 1934, 1932, 1930, 1928, 1926, 1924, 1922, 1920, 1918, 1916, 1914, 1912, 1910, 1908, 1906, 1904, 1902, 1900, 1898, 1896, 1894, 1892, 1890, 1888, 1886, 1884, 1882, 1880, 1878, 1876, 1874, 1872, 1870, 1868, 1866, 1864, 1862, 1860, 1858, 1856, 1854, 1852, 1850, 1848, 1846, 1844, 1842, 1840, 1838, 1836, 1834, 1832, 1830, 1828, 1826, 1824, 1822, 1820, 1818, 1816, 1814, 1812, 1810, 1808, 1806, 1804, 1802, 1800, 1798, 1796, 1794, 1792, 1790, 1788, 1786, 1784, 1782, 1780, 1778, 1776, 1774, 1772, 1770, 1768, 1766, 1764, 1762, 1760, 1758, 1756, 1754, 1752, 1750, 1748, 1746, 1744, 1742, 1740, 1738, 1736, 1734, 1732, 1730, 1728, 1726, 1724, 1722, 1720, 1718, 1716, 1714, 1712, 1710, 1708, 1706, 1704, 1702, 1700, 1698, 1696, 1694, 1692, 1690, 1688, 1686, 1684, 1682, 1680, 1678, 1676, 1674, 1672, 1670, 1668, 1666, 1664, 1662, 1660, 1658, 1656, 1654, 1652, 1650, 1648, 1646, 1644, 1642, 1640, 1638, 1636, 1634, 1632, 1630, 1628, 1626, 1624, 1622, 1620, 1618, 1616, 1614, 1612, 1610, 1608, 1606, 1604, 1602, 1600, 1598, 1596, 1594, 1592, 1590, 1588, 1586, 1584, 1582, 1580, 1578, 1576, 1574, 1572, 1570, 1568, 1566, 1564, 1562, 1560, 1558, 1556, 1554, 1552, 1550, 1548, 1546, 1544, 1542, 1540, 1538, 1536, 1534, 1532, 1530, 1528, 1526, 1524, 1522, 1520, 1518, 1516, 1514, 1512, 1510, 1508, 1506, 1504, 1502, 1500, 1498, 1496, 1494, 1492, 1490, 1488, 1486, 1484, 1482, 1480, 1478, 1476, 1474, 1472, 1470, 1468, 1466, 1464, 1462, 1460, 1458, 1456, 1454, 1452, 1450, 1448, 1446, 1444, 1442, 1440, 1438, 1436, 1434, 1432, 1430, 1428, 1426, 1424, 1422, 1420, 1418, 1416, 1414, 1412, 1410, 1408, 1406, 1404, 1402, 1400, 1398, 1396, 1394, 1392, 1390, 1388, 1386, 1384, 1382, 1380, 1378, 1376, 1374, 1372, 1370, 1368, 1366, 1364, 1362, 1360, 1358, 1356, 1354, 1352, 1350, 1348, 1346, 1344, 1342, 1340, 1338, 1336, 1334, 1332, 1330, 1328, 1326, 1324, 1322, 1320, 1318, 1316, 1314, 1312, 1310, 1308, 1306, 1304, 1302, 1300, 1298, 1296, 1294, 1292, 1290, 1288, 1286, 1284, 1282, 1280, 1278, 1276, 1274, 1272, 1270, 1268, 1266, 1264, 1262, 1260, 1258, 1256, 1254, 1252, 1250, 1248, 1246, 1244, 1242, 1240, 1238, 1236, 1234, 1232, 1230, 1228, 1226, 1224, 1222, 1220, 1218, 1216, 1214, 1212, 1210, 1208, 1206, 1204, 1202, 1200, 1198, 1196, 1194, 1192, 1190, 1188, 1186, 1184, 1182, 1180, 1178, 1176, 1174, 1172, 1170, 1168, 1166, 1164, 1162, 1160, 1158, 1156, 1154, 1152, 1150, 1148, 1146, 1144, 1142, 1140, 1138, 1136, 1134, 1132, 1130, 1128, 1126, 1124, 1122, 1120, 1118, 1116, 1114, 1112, 1110, 1108, 1106, 1104, 1102, 1100, 1098, 1096, 1094, 1092, 1090, 1088, 1086, 1084, 1082, 1080, 1078, 1076, 1074, 1072, 1070, 1068, 1066, 1064, 1062, 1060, 1058, 1056, 1054, 1052, 1050, 1048, 1046, 1044, 1042, 1040, 1038, 1036, 1034, 1032, 1030, 1028, 1026, 1024, 1022, 1020, 1018, 1016, 1014, 1012, 1010, 1008, 1006, 1004, 1002, 1000, 998, 996, 994, 992, 990, 988, 986, 984, 982, 980, 978, 976, 974, 972, 970, 968, 966, 964, 962, 960, 958, 956, 954, 952, 950, 948, 946, 944, 942, 940, 938, 936, 934, 932, 930, 928, 926, 924, 922, 920, 918, 916, 914, 912, 910, 908, 906, 904, 902, 900, 898, 896, 894, 892, 890, 888, 886, 884, 882, 880, 878, 876, 874, 872, 870, 868, 866, 864, 862, 860, 858, 856, 854, 852, 850, 848, 846, 844, 842, 840, 838, 836, 834, 832, 830, 828, 826, 824, 822, 820, 818, 816, 814, 812, 810, 808, 806, 804, 802, 800, 798, 796, 794, 792, 790, 788, 786, 784, 782, 780, 778, 776, 774, 772, 770, 768, 766, 764, 762, 760, 758, 756, 754, 752, 750, 748, 746, 744, 742, 740, 738, 736, 734, 732, 730, 728, 726, 724, 722, 720, 718, 716, 714, 712, 710, 708, 706, 704, 702, 700, 698, 696, 694, 692, 690, 688, 686, 684, 682, 680, 678, 676, 674, 672, 670, 668, 666, 664, 662, 660, 658, 656, 654, 652, 650, 648, 646, 644, 642, 640, 638, 636, 634, 632, 630, 628, 626, 624, 622, 620, 618, 616, 614, 612, 610, 608, 606, 604, 602, 600, 598, 596, 594, 592, 590, 588, 586, 584, 582, 580, 578, 576, 574, 572, 570, 568, 566, 564, 562, 560, 558, 556, 554, 552, 550, 548, 546, 544, 542, 540, 538, 536, 534, 532, 530, 528, 526, 524, 522, 520, 518, 516, 514, 512, 510, 508, 506, 504, 502, 500, 498, 496, 494, 492, 490, 488, 486, 484, 482, 480, 478, 476, 474, 472, 470, 468, 466, 464, 462, 460, 458, 456, 454, 452, 450, 448, 446, 444, 442, 440, 438, 436, 434, 432, 430, 428, 426, 424, 422, 420, 418, 416, 414, 412, 410, 408, 406, 404, 402, 400, 398, 396, 394, 392, 390, 388, 386, 384, 382, 380, 378, 376, 374, 372, 370, 368, 366, 364, 362, 360, 358, 356, 354, 352, 350, 348, 346, 344, 342, 340, 338, 336, 334, 332, 330, 328, 326, 324, 322, 320, 318, 316, 314, 312, 310, 308, 306, 304, 302, 300, 298, 296, 294, 292, 290, 288, 286, 284, 282, 280, 278, 276, 274, 272, 270, 268, 266, 264, 262, 260, 258, 256, 254, 252, 250, 248, 246, 244, 242, 240, 238, 236, 234, 232, 230, 228, 226, 224, 222, 220, 218, 216, 214, 212, 210, 208, 206, 204, 202, 200, 198, 196, 194, 192, 190, 188, 186, 184, 182, 180, 178, 176, 174, 172, 170, 168, 166, 164, 162, 160, 158, 156, 154, 152, 150, 148, 146, 144, 142, 140, 138, 136, 134, 132, 130, 128, 126, 124, 122, 120, 118, 116, 114, 112, 110, 108, 106, 104, 102, 100, 98, 96, 94, 92, 90, 88, 86, 84, 82, 80, 78, 76, 74, 72, 70, 68, 66, 64, 62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0]\n assert candidate(n = 1000,x = 500,y = 700) == [2000, 2004, 2010, 2016, 2022, 2028, 2034, 2040, 2046, 2052, 2058, 2064, 2070, 2076, 2082, 2088, 2094, 2100, 2106, 2112, 2118, 2124, 2130, 2136, 2142, 2148, 2154, 2160, 2166, 2172, 2178, 2184, 2190, 2196, 2202, 2208, 2214, 2220, 2226, 2232, 2238, 2244, 2250, 2256, 2262, 2268, 2274, 2280, 2286, 2292, 2298, 2304, 2310, 2316, 2322, 2328, 2334, 2340, 2346, 2352, 2358, 2364, 2370, 2376, 2382, 2388, 2394, 2400, 2406, 2412, 2418, 2424, 2430, 2436, 2442, 2448, 2454, 2460, 2466, 2472, 2478, 2484, 2490, 2496, 2502, 2508, 2514, 2520, 2526, 2532, 2538, 2544, 2550, 2556, 2562, 2568, 2574, 2580, 2586, 2592, 2196, 2194, 2192, 2190, 2188, 2186, 2184, 2182, 2180, 2178, 2176, 2174, 2172, 2170, 2168, 2166, 2164, 2162, 2160, 2158, 2156, 2154, 2152, 2150, 2148, 2146, 2144, 2142, 2140, 2138, 2136, 2134, 2132, 2130, 2128, 2126, 2124, 2122, 2120, 2118, 2116, 2114, 2112, 2110, 2108, 2106, 2104, 2102, 2100, 2098, 2096, 2094, 2092, 2090, 2088, 2086, 2084, 2082, 2080, 2078, 2076, 2074, 2072, 2070, 2068, 2066, 2064, 2062, 2060, 2058, 2056, 2054, 2052, 2050, 2048, 2046, 2044, 2042, 2040, 2038, 2036, 2034, 2032, 2030, 2028, 2026, 2024, 2022, 2020, 2018, 2016, 2014, 2012, 2010, 2008, 2006, 2004, 2002, 2000, 1998, 1996, 1994, 1992, 1990, 1988, 1986, 1984, 1982, 1980, 1978, 1976, 1974, 1972, 1970, 1968, 1966, 1964, 1962, 1960, 1958, 1956, 1954, 1952, 1950, 1948, 1946, 1944, 1942, 1940, 1938, 1936, 1934, 1932, 1930, 1928, 1926, 1924, 1922, 1920, 1918, 1916, 1914, 1912, 1910, 1908, 1906, 1904, 1902, 1900, 1898, 1896, 1894, 1892, 1890, 1888, 1886, 1884, 1882, 1880, 1878, 1876, 1874, 1872, 1870, 1868, 1866, 1864, 1862, 1860, 1858, 1856, 1854, 1852, 1850, 1848, 1846, 1844, 1842, 1840, 1838, 1836, 1834, 1832, 1830, 1828, 1826, 1824, 1822, 1820, 1818, 1816, 1814, 1812, 1810, 1808, 1806, 1804, 1802, 1800, 1798, 1796, 1792, 1786, 1780, 1774, 1768, 1762, 1756, 1750, 1744, 1738, 1732, 1726, 1720, 1714, 1708, 1702, 1696, 1690, 1684, 1678, 1672, 1666, 1660, 1654, 1648, 1642, 1636, 1630, 1624, 1618, 1612, 1606, 1600, 1594, 1588, 1582, 1576, 1570, 1564, 1558, 1552, 1546, 1540, 1534, 1528, 1522, 1516, 1510, 1504, 1498, 1492, 1486, 1480, 1474, 1468, 1462, 1456, 1450, 1444, 1438, 1432, 1426, 1420, 1414, 1408, 1402, 1396, 1390, 1384, 1378, 1372, 1366, 1360, 1354, 1348, 1342, 1336, 1330, 1324, 1318, 1312, 1306, 1300, 1294, 1288, 1282, 1276, 1270, 1264, 1258, 1252, 1246, 1240, 1234, 1228, 1222, 1216, 1210, 1204, 1198, 1196, 1194, 1192, 1190, 1188, 1186, 1184, 1182, 1180, 1178, 1176, 1174, 1172, 1170, 1168, 1166, 1164, 1162, 1160, 1158, 1156, 1154, 1152, 1150, 1148, 1146, 1144, 1142, 1140, 1138, 1136, 1134, 1132, 1130, 1128, 1126, 1124, 1122, 1120, 1118, 1116, 1114, 1112, 1110, 1108, 1106, 1104, 1102, 1100, 1098, 1096, 1094, 1092, 1090, 1088, 1086, 1084, 1082, 1080, 1078, 1076, 1074, 1072, 1070, 1068, 1066, 1064, 1062, 1060, 1058, 1056, 1054, 1052, 1050, 1048, 1046, 1044, 1042, 1040, 1038, 1036, 1034, 1032, 1030, 1028, 1026, 1024, 1022, 1020, 1018, 1016, 1014, 1012, 1010, 1008, 1006, 1004, 1002, 1000, 996, 990, 984, 978, 972, 966, 960, 954, 948, 942, 936, 930, 924, 918, 912, 906, 900, 894, 888, 882, 876, 870, 864, 858, 852, 846, 840, 834, 828, 822, 816, 810, 804, 798, 792, 786, 780, 774, 768, 762, 756, 750, 744, 738, 732, 726, 720, 714, 708, 702, 696, 690, 684, 678, 672, 666, 660, 654, 648, 642, 636, 630, 624, 618, 612, 606, 600, 594, 588, 582, 576, 570, 564, 558, 552, 546, 540, 534, 528, 522, 516, 510, 504, 498, 492, 486, 480, 474, 468, 462, 456, 450, 444, 438, 432, 426, 420, 414, 408, 402, 400, 398, 396, 394, 392, 390, 388, 386, 384, 382, 380, 378, 376, 374, 372, 370, 368, 366, 364, 362, 360, 358, 356, 354, 352, 350, 348, 346, 344, 342, 340, 338, 336, 334, 332, 330, 328, 326, 324, 322, 320, 318, 316, 314, 312, 310, 308, 306, 304, 302, 300, 298, 296, 294, 292, 290, 288, 286, 284, 282, 280, 278, 276, 274, 272, 270, 268, 266, 264, 262, 260, 258, 256, 254, 252, 250, 248, 246, 244, 242, 240, 238, 236, 234, 232, 230, 228, 226, 224, 222, 220, 218, 216, 214, 212, 210, 208, 206, 204, 202, 200, 198, 196, 194, 192, 190, 188, 186, 184, 182, 180, 178, 176, 174, 172, 170, 168, 166, 164, 162, 160, 158, 156, 154, 152, 150, 148, 146, 144, 142, 140, 138, 136, 134, 132, 130, 128, 126, 124, 122, 120, 118, 116, 114, 112, 110, 108, 106, 104, 102, 100, 98, 96, 94, 92, 90, 88, 86, 84, 82, 80, 78, 76, 74, 72, 70, 68, 66, 64, 62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 250,x = 100,y = 150) == [500, 504, 510, 516, 522, 528, 534, 540, 546, 552, 558, 564, 570, 576, 582, 588, 594, 600, 606, 612, 618, 624, 630, 636, 642, 546, 544, 542, 540, 538, 536, 534, 532, 530, 528, 526, 524, 522, 520, 518, 516, 514, 512, 510, 508, 506, 504, 502, 500, 498, 496, 494, 492, 490, 488, 486, 484, 482, 480, 478, 476, 474, 472, 470, 468, 466, 464, 462, 460, 458, 456, 454, 452, 450, 448, 446, 444, 442, 440, 438, 436, 434, 432, 430, 428, 426, 424, 422, 420, 418, 416, 414, 412, 410, 408, 406, 404, 402, 400, 398, 394, 386, 376, 366, 356, 346, 336, 326, 316, 306, 296, 286, 276, 266, 256, 246, 236, 226, 216, 206, 196, 186, 176, 166, 156, 150, 148, 146, 144, 142, 140, 138, 136, 134, 132, 130, 128, 126, 124, 122, 120, 118, 116, 114, 112, 110, 108, 106, 104, 102, 100, 98, 96, 94, 92, 90, 88, 86, 84, 82, 80, 78, 76, 74, 72, 70, 68, 66, 64, 62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 20,x = 10,y = 11) == [38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0]\n assert candidate(n = 30,x = 10,y = 20) == [60, 64, 70, 76, 82, 66, 64, 62, 60, 58, 54, 46, 36, 26, 16, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 18,x = 5,y = 13) == [36, 40, 46, 52, 40, 36, 28, 18, 8, 2, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 1000,x = 500,y = 501) == [1998, 1996, 1994, 1992, 1990, 1988, 1986, 1984, 1982, 1980, 1978, 1976, 1974, 1972, 1970, 1968, 1966, 1964, 1962, 1960, 1958, 1956, 1954, 1952, 1950, 1948, 1946, 1944, 1942, 1940, 1938, 1936, 1934, 1932, 1930, 1928, 1926, 1924, 1922, 1920, 1918, 1916, 1914, 1912, 1910, 1908, 1906, 1904, 1902, 1900, 1898, 1896, 1894, 1892, 1890, 1888, 1886, 1884, 1882, 1880, 1878, 1876, 1874, 1872, 1870, 1868, 1866, 1864, 1862, 1860, 1858, 1856, 1854, 1852, 1850, 1848, 1846, 1844, 1842, 1840, 1838, 1836, 1834, 1832, 1830, 1828, 1826, 1824, 1822, 1820, 1818, 1816, 1814, 1812, 1810, 1808, 1806, 1804, 1802, 1800, 1798, 1796, 1794, 1792, 1790, 1788, 1786, 1784, 1782, 1780, 1778, 1776, 1774, 1772, 1770, 1768, 1766, 1764, 1762, 1760, 1758, 1756, 1754, 1752, 1750, 1748, 1746, 1744, 1742, 1740, 1738, 1736, 1734, 1732, 1730, 1728, 1726, 1724, 1722, 1720, 1718, 1716, 1714, 1712, 1710, 1708, 1706, 1704, 1702, 1700, 1698, 1696, 1694, 1692, 1690, 1688, 1686, 1684, 1682, 1680, 1678, 1676, 1674, 1672, 1670, 1668, 1666, 1664, 1662, 1660, 1658, 1656, 1654, 1652, 1650, 1648, 1646, 1644, 1642, 1640, 1638, 1636, 1634, 1632, 1630, 1628, 1626, 1624, 1622, 1620, 1618, 1616, 1614, 1612, 1610, 1608, 1606, 1604, 1602, 1600, 1598, 1596, 1594, 1592, 1590, 1588, 1586, 1584, 1582, 1580, 1578, 1576, 1574, 1572, 1570, 1568, 1566, 1564, 1562, 1560, 1558, 1556, 1554, 1552, 1550, 1548, 1546, 1544, 1542, 1540, 1538, 1536, 1534, 1532, 1530, 1528, 1526, 1524, 1522, 1520, 1518, 1516, 1514, 1512, 1510, 1508, 1506, 1504, 1502, 1500, 1498, 1496, 1494, 1492, 1490, 1488, 1486, 1484, 1482, 1480, 1478, 1476, 1474, 1472, 1470, 1468, 1466, 1464, 1462, 1460, 1458, 1456, 1454, 1452, 1450, 1448, 1446, 1444, 1442, 1440, 1438, 1436, 1434, 1432, 1430, 1428, 1426, 1424, 1422, 1420, 1418, 1416, 1414, 1412, 1410, 1408, 1406, 1404, 1402, 1400, 1398, 1396, 1394, 1392, 1390, 1388, 1386, 1384, 1382, 1380, 1378, 1376, 1374, 1372, 1370, 1368, 1366, 1364, 1362, 1360, 1358, 1356, 1354, 1352, 1350, 1348, 1346, 1344, 1342, 1340, 1338, 1336, 1334, 1332, 1330, 1328, 1326, 1324, 1322, 1320, 1318, 1316, 1314, 1312, 1310, 1308, 1306, 1304, 1302, 1300, 1298, 1296, 1294, 1292, 1290, 1288, 1286, 1284, 1282, 1280, 1278, 1276, 1274, 1272, 1270, 1268, 1266, 1264, 1262, 1260, 1258, 1256, 1254, 1252, 1250, 1248, 1246, 1244, 1242, 1240, 1238, 1236, 1234, 1232, 1230, 1228, 1226, 1224, 1222, 1220, 1218, 1216, 1214, 1212, 1210, 1208, 1206, 1204, 1202, 1200, 1198, 1196, 1194, 1192, 1190, 1188, 1186, 1184, 1182, 1180, 1178, 1176, 1174, 1172, 1170, 1168, 1166, 1164, 1162, 1160, 1158, 1156, 1154, 1152, 1150, 1148, 1146, 1144, 1142, 1140, 1138, 1136, 1134, 1132, 1130, 1128, 1126, 1124, 1122, 1120, 1118, 1116, 1114, 1112, 1110, 1108, 1106, 1104, 1102, 1100, 1098, 1096, 1094, 1092, 1090, 1088, 1086, 1084, 1082, 1080, 1078, 1076, 1074, 1072, 1070, 1068, 1066, 1064, 1062, 1060, 1058, 1056, 1054, 1052, 1050, 1048, 1046, 1044, 1042, 1040, 1038, 1036, 1034, 1032, 1030, 1028, 1026, 1024, 1022, 1020, 1018, 1016, 1014, 1012, 1010, 1008, 1006, 1004, 1002, 1000, 998, 996, 994, 992, 990, 988, 986, 984, 982, 980, 978, 976, 974, 972, 970, 968, 966, 964, 962, 960, 958, 956, 954, 952, 950, 948, 946, 944, 942, 940, 938, 936, 934, 932, 930, 928, 926, 924, 922, 920, 918, 916, 914, 912, 910, 908, 906, 904, 902, 900, 898, 896, 894, 892, 890, 888, 886, 884, 882, 880, 878, 876, 874, 872, 870, 868, 866, 864, 862, 860, 858, 856, 854, 852, 850, 848, 846, 844, 842, 840, 838, 836, 834, 832, 830, 828, 826, 824, 822, 820, 818, 816, 814, 812, 810, 808, 806, 804, 802, 800, 798, 796, 794, 792, 790, 788, 786, 784, 782, 780, 778, 776, 774, 772, 770, 768, 766, 764, 762, 760, 758, 756, 754, 752, 750, 748, 746, 744, 742, 740, 738, 736, 734, 732, 730, 728, 726, 724, 722, 720, 718, 716, 714, 712, 710, 708, 706, 704, 702, 700, 698, 696, 694, 692, 690, 688, 686, 684, 682, 680, 678, 676, 674, 672, 670, 668, 666, 664, 662, 660, 658, 656, 654, 652, 650, 648, 646, 644, 642, 640, 638, 636, 634, 632, 630, 628, 626, 624, 622, 620, 618, 616, 614, 612, 610, 608, 606, 604, 602, 600, 598, 596, 594, 592, 590, 588, 586, 584, 582, 580, 578, 576, 574, 572, 570, 568, 566, 564, 562, 560, 558, 556, 554, 552, 550, 548, 546, 544, 542, 540, 538, 536, 534, 532, 530, 528, 526, 524, 522, 520, 518, 516, 514, 512, 510, 508, 506, 504, 502, 500, 498, 496, 494, 492, 490, 488, 486, 484, 482, 480, 478, 476, 474, 472, 470, 468, 466, 464, 462, 460, 458, 456, 454, 452, 450, 448, 446, 444, 442, 440, 438, 436, 434, 432, 430, 428, 426, 424, 422, 420, 418, 416, 414, 412, 410, 408, 406, 404, 402, 400, 398, 396, 394, 392, 390, 388, 386, 384, 382, 380, 378, 376, 374, 372, 370, 368, 366, 364, 362, 360, 358, 356, 354, 352, 350, 348, 346, 344, 342, 340, 338, 336, 334, 332, 330, 328, 326, 324, 322, 320, 318, 316, 314, 312, 310, 308, 306, 304, 302, 300, 298, 296, 294, 292, 290, 288, 286, 284, 282, 280, 278, 276, 274, 272, 270, 268, 266, 264, 262, 260, 258, 256, 254, 252, 250, 248, 246, 244, 242, 240, 238, 236, 234, 232, 230, 228, 226, 224, 222, 220, 218, 216, 214, 212, 210, 208, 206, 204, 202, 200, 198, 196, 194, 192, 190, 188, 186, 184, 182, 180, 178, 176, 174, 172, 170, 168, 166, 164, 162, 160, 158, 156, 154, 152, 150, 148, 146, 144, 142, 140, 138, 136, 134, 132, 130, 128, 126, 124, 122, 120, 118, 116, 114, 112, 110, 108, 106, 104, 102, 100, 98, 96, 94, 92, 90, 88, 86, 84, 82, 80, 78, 76, 74, 72, 70, 68, 66, 64, 62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0]\n assert candidate(n = 60,x = 10,y = 55) == [120, 124, 130, 136, 142, 148, 152, 154, 156, 158, 158, 156, 154, 152, 150, 148, 148, 148, 148, 148, 148, 148, 102, 52, 44, 36, 28, 20, 14, 10, 6, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 5,x = 1,y = 5) == [10, 10, 0, 0, 0]\n assert candidate(n = 50,x = 25,y = 30) == [100, 104, 104, 100, 98, 96, 94, 92, 90, 88, 86, 84, 82, 80, 78, 76, 74, 72, 70, 68, 66, 62, 56, 52, 50, 46, 40, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0]\n assert candidate(n = 300,x = 150,y = 250) == [600, 604, 610, 616, 622, 628, 634, 640, 646, 652, 658, 664, 670, 676, 682, 688, 694, 700, 706, 712, 718, 724, 730, 736, 742, 748, 754, 760, 766, 772, 778, 784, 790, 796, 802, 808, 814, 820, 826, 832, 838, 844, 850, 856, 862, 868, 874, 880, 886, 892, 696, 692, 686, 680, 674, 668, 662, 656, 650, 644, 638, 632, 626, 620, 614, 608, 602, 596, 590, 584, 578, 572, 566, 560, 554, 548, 542, 536, 530, 524, 518, 512, 506, 500, 494, 488, 482, 476, 470, 464, 458, 452, 446, 440, 434, 428, 422, 416, 410, 404, 398, 396, 394, 392, 390, 388, 386, 384, 382, 380, 378, 376, 374, 372, 370, 368, 366, 364, 362, 360, 358, 356, 354, 352, 350, 348, 346, 344, 342, 340, 338, 336, 334, 332, 330, 328, 326, 324, 322, 320, 318, 316, 314, 312, 310, 308, 306, 304, 302, 300, 296, 290, 284, 278, 272, 266, 260, 254, 248, 242, 236, 230, 224, 218, 212, 206, 200, 194, 188, 182, 176, 170, 164, 158, 152, 146, 140, 134, 128, 122, 116, 110, 104, 98, 92, 86, 80, 74, 68, 62, 56, 50, 44, 38, 32, 26, 20, 14, 8, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 30,x = 1,y = 30) == [60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 100,x = 20,y = 80) == [200, 204, 210, 216, 222, 228, 234, 240, 246, 252, 258, 264, 270, 276, 282, 288, 294, 300, 306, 312, 316, 316, 314, 312, 310, 308, 306, 304, 302, 300, 176, 166, 156, 146, 136, 126, 116, 106, 96, 86, 76, 68, 60, 52, 44, 36, 28, 20, 12, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 90,x = 30,y = 60) == [180, 184, 190, 196, 202, 208, 214, 220, 226, 232, 238, 244, 250, 256, 262, 206, 204, 202, 200, 198, 196, 194, 192, 190, 188, 186, 184, 182, 180, 178, 174, 166, 156, 146, 136, 126, 116, 106, 96, 86, 76, 66, 56, 46, 36, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 20,x = 5,y = 16) == [40, 44, 50, 56, 62, 52, 34, 24, 14, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 80,x = 20,y = 60) == [160, 164, 170, 176, 182, 188, 194, 200, 206, 212, 218, 224, 230, 236, 242, 248, 254, 260, 266, 272, 194, 186, 176, 166, 156, 146, 136, 126, 116, 106, 96, 86, 76, 66, 56, 46, 36, 26, 16, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 100,x = 1,y = 1) == [198, 196, 194, 192, 190, 188, 186, 184, 182, 180, 178, 176, 174, 172, 170, 168, 166, 164, 162, 160, 158, 156, 154, 152, 150, 148, 146, 144, 142, 140, 138, 136, 134, 132, 130, 128, 126, 124, 122, 120, 118, 116, 114, 112, 110, 108, 106, 104, 102, 100, 98, 96, 94, 92, 90, 88, 86, 84, 82, 80, 78, 76, 74, 72, 70, 68, 66, 64, 62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0]\n assert candidate(n = 25,x = 3,y = 22) == [50, 54, 60, 64, 64, 62, 60, 60, 60, 40, 16, 8, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 1000,x = 1,y = 1000) == [2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 100,x = 50,y = 55) == [200, 204, 204, 200, 198, 196, 194, 192, 190, 188, 186, 184, 182, 180, 178, 176, 174, 172, 170, 168, 166, 164, 162, 160, 158, 156, 154, 152, 150, 148, 146, 144, 142, 140, 138, 136, 134, 132, 130, 128, 126, 124, 122, 120, 118, 116, 112, 106, 102, 100, 96, 90, 86, 84, 82, 80, 78, 76, 74, 72, 70, 68, 66, 64, 62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0]\n assert candidate(n = 50,x = 15,y = 40) == [100, 104, 110, 116, 122, 128, 134, 140, 146, 152, 158, 162, 138, 110, 104, 96, 86, 76, 66, 56, 46, 36, 26, 18, 12, 6, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 300,x = 200,y = 250) == [600, 604, 610, 616, 622, 628, 634, 640, 646, 652, 658, 664, 670, 676, 682, 688, 694, 700, 706, 712, 718, 724, 730, 736, 742, 646, 644, 642, 640, 638, 636, 634, 632, 630, 628, 626, 624, 622, 620, 618, 616, 614, 612, 610, 608, 606, 604, 602, 600, 598, 596, 592, 586, 580, 574, 568, 562, 556, 550, 544, 538, 532, 526, 520, 514, 508, 502, 496, 490, 484, 478, 472, 466, 460, 454, 448, 446, 444, 442, 440, 438, 436, 434, 432, 430, 428, 426, 424, 422, 420, 418, 416, 414, 412, 410, 408, 406, 404, 402, 400, 398, 396, 394, 392, 390, 388, 386, 384, 382, 380, 378, 376, 374, 372, 370, 368, 366, 364, 362, 360, 358, 356, 354, 352, 350, 348, 346, 344, 342, 340, 338, 336, 334, 332, 330, 328, 326, 324, 322, 320, 318, 316, 314, 312, 310, 308, 306, 304, 302, 300, 298, 296, 294, 292, 290, 288, 286, 284, 282, 280, 278, 276, 274, 272, 270, 268, 266, 264, 262, 260, 258, 256, 254, 252, 250, 248, 246, 244, 242, 240, 238, 236, 234, 232, 230, 228, 226, 224, 222, 220, 218, 216, 214, 212, 210, 208, 206, 204, 202, 200, 196, 190, 184, 178, 172, 166, 160, 154, 148, 142, 136, 130, 124, 118, 112, 106, 100, 94, 88, 82, 76, 70, 64, 58, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 200,x = 100,y = 101) == [398, 396, 394, 392, 390, 388, 386, 384, 382, 380, 378, 376, 374, 372, 370, 368, 366, 364, 362, 360, 358, 356, 354, 352, 350, 348, 346, 344, 342, 340, 338, 336, 334, 332, 330, 328, 326, 324, 322, 320, 318, 316, 314, 312, 310, 308, 306, 304, 302, 300, 298, 296, 294, 292, 290, 288, 286, 284, 282, 280, 278, 276, 274, 272, 270, 268, 266, 264, 262, 260, 258, 256, 254, 252, 250, 248, 246, 244, 242, 240, 238, 236, 234, 232, 230, 228, 226, 224, 222, 220, 218, 216, 214, 212, 210, 208, 206, 204, 202, 200, 198, 196, 194, 192, 190, 188, 186, 184, 182, 180, 178, 176, 174, 172, 170, 168, 166, 164, 162, 160, 158, 156, 154, 152, 150, 148, 146, 144, 142, 140, 138, 136, 134, 132, 130, 128, 126, 124, 122, 120, 118, 116, 114, 112, 110, 108, 106, 104, 102, 100, 98, 96, 94, 92, 90, 88, 86, 84, 82, 80, 78, 76, 74, 72, 70, 68, 66, 64, 62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0]\n assert candidate(n = 25,x = 5,y = 5) == [48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0]\n assert candidate(n = 5000,x = 1,y = 5000) == [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 5000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 20,x = 7,y = 14) == [40, 44, 50, 48, 42, 40, 38, 32, 22, 12, 6, 4, 2, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 50,x = 25,y = 26) == [98, 96, 94, 92, 90, 88, 86, 84, 82, 80, 78, 76, 74, 72, 70, 68, 66, 64, 62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0]\n assert candidate(n = 100,x = 3,y = 4) == [198, 196, 194, 192, 190, 188, 186, 184, 182, 180, 178, 176, 174, 172, 170, 168, 166, 164, 162, 160, 158, 156, 154, 152, 150, 148, 146, 144, 142, 140, 138, 136, 134, 132, 130, 128, 126, 124, 122, 120, 118, 116, 114, 112, 110, 108, 106, 104, 102, 100, 98, 96, 94, 92, 90, 88, 86, 84, 82, 80, 78, 76, 74, 72, 70, 68, 66, 64, 62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0]\n assert candidate(n = 150,x = 75,y = 75) == [298, 296, 294, 292, 290, 288, 286, 284, 282, 280, 278, 276, 274, 272, 270, 268, 266, 264, 262, 260, 258, 256, 254, 252, 250, 248, 246, 244, 242, 240, 238, 236, 234, 232, 230, 228, 226, 224, 222, 220, 218, 216, 214, 212, 210, 208, 206, 204, 202, 200, 198, 196, 194, 192, 190, 188, 186, 184, 182, 180, 178, 176, 174, 172, 170, 168, 166, 164, 162, 160, 158, 156, 154, 152, 150, 148, 146, 144, 142, 140, 138, 136, 134, 132, 130, 128, 126, 124, 122, 120, 118, 116, 114, 112, 110, 108, 106, 104, 102, 100, 98, 96, 94, 92, 90, 88, 86, 84, 82, 80, 78, 76, 74, 72, 70, 68, 66, 64, 62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0]\n assert candidate(n = 180,x = 60,y = 120) == [360, 364, 370, 376, 382, 388, 394, 400, 406, 412, 418, 424, 430, 436, 442, 448, 454, 460, 466, 472, 478, 484, 490, 496, 502, 508, 514, 520, 526, 532, 416, 414, 412, 410, 408, 406, 404, 402, 400, 398, 396, 394, 392, 390, 388, 386, 384, 382, 380, 378, 376, 374, 372, 370, 368, 366, 364, 362, 360, 358, 354, 346, 336, 326, 316, 306, 296, 286, 276, 266, 256, 246, 236, 226, 216, 206, 196, 186, 176, 166, 156, 146, 136, 126, 116, 106, 96, 86, 76, 66, 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 75,x = 10,y = 65) == [150, 154, 160, 166, 172, 178, 184, 190, 196, 202, 206, 206, 204, 202, 200, 198, 196, 194, 192, 190, 188, 188, 188, 188, 188, 188, 188, 132, 72, 64, 56, 48, 40, 32, 24, 16, 8, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 50,x = 20,y = 30) == [100, 104, 110, 116, 122, 106, 104, 102, 100, 98, 96, 94, 92, 90, 88, 86, 84, 82, 80, 78, 74, 66, 56, 46, 36, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 50,x = 25,y = 35) == [100, 104, 110, 116, 122, 106, 104, 102, 100, 98, 96, 94, 92, 90, 88, 86, 82, 76, 70, 64, 58, 56, 54, 52, 50, 46, 40, 34, 28, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 100,x = 50,y = 75) == [200, 204, 210, 216, 222, 228, 234, 240, 246, 252, 258, 264, 244, 220, 218, 216, 214, 212, 210, 208, 206, 204, 202, 200, 198, 196, 192, 186, 180, 174, 168, 162, 156, 150, 144, 138, 132, 126, 122, 120, 118, 116, 114, 112, 110, 108, 106, 104, 102, 100, 96, 90, 84, 78, 72, 66, 60, 54, 48, 42, 36, 30, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 150,x = 1,y = 150) == [300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 20,x = 5,y = 15) == [40, 44, 50, 56, 62, 44, 36, 26, 16, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 100,x = 10,y = 90) == [200, 204, 210, 216, 222, 228, 234, 240, 246, 252, 256, 256, 254, 252, 250, 248, 246, 244, 242, 240, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 238, 76, 68, 60, 52, 44, 36, 28, 20, 12, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 200,x = 50,y = 150) == [400, 404, 410, 416, 422, 428, 434, 440, 446, 452, 458, 464, 470, 476, 482, 488, 494, 500, 506, 512, 518, 524, 530, 536, 542, 548, 554, 560, 566, 572, 578, 584, 590, 596, 602, 608, 614, 620, 626, 632, 638, 644, 650, 656, 662, 668, 674, 680, 686, 692, 494, 486, 476, 466, 456, 446, 436, 426, 416, 406, 396, 386, 376, 366, 356, 346, 336, 326, 316, 306, 296, 286, 276, 266, 256, 246, 236, 226, 216, 206, 196, 186, 176, 166, 156, 146, 136, 126, 116, 106, 96, 86, 76, 66, 56, 46, 36, 26, 16, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 999,x = 333,y = 666) == [1998, 2002, 2008, 2014, 2020, 2026, 2032, 2038, 2044, 2050, 2056, 2062, 2068, 2074, 2080, 2086, 2092, 2098, 2104, 2110, 2116, 2122, 2128, 2134, 2140, 2146, 2152, 2158, 2164, 2170, 2176, 2182, 2188, 2194, 2200, 2206, 2212, 2218, 2224, 2230, 2236, 2242, 2248, 2254, 2260, 2266, 2272, 2278, 2284, 2290, 2296, 2302, 2308, 2314, 2320, 2326, 2332, 2338, 2344, 2350, 2356, 2362, 2368, 2374, 2380, 2386, 2392, 2398, 2404, 2410, 2416, 2422, 2428, 2434, 2440, 2446, 2452, 2458, 2464, 2470, 2476, 2482, 2488, 2494, 2500, 2506, 2512, 2518, 2524, 2530, 2536, 2542, 2548, 2554, 2560, 2566, 2572, 2578, 2584, 2590, 2596, 2602, 2608, 2614, 2620, 2626, 2632, 2638, 2644, 2650, 2656, 2662, 2668, 2674, 2680, 2686, 2692, 2698, 2704, 2710, 2716, 2722, 2728, 2734, 2740, 2746, 2752, 2758, 2764, 2770, 2776, 2782, 2788, 2794, 2800, 2806, 2812, 2818, 2824, 2830, 2836, 2842, 2848, 2854, 2860, 2866, 2872, 2878, 2884, 2890, 2896, 2902, 2908, 2914, 2920, 2926, 2932, 2938, 2944, 2950, 2956, 2962, 2968, 2974, 2980, 2986, 2658, 2326, 2324, 2322, 2320, 2318, 2316, 2314, 2312, 2310, 2308, 2306, 2304, 2302, 2300, 2298, 2296, 2294, 2292, 2290, 2288, 2286, 2284, 2282, 2280, 2278, 2276, 2274, 2272, 2270, 2268, 2266, 2264, 2262, 2260, 2258, 2256, 2254, 2252, 2250, 2248, 2246, 2244, 2242, 2240, 2238, 2236, 2234, 2232, 2230, 2228, 2226, 2224, 2222, 2220, 2218, 2216, 2214, 2212, 2210, 2208, 2206, 2204, 2202, 2200, 2198, 2196, 2194, 2192, 2190, 2188, 2186, 2184, 2182, 2180, 2178, 2176, 2174, 2172, 2170, 2168, 2166, 2164, 2162, 2160, 2158, 2156, 2154, 2152, 2150, 2148, 2146, 2144, 2142, 2140, 2138, 2136, 2134, 2132, 2130, 2128, 2126, 2124, 2122, 2120, 2118, 2116, 2114, 2112, 2110, 2108, 2106, 2104, 2102, 2100, 2098, 2096, 2094, 2092, 2090, 2088, 2086, 2084, 2082, 2080, 2078, 2076, 2074, 2072, 2070, 2068, 2066, 2064, 2062, 2060, 2058, 2056, 2054, 2052, 2050, 2048, 2046, 2044, 2042, 2040, 2038, 2036, 2034, 2032, 2030, 2028, 2026, 2024, 2022, 2020, 2018, 2016, 2014, 2012, 2010, 2008, 2006, 2004, 2002, 2000, 1998, 1996, 1992, 1984, 1974, 1964, 1954, 1944, 1934, 1924, 1914, 1904, 1894, 1884, 1874, 1864, 1854, 1844, 1834, 1824, 1814, 1804, 1794, 1784, 1774, 1764, 1754, 1744, 1734, 1724, 1714, 1704, 1694, 1684, 1674, 1664, 1654, 1644, 1634, 1624, 1614, 1604, 1594, 1584, 1574, 1564, 1554, 1544, 1534, 1524, 1514, 1504, 1494, 1484, 1474, 1464, 1454, 1444, 1434, 1424, 1414, 1404, 1394, 1384, 1374, 1364, 1354, 1344, 1334, 1324, 1314, 1304, 1294, 1284, 1274, 1264, 1254, 1244, 1234, 1224, 1214, 1204, 1194, 1184, 1174, 1164, 1154, 1144, 1134, 1124, 1114, 1104, 1094, 1084, 1074, 1064, 1054, 1044, 1034, 1024, 1014, 1004, 994, 984, 974, 964, 954, 944, 934, 924, 914, 904, 894, 884, 874, 864, 854, 844, 834, 824, 814, 804, 794, 784, 774, 764, 754, 744, 734, 724, 714, 704, 694, 684, 674, 664, 654, 644, 634, 624, 614, 604, 594, 584, 574, 564, 554, 544, 534, 524, 514, 504, 494, 484, 474, 464, 454, 444, 434, 424, 414, 404, 394, 384, 374, 364, 354, 344, 336, 332, 330, 328, 326, 324, 322, 320, 318, 316, 314, 312, 310, 308, 306, 304, 302, 300, 298, 296, 294, 292, 290, 288, 286, 284, 282, 280, 278, 276, 274, 272, 270, 268, 266, 264, 262, 260, 258, 256, 254, 252, 250, 248, 246, 244, 242, 240, 238, 236, 234, 232, 230, 228, 226, 224, 222, 220, 218, 216, 214, 212, 210, 208, 206, 204, 202, 200, 198, 196, 194, 192, 190, 188, 186, 184, 182, 180, 178, 176, 174, 172, 170, 168, 166, 164, 162, 160, 158, 156, 154, 152, 150, 148, 146, 144, 142, 140, 138, 136, 134, 132, 130, 128, 126, 124, 122, 120, 118, 116, 114, 112, 110, 108, 106, 104, 102, 100, 98, 96, 94, 92, 90, 88, 86, 84, 82, 80, 78, 76, 74, 72, 70, 68, 66, 64, 62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 50,x = 15,y = 35) == [100, 104, 110, 116, 122, 128, 134, 140, 146, 152, 116, 114, 112, 110, 108, 104, 96, 86, 76, 66, 56, 46, 36, 26, 16, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 15,x = 1,y = 15) == [30, 30, 30, 30, 30, 30, 30, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 2000,x = 1000,y = 1001) == [3998, 3996, 3994, 3992, 3990, 3988, 3986, 3984, 3982, 3980, 3978, 3976, 3974, 3972, 3970, 3968, 3966, 3964, 3962, 3960, 3958, 3956, 3954, 3952, 3950, 3948, 3946, 3944, 3942, 3940, 3938, 3936, 3934, 3932, 3930, 3928, 3926, 3924, 3922, 3920, 3918, 3916, 3914, 3912, 3910, 3908, 3906, 3904, 3902, 3900, 3898, 3896, 3894, 3892, 3890, 3888, 3886, 3884, 3882, 3880, 3878, 3876, 3874, 3872, 3870, 3868, 3866, 3864, 3862, 3860, 3858, 3856, 3854, 3852, 3850, 3848, 3846, 3844, 3842, 3840, 3838, 3836, 3834, 3832, 3830, 3828, 3826, 3824, 3822, 3820, 3818, 3816, 3814, 3812, 3810, 3808, 3806, 3804, 3802, 3800, 3798, 3796, 3794, 3792, 3790, 3788, 3786, 3784, 3782, 3780, 3778, 3776, 3774, 3772, 3770, 3768, 3766, 3764, 3762, 3760, 3758, 3756, 3754, 3752, 3750, 3748, 3746, 3744, 3742, 3740, 3738, 3736, 3734, 3732, 3730, 3728, 3726, 3724, 3722, 3720, 3718, 3716, 3714, 3712, 3710, 3708, 3706, 3704, 3702, 3700, 3698, 3696, 3694, 3692, 3690, 3688, 3686, 3684, 3682, 3680, 3678, 3676, 3674, 3672, 3670, 3668, 3666, 3664, 3662, 3660, 3658, 3656, 3654, 3652, 3650, 3648, 3646, 3644, 3642, 3640, 3638, 3636, 3634, 3632, 3630, 3628, 3626, 3624, 3622, 3620, 3618, 3616, 3614, 3612, 3610, 3608, 3606, 3604, 3602, 3600, 3598, 3596, 3594, 3592, 3590, 3588, 3586, 3584, 3582, 3580, 3578, 3576, 3574, 3572, 3570, 3568, 3566, 3564, 3562, 3560, 3558, 3556, 3554, 3552, 3550, 3548, 3546, 3544, 3542, 3540, 3538, 3536, 3534, 3532, 3530, 3528, 3526, 3524, 3522, 3520, 3518, 3516, 3514, 3512, 3510, 3508, 3506, 3504, 3502, 3500, 3498, 3496, 3494, 3492, 3490, 3488, 3486, 3484, 3482, 3480, 3478, 3476, 3474, 3472, 3470, 3468, 3466, 3464, 3462, 3460, 3458, 3456, 3454, 3452, 3450, 3448, 3446, 3444, 3442, 3440, 3438, 3436, 3434, 3432, 3430, 3428, 3426, 3424, 3422, 3420, 3418, 3416, 3414, 3412, 3410, 3408, 3406, 3404, 3402, 3400, 3398, 3396, 3394, 3392, 3390, 3388, 3386, 3384, 3382, 3380, 3378, 3376, 3374, 3372, 3370, 3368, 3366, 3364, 3362, 3360, 3358, 3356, 3354, 3352, 3350, 3348, 3346, 3344, 3342, 3340, 3338, 3336, 3334, 3332, 3330, 3328, 3326, 3324, 3322, 3320, 3318, 3316, 3314, 3312, 3310, 3308, 3306, 3304, 3302, 3300, 3298, 3296, 3294, 3292, 3290, 3288, 3286, 3284, 3282, 3280, 3278, 3276, 3274, 3272, 3270, 3268, 3266, 3264, 3262, 3260, 3258, 3256, 3254, 3252, 3250, 3248, 3246, 3244, 3242, 3240, 3238, 3236, 3234, 3232, 3230, 3228, 3226, 3224, 3222, 3220, 3218, 3216, 3214, 3212, 3210, 3208, 3206, 3204, 3202, 3200, 3198, 3196, 3194, 3192, 3190, 3188, 3186, 3184, 3182, 3180, 3178, 3176, 3174, 3172, 3170, 3168, 3166, 3164, 3162, 3160, 3158, 3156, 3154, 3152, 3150, 3148, 3146, 3144, 3142, 3140, 3138, 3136, 3134, 3132, 3130, 3128, 3126, 3124, 3122, 3120, 3118, 3116, 3114, 3112, 3110, 3108, 3106, 3104, 3102, 3100, 3098, 3096, 3094, 3092, 3090, 3088, 3086, 3084, 3082, 3080, 3078, 3076, 3074, 3072, 3070, 3068, 3066, 3064, 3062, 3060, 3058, 3056, 3054, 3052, 3050, 3048, 3046, 3044, 3042, 3040, 3038, 3036, 3034, 3032, 3030, 3028, 3026, 3024, 3022, 3020, 3018, 3016, 3014, 3012, 3010, 3008, 3006, 3004, 3002, 3000, 2998, 2996, 2994, 2992, 2990, 2988, 2986, 2984, 2982, 2980, 2978, 2976, 2974, 2972, 2970, 2968, 2966, 2964, 2962, 2960, 2958, 2956, 2954, 2952, 2950, 2948, 2946, 2944, 2942, 2940, 2938, 2936, 2934, 2932, 2930, 2928, 2926, 2924, 2922, 2920, 2918, 2916, 2914, 2912, 2910, 2908, 2906, 2904, 2902, 2900, 2898, 2896, 2894, 2892, 2890, 2888, 2886, 2884, 2882, 2880, 2878, 2876, 2874, 2872, 2870, 2868, 2866, 2864, 2862, 2860, 2858, 2856, 2854, 2852, 2850, 2848, 2846, 2844, 2842, 2840, 2838, 2836, 2834, 2832, 2830, 2828, 2826, 2824, 2822, 2820, 2818, 2816, 2814, 2812, 2810, 2808, 2806, 2804, 2802, 2800, 2798, 2796, 2794, 2792, 2790, 2788, 2786, 2784, 2782, 2780, 2778, 2776, 2774, 2772, 2770, 2768, 2766, 2764, 2762, 2760, 2758, 2756, 2754, 2752, 2750, 2748, 2746, 2744, 2742, 2740, 2738, 2736, 2734, 2732, 2730, 2728, 2726, 2724, 2722, 2720, 2718, 2716, 2714, 2712, 2710, 2708, 2706, 2704, 2702, 2700, 2698, 2696, 2694, 2692, 2690, 2688, 2686, 2684, 2682, 2680, 2678, 2676, 2674, 2672, 2670, 2668, 2666, 2664, 2662, 2660, 2658, 2656, 2654, 2652, 2650, 2648, 2646, 2644, 2642, 2640, 2638, 2636, 2634, 2632, 2630, 2628, 2626, 2624, 2622, 2620, 2618, 2616, 2614, 2612, 2610, 2608, 2606, 2604, 2602, 2600, 2598, 2596, 2594, 2592, 2590, 2588, 2586, 2584, 2582, 2580, 2578, 2576, 2574, 2572, 2570, 2568, 2566, 2564, 2562, 2560, 2558, 2556, 2554, 2552, 2550, 2548, 2546, 2544, 2542, 2540, 2538, 2536, 2534, 2532, 2530, 2528, 2526, 2524, 2522, 2520, 2518, 2516, 2514, 2512, 2510, 2508, 2506, 2504, 2502, 2500, 2498, 2496, 2494, 2492, 2490, 2488, 2486, 2484, 2482, 2480, 2478, 2476, 2474, 2472, 2470, 2468, 2466, 2464, 2462, 2460, 2458, 2456, 2454, 2452, 2450, 2448, 2446, 2444, 2442, 2440, 2438, 2436, 2434, 2432, 2430, 2428, 2426, 2424, 2422, 2420, 2418, 2416, 2414, 2412, 2410, 2408, 2406, 2404, 2402, 2400, 2398, 2396, 2394, 2392, 2390, 2388, 2386, 2384, 2382, 2380, 2378, 2376, 2374, 2372, 2370, 2368, 2366, 2364, 2362, 2360, 2358, 2356, 2354, 2352, 2350, 2348, 2346, 2344, 2342, 2340, 2338, 2336, 2334, 2332, 2330, 2328, 2326, 2324, 2322, 2320, 2318, 2316, 2314, 2312, 2310, 2308, 2306, 2304, 2302, 2300, 2298, 2296, 2294, 2292, 2290, 2288, 2286, 2284, 2282, 2280, 2278, 2276, 2274, 2272, 2270, 2268, 2266, 2264, 2262, 2260, 2258, 2256, 2254, 2252, 2250, 2248, 2246, 2244, 2242, 2240, 2238, 2236, 2234, 2232, 2230, 2228, 2226, 2224, 2222, 2220, 2218, 2216, 2214, 2212, 2210, 2208, 2206, 2204, 2202, 2200, 2198, 2196, 2194, 2192, 2190, 2188, 2186, 2184, 2182, 2180, 2178, 2176, 2174, 2172, 2170, 2168, 2166, 2164, 2162, 2160, 2158, 2156, 2154, 2152, 2150, 2148, 2146, 2144, 2142, 2140, 2138, 2136, 2134, 2132, 2130, 2128, 2126, 2124, 2122, 2120, 2118, 2116, 2114, 2112, 2110, 2108, 2106, 2104, 2102, 2100, 2098, 2096, 2094, 2092, 2090, 2088, 2086, 2084, 2082, 2080, 2078, 2076, 2074, 2072, 2070, 2068, 2066, 2064, 2062, 2060, 2058, 2056, 2054, 2052, 2050, 2048, 2046, 2044, 2042, 2040, 2038, 2036, 2034, 2032, 2030, 2028, 2026, 2024, 2022, 2020, 2018, 2016, 2014, 2012, 2010, 2008, 2006, 2004, 2002, 2000, 1998, 1996, 1994, 1992, 1990, 1988, 1986, 1984, 1982, 1980, 1978, 1976, 1974, 1972, 1970, 1968, 1966, 1964, 1962, 1960, 1958, 1956, 1954, 1952, 1950, 1948, 1946, 1944, 1942, 1940, 1938, 1936, 1934, 1932, 1930, 1928, 1926, 1924, 1922, 1920, 1918, 1916, 1914, 1912, 1910, 1908, 1906, 1904, 1902, 1900, 1898, 1896, 1894, 1892, 1890, 1888, 1886, 1884, 1882, 1880, 1878, 1876, 1874, 1872, 1870, 1868, 1866, 1864, 1862, 1860, 1858, 1856, 1854, 1852, 1850, 1848, 1846, 1844, 1842, 1840, 1838, 1836, 1834, 1832, 1830, 1828, 1826, 1824, 1822, 1820, 1818, 1816, 1814, 1812, 1810, 1808, 1806, 1804, 1802, 1800, 1798, 1796, 1794, 1792, 1790, 1788, 1786, 1784, 1782, 1780, 1778, 1776, 1774, 1772, 1770, 1768, 1766, 1764, 1762, 1760, 1758, 1756, 1754, 1752, 1750, 1748, 1746, 1744, 1742, 1740, 1738, 1736, 1734, 1732, 1730, 1728, 1726, 1724, 1722, 1720, 1718, 1716, 1714, 1712, 1710, 1708, 1706, 1704, 1702, 1700, 1698, 1696, 1694, 1692, 1690, 1688, 1686, 1684, 1682, 1680, 1678, 1676, 1674, 1672, 1670, 1668, 1666, 1664, 1662, 1660, 1658, 1656, 1654, 1652, 1650, 1648, 1646, 1644, 1642, 1640, 1638, 1636, 1634, 1632, 1630, 1628, 1626, 1624, 1622, 1620, 1618, 1616, 1614, 1612, 1610, 1608, 1606, 1604, 1602, 1600, 1598, 1596, 1594, 1592, 1590, 1588, 1586, 1584, 1582, 1580, 1578, 1576, 1574, 1572, 1570, 1568, 1566, 1564, 1562, 1560, 1558, 1556, 1554, 1552, 1550, 1548, 1546, 1544, 1542, 1540, 1538, 1536, 1534, 1532, 1530, 1528, 1526, 1524, 1522, 1520, 1518, 1516, 1514, 1512, 1510, 1508, 1506, 1504, 1502, 1500, 1498, 1496, 1494, 1492, 1490, 1488, 1486, 1484, 1482, 1480, 1478, 1476, 1474, 1472, 1470, 1468, 1466, 1464, 1462, 1460, 1458, 1456, 1454, 1452, 1450, 1448, 1446, 1444, 1442, 1440, 1438, 1436, 1434, 1432, 1430, 1428, 1426, 1424, 1422, 1420, 1418, 1416, 1414, 1412, 1410, 1408, 1406, 1404, 1402, 1400, 1398, 1396, 1394, 1392, 1390, 1388, 1386, 1384, 1382, 1380, 1378, 1376, 1374, 1372, 1370, 1368, 1366, 1364, 1362, 1360, 1358, 1356, 1354, 1352, 1350, 1348, 1346, 1344, 1342, 1340, 1338, 1336, 1334, 1332, 1330, 1328, 1326, 1324, 1322, 1320, 1318, 1316, 1314, 1312, 1310, 1308, 1306, 1304, 1302, 1300, 1298, 1296, 1294, 1292, 1290, 1288, 1286, 1284, 1282, 1280, 1278, 1276, 1274, 1272, 1270, 1268, 1266, 1264, 1262, 1260, 1258, 1256, 1254, 1252, 1250, 1248, 1246, 1244, 1242, 1240, 1238, 1236, 1234, 1232, 1230, 1228, 1226, 1224, 1222, 1220, 1218, 1216, 1214, 1212, 1210, 1208, 1206, 1204, 1202, 1200, 1198, 1196, 1194, 1192, 1190, 1188, 1186, 1184, 1182, 1180, 1178, 1176, 1174, 1172, 1170, 1168, 1166, 1164, 1162, 1160, 1158, 1156, 1154, 1152, 1150, 1148, 1146, 1144, 1142, 1140, 1138, 1136, 1134, 1132, 1130, 1128, 1126, 1124, 1122, 1120, 1118, 1116, 1114, 1112, 1110, 1108, 1106, 1104, 1102, 1100, 1098, 1096, 1094, 1092, 1090, 1088, 1086, 1084, 1082, 1080, 1078, 1076, 1074, 1072, 1070, 1068, 1066, 1064, 1062, 1060, 1058, 1056, 1054, 1052, 1050, 1048, 1046, 1044, 1042, 1040, 1038, 1036, 1034, 1032, 1030, 1028, 1026, 1024, 1022, 1020, 1018, 1016, 1014, 1012, 1010, 1008, 1006, 1004, 1002, 1000, 998, 996, 994, 992, 990, 988, 986, 984, 982, 980, 978, 976, 974, 972, 970, 968, 966, 964, 962, 960, 958, 956, 954, 952, 950, 948, 946, 944, 942, 940, 938, 936, 934, 932, 930, 928, 926, 924, 922, 920, 918, 916, 914, 912, 910, 908, 906, 904, 902, 900, 898, 896, 894, 892, 890, 888, 886, 884, 882, 880, 878, 876, 874, 872, 870, 868, 866, 864, 862, 860, 858, 856, 854, 852, 850, 848, 846, 844, 842, 840, 838, 836, 834, 832, 830, 828, 826, 824, 822, 820, 818, 816, 814, 812, 810, 808, 806, 804, 802, 800, 798, 796, 794, 792, 790, 788, 786, 784, 782, 780, 778, 776, 774, 772, 770, 768, 766, 764, 762, 760, 758, 756, 754, 752, 750, 748, 746, 744, 742, 740, 738, 736, 734, 732, 730, 728, 726, 724, 722, 720, 718, 716, 714, 712, 710, 708, 706, 704, 702, 700, 698, 696, 694, 692, 690, 688, 686, 684, 682, 680, 678, 676, 674, 672, 670, 668, 666, 664, 662, 660, 658, 656, 654, 652, 650, 648, 646, 644, 642, 640, 638, 636, 634, 632, 630, 628, 626, 624, 622, 620, 618, 616, 614, 612, 610, 608, 606, 604, 602, 600, 598, 596, 594, 592, 590, 588, 586, 584, 582, 580, 578, 576, 574, 572, 570, 568, 566, 564, 562, 560, 558, 556, 554, 552, 550, 548, 546, 544, 542, 540, 538, 536, 534, 532, 530, 528, 526, 524, 522, 520, 518, 516, 514, 512, 510, 508, 506, 504, 502, 500, 498, 496, 494, 492, 490, 488, 486, 484, 482, 480, 478, 476, 474, 472, 470, 468, 466, 464, 462, 460, 458, 456, 454, 452, 450, 448, 446, 444, 442, 440, 438, 436, 434, 432, 430, 428, 426, 424, 422, 420, 418, 416, 414, 412, 410, 408, 406, 404, 402, 400, 398, 396, 394, 392, 390, 388, 386, 384, 382, 380, 378, 376, 374, 372, 370, 368, 366, 364, 362, 360, 358, 356, 354, 352, 350, 348, 346, 344, 342, 340, 338, 336, 334, 332, 330, 328, 326, 324, 322, 320, 318, 316, 314, 312, 310, 308, 306, 304, 302, 300, 298, 296, 294, 292, 290, 288, 286, 284, 282, 280, 278, 276, 274, 272, 270, 268, 266, 264, 262, 260, 258, 256, 254, 252, 250, 248, 246, 244, 242, 240, 238, 236, 234, 232, 230, 228, 226, 224, 222, 220, 218, 216, 214, 212, 210, 208, 206, 204, 202, 200, 198, 196, 194, 192, 190, 188, 186, 184, 182, 180, 178, 176, 174, 172, 170, 168, 166, 164, 162, 160, 158, 156, 154, 152, 150, 148, 146, 144, 142, 140, 138, 136, 134, 132, 130, 128, 126, 124, 122, 120, 118, 116, 114, 112, 110, 108, 106, 104, 102, 100, 98, 96, 94, 92, 90, 88, 86, 84, 82, 80, 78, 76, 74, 72, 70, 68, 66, 64, 62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0]\n assert candidate(n = 5000,x = 2500,y = 3000) == [10000, 10004, 10010, 10016, 10022, 10028, 10034, 10040, 10046, 10052, 10058, 10064, 10070, 10076, 10082, 10088, 10094, 10100, 10106, 10112, 10118, 10124, 10130, 10136, 10142, 10148, 10154, 10160, 10166, 10172, 10178, 10184, 10190, 10196, 10202, 10208, 10214, 10220, 10226, 10232, 10238, 10244, 10250, 10256, 10262, 10268, 10274, 10280, 10286, 10292, 10298, 10304, 10310, 10316, 10322, 10328, 10334, 10340, 10346, 10352, 10358, 10364, 10370, 10376, 10382, 10388, 10394, 10400, 10406, 10412, 10418, 10424, 10430, 10436, 10442, 10448, 10454, 10460, 10466, 10472, 10478, 10484, 10490, 10496, 10502, 10508, 10514, 10520, 10526, 10532, 10538, 10544, 10550, 10556, 10562, 10568, 10574, 10580, 10586, 10592, 10598, 10604, 10610, 10616, 10622, 10628, 10634, 10640, 10646, 10652, 10658, 10664, 10670, 10676, 10682, 10688, 10694, 10700, 10706, 10712, 10718, 10724, 10730, 10736, 10742, 10748, 10754, 10760, 10766, 10772, 10778, 10784, 10790, 10796, 10802, 10808, 10814, 10820, 10826, 10832, 10838, 10844, 10850, 10856, 10862, 10868, 10874, 10880, 10886, 10892, 10898, 10904, 10910, 10916, 10922, 10928, 10934, 10940, 10946, 10952, 10958, 10964, 10970, 10976, 10982, 10988, 10994, 11000, 11006, 11012, 11018, 11024, 11030, 11036, 11042, 11048, 11054, 11060, 11066, 11072, 11078, 11084, 11090, 11096, 11102, 11108, 11114, 11120, 11126, 11132, 11138, 11144, 11150, 11156, 11162, 11168, 11174, 11180, 11186, 11192, 11198, 11204, 11210, 11216, 11222, 11228, 11234, 11240, 11246, 11252, 11258, 11264, 11270, 11276, 11282, 11288, 11294, 11300, 11306, 11312, 11318, 11324, 11330, 11336, 11342, 11348, 11354, 11360, 11366, 11372, 11378, 11384, 11390, 11396, 11402, 11408, 11414, 11420, 11426, 11432, 11438, 11444, 11450, 11456, 11462, 11468, 11474, 11480, 11486, 11492, 10496, 10494, 10492, 10490, 10488, 10486, 10484, 10482, 10480, 10478, 10476, 10474, 10472, 10470, 10468, 10466, 10464, 10462, 10460, 10458, 10456, 10454, 10452, 10450, 10448, 10446, 10444, 10442, 10440, 10438, 10436, 10434, 10432, 10430, 10428, 10426, 10424, 10422, 10420, 10418, 10416, 10414, 10412, 10410, 10408, 10406, 10404, 10402, 10400, 10398, 10396, 10394, 10392, 10390, 10388, 10386, 10384, 10382, 10380, 10378, 10376, 10374, 10372, 10370, 10368, 10366, 10364, 10362, 10360, 10358, 10356, 10354, 10352, 10350, 10348, 10346, 10344, 10342, 10340, 10338, 10336, 10334, 10332, 10330, 10328, 10326, 10324, 10322, 10320, 10318, 10316, 10314, 10312, 10310, 10308, 10306, 10304, 10302, 10300, 10298, 10296, 10294, 10292, 10290, 10288, 10286, 10284, 10282, 10280, 10278, 10276, 10274, 10272, 10270, 10268, 10266, 10264, 10262, 10260, 10258, 10256, 10254, 10252, 10250, 10248, 10246, 10244, 10242, 10240, 10238, 10236, 10234, 10232, 10230, 10228, 10226, 10224, 10222, 10220, 10218, 10216, 10214, 10212, 10210, 10208, 10206, 10204, 10202, 10200, 10198, 10196, 10194, 10192, 10190, 10188, 10186, 10184, 10182, 10180, 10178, 10176, 10174, 10172, 10170, 10168, 10166, 10164, 10162, 10160, 10158, 10156, 10154, 10152, 10150, 10148, 10146, 10144, 10142, 10140, 10138, 10136, 10134, 10132, 10130, 10128, 10126, 10124, 10122, 10120, 10118, 10116, 10114, 10112, 10110, 10108, 10106, 10104, 10102, 10100, 10098, 10096, 10094, 10092, 10090, 10088, 10086, 10084, 10082, 10080, 10078, 10076, 10074, 10072, 10070, 10068, 10066, 10064, 10062, 10060, 10058, 10056, 10054, 10052, 10050, 10048, 10046, 10044, 10042, 10040, 10038, 10036, 10034, 10032, 10030, 10028, 10026, 10024, 10022, 10020, 10018, 10016, 10014, 10012, 10010, 10008, 10006, 10004, 10002, 10000, 9998, 9996, 9994, 9992, 9990, 9988, 9986, 9984, 9982, 9980, 9978, 9976, 9974, 9972, 9970, 9968, 9966, 9964, 9962, 9960, 9958, 9956, 9954, 9952, 9950, 9948, 9946, 9944, 9942, 9940, 9938, 9936, 9934, 9932, 9930, 9928, 9926, 9924, 9922, 9920, 9918, 9916, 9914, 9912, 9910, 9908, 9906, 9904, 9902, 9900, 9898, 9896, 9894, 9892, 9890, 9888, 9886, 9884, 9882, 9880, 9878, 9876, 9874, 9872, 9870, 9868, 9866, 9864, 9862, 9860, 9858, 9856, 9854, 9852, 9850, 9848, 9846, 9844, 9842, 9840, 9838, 9836, 9834, 9832, 9830, 9828, 9826, 9824, 9822, 9820, 9818, 9816, 9814, 9812, 9810, 9808, 9806, 9804, 9802, 9800, 9798, 9796, 9794, 9792, 9790, 9788, 9786, 9784, 9782, 9780, 9778, 9776, 9774, 9772, 9770, 9768, 9766, 9764, 9762, 9760, 9758, 9756, 9754, 9752, 9750, 9748, 9746, 9744, 9742, 9740, 9738, 9736, 9734, 9732, 9730, 9728, 9726, 9724, 9722, 9720, 9718, 9716, 9714, 9712, 9710, 9708, 9706, 9704, 9702, 9700, 9698, 9696, 9694, 9692, 9690, 9688, 9686, 9684, 9682, 9680, 9678, 9676, 9674, 9672, 9670, 9668, 9666, 9664, 9662, 9660, 9658, 9656, 9654, 9652, 9650, 9648, 9646, 9644, 9642, 9640, 9638, 9636, 9634, 9632, 9630, 9628, 9626, 9624, 9622, 9620, 9618, 9616, 9614, 9612, 9610, 9608, 9606, 9604, 9602, 9600, 9598, 9596, 9594, 9592, 9590, 9588, 9586, 9584, 9582, 9580, 9578, 9576, 9574, 9572, 9570, 9568, 9566, 9564, 9562, 9560, 9558, 9556, 9554, 9552, 9550, 9548, 9546, 9544, 9542, 9540, 9538, 9536, 9534, 9532, 9530, 9528, 9526, 9524, 9522, 9520, 9518, 9516, 9514, 9512, 9510, 9508, 9506, 9504, 9502, 9500, 9498, 9496, 9494, 9492, 9490, 9488, 9486, 9484, 9482, 9480, 9478, 9476, 9474, 9472, 9470, 9468, 9466, 9464, 9462, 9460, 9458, 9456, 9454, 9452, 9450, 9448, 9446, 9444, 9442, 9440, 9438, 9436, 9434, 9432, 9430, 9428, 9426, 9424, 9422, 9420, 9418, 9416, 9414, 9412, 9410, 9408, 9406, 9404, 9402, 9400, 9398, 9396, 9394, 9392, 9390, 9388, 9386, 9384, 9382, 9380, 9378, 9376, 9374, 9372, 9370, 9368, 9366, 9364, 9362, 9360, 9358, 9356, 9354, 9352, 9350, 9348, 9346, 9344, 9342, 9340, 9338, 9336, 9334, 9332, 9330, 9328, 9326, 9324, 9322, 9320, 9318, 9316, 9314, 9312, 9310, 9308, 9306, 9304, 9302, 9300, 9298, 9296, 9294, 9292, 9290, 9288, 9286, 9284, 9282, 9280, 9278, 9276, 9274, 9272, 9270, 9268, 9266, 9264, 9262, 9260, 9258, 9256, 9254, 9252, 9250, 9248, 9246, 9244, 9242, 9240, 9238, 9236, 9234, 9232, 9230, 9228, 9226, 9224, 9222, 9220, 9218, 9216, 9214, 9212, 9210, 9208, 9206, 9204, 9202, 9200, 9198, 9196, 9194, 9192, 9190, 9188, 9186, 9184, 9182, 9180, 9178, 9176, 9174, 9172, 9170, 9168, 9166, 9164, 9162, 9160, 9158, 9156, 9154, 9152, 9150, 9148, 9146, 9144, 9142, 9140, 9138, 9136, 9134, 9132, 9130, 9128, 9126, 9124, 9122, 9120, 9118, 9116, 9114, 9112, 9110, 9108, 9106, 9104, 9102, 9100, 9098, 9096, 9094, 9092, 9090, 9088, 9086, 9084, 9082, 9080, 9078, 9076, 9074, 9072, 9070, 9068, 9066, 9064, 9062, 9060, 9058, 9056, 9054, 9052, 9050, 9048, 9046, 9044, 9042, 9040, 9038, 9036, 9034, 9032, 9030, 9028, 9026, 9024, 9022, 9020, 9018, 9016, 9014, 9012, 9010, 9008, 9006, 9004, 9002, 9000, 8998, 8996, 8994, 8992, 8990, 8988, 8986, 8984, 8982, 8980, 8978, 8976, 8974, 8972, 8970, 8968, 8966, 8964, 8962, 8960, 8958, 8956, 8954, 8952, 8950, 8948, 8946, 8944, 8942, 8940, 8938, 8936, 8934, 8932, 8930, 8928, 8926, 8924, 8922, 8920, 8918, 8916, 8914, 8912, 8910, 8908, 8906, 8904, 8902, 8900, 8898, 8896, 8894, 8892, 8890, 8888, 8886, 8884, 8882, 8880, 8878, 8876, 8874, 8872, 8870, 8868, 8866, 8864, 8862, 8860, 8858, 8856, 8854, 8852, 8850, 8848, 8846, 8844, 8842, 8840, 8838, 8836, 8834, 8832, 8830, 8828, 8826, 8824, 8822, 8820, 8818, 8816, 8814, 8812, 8810, 8808, 8806, 8804, 8802, 8800, 8798, 8796, 8794, 8792, 8790, 8788, 8786, 8784, 8782, 8780, 8778, 8776, 8774, 8772, 8770, 8768, 8766, 8764, 8762, 8760, 8758, 8756, 8754, 8752, 8750, 8748, 8746, 8744, 8742, 8740, 8738, 8736, 8734, 8732, 8730, 8728, 8726, 8724, 8722, 8720, 8718, 8716, 8714, 8712, 8710, 8708, 8706, 8704, 8702, 8700, 8698, 8696, 8694, 8692, 8690, 8688, 8686, 8684, 8682, 8680, 8678, 8676, 8674, 8672, 8670, 8668, 8666, 8664, 8662, 8660, 8658, 8656, 8654, 8652, 8650, 8648, 8646, 8644, 8642, 8640, 8638, 8636, 8634, 8632, 8630, 8628, 8626, 8624, 8622, 8620, 8618, 8616, 8614, 8612, 8610, 8608, 8606, 8604, 8602, 8600, 8598, 8596, 8594, 8592, 8590, 8588, 8586, 8584, 8582, 8580, 8578, 8576, 8574, 8572, 8570, 8568, 8566, 8564, 8562, 8560, 8558, 8556, 8554, 8552, 8550, 8548, 8546, 8544, 8542, 8540, 8538, 8536, 8534, 8532, 8530, 8528, 8526, 8524, 8522, 8520, 8518, 8516, 8514, 8512, 8510, 8508, 8506, 8504, 8502, 8500, 8498, 8496, 8494, 8492, 8490, 8488, 8486, 8484, 8482, 8480, 8478, 8476, 8474, 8472, 8470, 8468, 8466, 8464, 8462, 8460, 8458, 8456, 8454, 8452, 8450, 8448, 8446, 8444, 8442, 8440, 8438, 8436, 8434, 8432, 8430, 8428, 8426, 8424, 8422, 8420, 8418, 8416, 8414, 8412, 8410, 8408, 8406, 8404, 8402, 8400, 8398, 8396, 8394, 8392, 8390, 8388, 8386, 8384, 8382, 8380, 8378, 8376, 8374, 8372, 8370, 8368, 8366, 8364, 8362, 8360, 8358, 8356, 8354, 8352, 8350, 8348, 8346, 8344, 8342, 8340, 8338, 8336, 8334, 8332, 8330, 8328, 8326, 8324, 8322, 8320, 8318, 8316, 8314, 8312, 8310, 8308, 8306, 8304, 8302, 8300, 8298, 8296, 8294, 8292, 8290, 8288, 8286, 8284, 8282, 8280, 8278, 8276, 8274, 8272, 8270, 8268, 8266, 8264, 8262, 8260, 8258, 8256, 8254, 8252, 8250, 8248, 8246, 8244, 8242, 8240, 8238, 8236, 8234, 8232, 8230, 8228, 8226, 8224, 8222, 8220, 8218, 8216, 8214, 8212, 8210, 8208, 8206, 8204, 8202, 8200, 8198, 8196, 8194, 8192, 8190, 8188, 8186, 8184, 8182, 8180, 8178, 8176, 8174, 8172, 8170, 8168, 8166, 8164, 8162, 8160, 8158, 8156, 8154, 8152, 8150, 8148, 8146, 8144, 8142, 8140, 8138, 8136, 8134, 8132, 8130, 8128, 8126, 8124, 8122, 8120, 8118, 8116, 8114, 8112, 8110, 8108, 8106, 8104, 8102, 8100, 8098, 8096, 8094, 8092, 8090, 8088, 8086, 8084, 8082, 8080, 8078, 8076, 8074, 8072, 8070, 8068, 8066, 8064, 8062, 8060, 8058, 8056, 8054, 8052, 8050, 8048, 8046, 8044, 8042, 8040, 8038, 8036, 8034, 8032, 8030, 8028, 8026, 8024, 8022, 8020, 8018, 8016, 8014, 8012, 8010, 8008, 8006, 8004, 8002, 8000, 7998, 7996, 7994, 7992, 7990, 7988, 7986, 7984, 7982, 7980, 7978, 7976, 7974, 7972, 7970, 7968, 7966, 7964, 7962, 7960, 7958, 7956, 7954, 7952, 7950, 7948, 7946, 7944, 7942, 7940, 7938, 7936, 7934, 7932, 7930, 7928, 7926, 7924, 7922, 7920, 7918, 7916, 7914, 7912, 7910, 7908, 7906, 7904, 7902, 7900, 7898, 7896, 7894, 7892, 7890, 7888, 7886, 7884, 7882, 7880, 7878, 7876, 7874, 7872, 7870, 7868, 7866, 7864, 7862, 7860, 7858, 7856, 7854, 7852, 7850, 7848, 7846, 7844, 7842, 7840, 7838, 7836, 7834, 7832, 7830, 7828, 7826, 7824, 7822, 7820, 7818, 7816, 7814, 7812, 7810, 7808, 7806, 7804, 7802, 7800, 7798, 7796, 7794, 7792, 7790, 7788, 7786, 7784, 7782, 7780, 7778, 7776, 7774, 7772, 7770, 7768, 7766, 7764, 7762, 7760, 7758, 7756, 7754, 7752, 7750, 7748, 7746, 7744, 7742, 7740, 7738, 7736, 7734, 7732, 7730, 7728, 7726, 7724, 7722, 7720, 7718, 7716, 7714, 7712, 7710, 7708, 7706, 7704, 7702, 7700, 7698, 7696, 7694, 7692, 7690, 7688, 7686, 7684, 7682, 7680, 7678, 7676, 7674, 7672, 7670, 7668, 7666, 7664, 7662, 7660, 7658, 7656, 7654, 7652, 7650, 7648, 7646, 7644, 7642, 7640, 7638, 7636, 7634, 7632, 7630, 7628, 7626, 7624, 7622, 7620, 7618, 7616, 7614, 7612, 7610, 7608, 7606, 7604, 7602, 7600, 7598, 7596, 7594, 7592, 7590, 7588, 7586, 7584, 7582, 7580, 7578, 7576, 7574, 7572, 7570, 7568, 7566, 7564, 7562, 7560, 7558, 7556, 7554, 7552, 7550, 7548, 7546, 7544, 7542, 7540, 7538, 7536, 7534, 7532, 7530, 7528, 7526, 7524, 7522, 7520, 7518, 7516, 7514, 7512, 7510, 7508, 7506, 7504, 7502, 7500, 7498, 7496, 7494, 7492, 7490, 7488, 7486, 7484, 7482, 7480, 7478, 7476, 7474, 7472, 7470, 7468, 7466, 7464, 7462, 7460, 7458, 7456, 7454, 7452, 7450, 7448, 7446, 7444, 7442, 7440, 7438, 7436, 7434, 7432, 7430, 7428, 7426, 7424, 7422, 7420, 7418, 7416, 7414, 7412, 7410, 7408, 7406, 7404, 7402, 7400, 7398, 7396, 7394, 7392, 7390, 7388, 7386, 7384, 7382, 7380, 7378, 7376, 7374, 7372, 7370, 7368, 7366, 7364, 7362, 7360, 7358, 7356, 7354, 7352, 7350, 7348, 7346, 7344, 7342, 7340, 7338, 7336, 7334, 7332, 7330, 7328, 7326, 7324, 7322, 7320, 7318, 7316, 7314, 7312, 7310, 7308, 7306, 7304, 7302, 7300, 7298, 7296, 7294, 7292, 7290, 7288, 7286, 7284, 7282, 7280, 7278, 7276, 7274, 7272, 7270, 7268, 7266, 7264, 7262, 7260, 7258, 7256, 7254, 7252, 7250, 7248, 7246, 7244, 7242, 7240, 7238, 7236, 7234, 7232, 7230, 7228, 7226, 7224, 7222, 7220, 7218, 7216, 7214, 7212, 7210, 7208, 7206, 7204, 7202, 7200, 7198, 7196, 7194, 7192, 7190, 7188, 7186, 7184, 7182, 7180, 7178, 7176, 7174, 7172, 7170, 7168, 7166, 7164, 7162, 7160, 7158, 7156, 7154, 7152, 7150, 7148, 7146, 7144, 7142, 7140, 7138, 7136, 7134, 7132, 7130, 7128, 7126, 7124, 7122, 7120, 7118, 7116, 7114, 7112, 7110, 7108, 7106, 7104, 7102, 7100, 7098, 7096, 7094, 7092, 7090, 7088, 7086, 7084, 7082, 7080, 7078, 7076, 7074, 7072, 7070, 7068, 7066, 7064, 7062, 7060, 7058, 7056, 7054, 7052, 7050, 7048, 7046, 7044, 7042, 7040, 7038, 7036, 7034, 7032, 7030, 7028, 7026, 7024, 7022, 7020, 7018, 7016, 7014, 7012, 7010, 7008, 7006, 7004, 7002, 7000, 6998, 6996, 6992, 6986, 6980, 6974, 6968, 6962, 6956, 6950, 6944, 6938, 6932, 6926, 6920, 6914, 6908, 6902, 6896, 6890, 6884, 6878, 6872, 6866, 6860, 6854, 6848, 6842, 6836, 6830, 6824, 6818, 6812, 6806, 6800, 6794, 6788, 6782, 6776, 6770, 6764, 6758, 6752, 6746, 6740, 6734, 6728, 6722, 6716, 6710, 6704, 6698, 6692, 6686, 6680, 6674, 6668, 6662, 6656, 6650, 6644, 6638, 6632, 6626, 6620, 6614, 6608, 6602, 6596, 6590, 6584, 6578, 6572, 6566, 6560, 6554, 6548, 6542, 6536, 6530, 6524, 6518, 6512, 6506, 6500, 6494, 6488, 6482, 6476, 6470, 6464, 6458, 6452, 6446, 6440, 6434, 6428, 6422, 6416, 6410, 6404, 6398, 6392, 6386, 6380, 6374, 6368, 6362, 6356, 6350, 6344, 6338, 6332, 6326, 6320, 6314, 6308, 6302, 6296, 6290, 6284, 6278, 6272, 6266, 6260, 6254, 6248, 6242, 6236, 6230, 6224, 6218, 6212, 6206, 6200, 6194, 6188, 6182, 6176, 6170, 6164, 6158, 6152, 6146, 6140, 6134, 6128, 6122, 6116, 6110, 6104, 6098, 6092, 6086, 6080, 6074, 6068, 6062, 6056, 6050, 6044, 6038, 6032, 6026, 6020, 6014, 6008, 6002, 5996, 5990, 5984, 5978, 5972, 5966, 5960, 5954, 5948, 5942, 5936, 5930, 5924, 5918, 5912, 5906, 5900, 5894, 5888, 5882, 5876, 5870, 5864, 5858, 5852, 5846, 5840, 5834, 5828, 5822, 5816, 5810, 5804, 5798, 5792, 5786, 5780, 5774, 5768, 5762, 5756, 5750, 5744, 5738, 5732, 5726, 5720, 5714, 5708, 5702, 5696, 5690, 5684, 5678, 5672, 5666, 5660, 5654, 5648, 5642, 5636, 5630, 5624, 5618, 5612, 5606, 5600, 5594, 5588, 5582, 5576, 5570, 5564, 5558, 5552, 5546, 5540, 5534, 5528, 5522, 5516, 5510, 5504, 5498, 5496, 5494, 5492, 5490, 5488, 5486, 5484, 5482, 5480, 5478, 5476, 5474, 5472, 5470, 5468, 5466, 5464, 5462, 5460, 5458, 5456, 5454, 5452, 5450, 5448, 5446, 5444, 5442, 5440, 5438, 5436, 5434, 5432, 5430, 5428, 5426, 5424, 5422, 5420, 5418, 5416, 5414, 5412, 5410, 5408, 5406, 5404, 5402, 5400, 5398, 5396, 5394, 5392, 5390, 5388, 5386, 5384, 5382, 5380, 5378, 5376, 5374, 5372, 5370, 5368, 5366, 5364, 5362, 5360, 5358, 5356, 5354, 5352, 5350, 5348, 5346, 5344, 5342, 5340, 5338, 5336, 5334, 5332, 5330, 5328, 5326, 5324, 5322, 5320, 5318, 5316, 5314, 5312, 5310, 5308, 5306, 5304, 5302, 5300, 5298, 5296, 5294, 5292, 5290, 5288, 5286, 5284, 5282, 5280, 5278, 5276, 5274, 5272, 5270, 5268, 5266, 5264, 5262, 5260, 5258, 5256, 5254, 5252, 5250, 5248, 5246, 5244, 5242, 5240, 5238, 5236, 5234, 5232, 5230, 5228, 5226, 5224, 5222, 5220, 5218, 5216, 5214, 5212, 5210, 5208, 5206, 5204, 5202, 5200, 5198, 5196, 5194, 5192, 5190, 5188, 5186, 5184, 5182, 5180, 5178, 5176, 5174, 5172, 5170, 5168, 5166, 5164, 5162, 5160, 5158, 5156, 5154, 5152, 5150, 5148, 5146, 5144, 5142, 5140, 5138, 5136, 5134, 5132, 5130, 5128, 5126, 5124, 5122, 5120, 5118, 5116, 5114, 5112, 5110, 5108, 5106, 5104, 5102, 5100, 5098, 5096, 5094, 5092, 5090, 5088, 5086, 5084, 5082, 5080, 5078, 5076, 5074, 5072, 5070, 5068, 5066, 5064, 5062, 5060, 5058, 5056, 5054, 5052, 5050, 5048, 5046, 5044, 5042, 5040, 5038, 5036, 5034, 5032, 5030, 5028, 5026, 5024, 5022, 5020, 5018, 5016, 5014, 5012, 5010, 5008, 5006, 5004, 5002, 5000, 4996, 4990, 4984, 4978, 4972, 4966, 4960, 4954, 4948, 4942, 4936, 4930, 4924, 4918, 4912, 4906, 4900, 4894, 4888, 4882, 4876, 4870, 4864, 4858, 4852, 4846, 4840, 4834, 4828, 4822, 4816, 4810, 4804, 4798, 4792, 4786, 4780, 4774, 4768, 4762, 4756, 4750, 4744, 4738, 4732, 4726, 4720, 4714, 4708, 4702, 4696, 4690, 4684, 4678, 4672, 4666, 4660, 4654, 4648, 4642, 4636, 4630, 4624, 4618, 4612, 4606, 4600, 4594, 4588, 4582, 4576, 4570, 4564, 4558, 4552, 4546, 4540, 4534, 4528, 4522, 4516, 4510, 4504, 4498, 4492, 4486, 4480, 4474, 4468, 4462, 4456, 4450, 4444, 4438, 4432, 4426, 4420, 4414, 4408, 4402, 4396, 4390, 4384, 4378, 4372, 4366, 4360, 4354, 4348, 4342, 4336, 4330, 4324, 4318, 4312, 4306, 4300, 4294, 4288, 4282, 4276, 4270, 4264, 4258, 4252, 4246, 4240, 4234, 4228, 4222, 4216, 4210, 4204, 4198, 4192, 4186, 4180, 4174, 4168, 4162, 4156, 4150, 4144, 4138, 4132, 4126, 4120, 4114, 4108, 4102, 4096, 4090, 4084, 4078, 4072, 4066, 4060, 4054, 4048, 4042, 4036, 4030, 4024, 4018, 4012, 4006, 4000, 3994, 3988, 3982, 3976, 3970, 3964, 3958, 3952, 3946, 3940, 3934, 3928, 3922, 3916, 3910, 3904, 3898, 3892, 3886, 3880, 3874, 3868, 3862, 3856, 3850, 3844, 3838, 3832, 3826, 3820, 3814, 3808, 3802, 3796, 3790, 3784, 3778, 3772, 3766, 3760, 3754, 3748, 3742, 3736, 3730, 3724, 3718, 3712, 3706, 3700, 3694, 3688, 3682, 3676, 3670, 3664, 3658, 3652, 3646, 3640, 3634, 3628, 3622, 3616, 3610, 3604, 3598, 3592, 3586, 3580, 3574, 3568, 3562, 3556, 3550, 3544, 3538, 3532, 3526, 3520, 3514, 3508, 3502, 3500, 3498, 3496, 3494, 3492, 3490, 3488, 3486, 3484, 3482, 3480, 3478, 3476, 3474, 3472, 3470, 3468, 3466, 3464, 3462, 3460, 3458, 3456, 3454, 3452, 3450, 3448, 3446, 3444, 3442, 3440, 3438, 3436, 3434, 3432, 3430, 3428, 3426, 3424, 3422, 3420, 3418, 3416, 3414, 3412, 3410, 3408, 3406, 3404, 3402, 3400, 3398, 3396, 3394, 3392, 3390, 3388, 3386, 3384, 3382, 3380, 3378, 3376, 3374, 3372, 3370, 3368, 3366, 3364, 3362, 3360, 3358, 3356, 3354, 3352, 3350, 3348, 3346, 3344, 3342, 3340, 3338, 3336, 3334, 3332, 3330, 3328, 3326, 3324, 3322, 3320, 3318, 3316, 3314, 3312, 3310, 3308, 3306, 3304, 3302, 3300, 3298, 3296, 3294, 3292, 3290, 3288, 3286, 3284, 3282, 3280, 3278, 3276, 3274, 3272, 3270, 3268, 3266, 3264, 3262, 3260, 3258, 3256, 3254, 3252, 3250, 3248, 3246, 3244, 3242, 3240, 3238, 3236, 3234, 3232, 3230, 3228, 3226, 3224, 3222, 3220, 3218, 3216, 3214, 3212, 3210, 3208, 3206, 3204, 3202, 3200, 3198, 3196, 3194, 3192, 3190, 3188, 3186, 3184, 3182, 3180, 3178, 3176, 3174, 3172, 3170, 3168, 3166, 3164, 3162, 3160, 3158, 3156, 3154, 3152, 3150, 3148, 3146, 3144, 3142, 3140, 3138, 3136, 3134, 3132, 3130, 3128, 3126, 3124, 3122, 3120, 3118, 3116, 3114, 3112, 3110, 3108, 3106, 3104, 3102, 3100, 3098, 3096, 3094, 3092, 3090, 3088, 3086, 3084, 3082, 3080, 3078, 3076, 3074, 3072, 3070, 3068, 3066, 3064, 3062, 3060, 3058, 3056, 3054, 3052, 3050, 3048, 3046, 3044, 3042, 3040, 3038, 3036, 3034, 3032, 3030, 3028, 3026, 3024, 3022, 3020, 3018, 3016, 3014, 3012, 3010, 3008, 3006, 3004, 3002, 3000, 2998, 2996, 2994, 2992, 2990, 2988, 2986, 2984, 2982, 2980, 2978, 2976, 2974, 2972, 2970, 2968, 2966, 2964, 2962, 2960, 2958, 2956, 2954, 2952, 2950, 2948, 2946, 2944, 2942, 2940, 2938, 2936, 2934, 2932, 2930, 2928, 2926, 2924, 2922, 2920, 2918, 2916, 2914, 2912, 2910, 2908, 2906, 2904, 2902, 2900, 2898, 2896, 2894, 2892, 2890, 2888, 2886, 2884, 2882, 2880, 2878, 2876, 2874, 2872, 2870, 2868, 2866, 2864, 2862, 2860, 2858, 2856, 2854, 2852, 2850, 2848, 2846, 2844, 2842, 2840, 2838, 2836, 2834, 2832, 2830, 2828, 2826, 2824, 2822, 2820, 2818, 2816, 2814, 2812, 2810, 2808, 2806, 2804, 2802, 2800, 2798, 2796, 2794, 2792, 2790, 2788, 2786, 2784, 2782, 2780, 2778, 2776, 2774, 2772, 2770, 2768, 2766, 2764, 2762, 2760, 2758, 2756, 2754, 2752, 2750, 2748, 2746, 2744, 2742, 2740, 2738, 2736, 2734, 2732, 2730, 2728, 2726, 2724, 2722, 2720, 2718, 2716, 2714, 2712, 2710, 2708, 2706, 2704, 2702, 2700, 2698, 2696, 2694, 2692, 2690, 2688, 2686, 2684, 2682, 2680, 2678, 2676, 2674, 2672, 2670, 2668, 2666, 2664, 2662, 2660, 2658, 2656, 2654, 2652, 2650, 2648, 2646, 2644, 2642, 2640, 2638, 2636, 2634, 2632, 2630, 2628, 2626, 2624, 2622, 2620, 2618, 2616, 2614, 2612, 2610, 2608, 2606, 2604, 2602, 2600, 2598, 2596, 2594, 2592, 2590, 2588, 2586, 2584, 2582, 2580, 2578, 2576, 2574, 2572, 2570, 2568, 2566, 2564, 2562, 2560, 2558, 2556, 2554, 2552, 2550, 2548, 2546, 2544, 2542, 2540, 2538, 2536, 2534, 2532, 2530, 2528, 2526, 2524, 2522, 2520, 2518, 2516, 2514, 2512, 2510, 2508, 2506, 2504, 2502, 2500, 2498, 2496, 2494, 2492, 2490, 2488, 2486, 2484, 2482, 2480, 2478, 2476, 2474, 2472, 2470, 2468, 2466, 2464, 2462, 2460, 2458, 2456, 2454, 2452, 2450, 2448, 2446, 2444, 2442, 2440, 2438, 2436, 2434, 2432, 2430, 2428, 2426, 2424, 2422, 2420, 2418, 2416, 2414, 2412, 2410, 2408, 2406, 2404, 2402, 2400, 2398, 2396, 2394, 2392, 2390, 2388, 2386, 2384, 2382, 2380, 2378, 2376, 2374, 2372, 2370, 2368, 2366, 2364, 2362, 2360, 2358, 2356, 2354, 2352, 2350, 2348, 2346, 2344, 2342, 2340, 2338, 2336, 2334, 2332, 2330, 2328, 2326, 2324, 2322, 2320, 2318, 2316, 2314, 2312, 2310, 2308, 2306, 2304, 2302, 2300, 2298, 2296, 2294, 2292, 2290, 2288, 2286, 2284, 2282, 2280, 2278, 2276, 2274, 2272, 2270, 2268, 2266, 2264, 2262, 2260, 2258, 2256, 2254, 2252, 2250, 2248, 2246, 2244, 2242, 2240, 2238, 2236, 2234, 2232, 2230, 2228, 2226, 2224, 2222, 2220, 2218, 2216, 2214, 2212, 2210, 2208, 2206, 2204, 2202, 2200, 2198, 2196, 2194, 2192, 2190, 2188, 2186, 2184, 2182, 2180, 2178, 2176, 2174, 2172, 2170, 2168, 2166, 2164, 2162, 2160, 2158, 2156, 2154, 2152, 2150, 2148, 2146, 2144, 2142, 2140, 2138, 2136, 2134, 2132, 2130, 2128, 2126, 2124, 2122, 2120, 2118, 2116, 2114, 2112, 2110, 2108, 2106, 2104, 2102, 2100, 2098, 2096, 2094, 2092, 2090, 2088, 2086, 2084, 2082, 2080, 2078, 2076, 2074, 2072, 2070, 2068, 2066, 2064, 2062, 2060, 2058, 2056, 2054, 2052, 2050, 2048, 2046, 2044, 2042, 2040, 2038, 2036, 2034, 2032, 2030, 2028, 2026, 2024, 2022, 2020, 2018, 2016, 2014, 2012, 2010, 2008, 2006, 2004, 2002, 2000, 1998, 1996, 1994, 1992, 1990, 1988, 1986, 1984, 1982, 1980, 1978, 1976, 1974, 1972, 1970, 1968, 1966, 1964, 1962, 1960, 1958, 1956, 1954, 1952, 1950, 1948, 1946, 1944, 1942, 1940, 1938, 1936, 1934, 1932, 1930, 1928, 1926, 1924, 1922, 1920, 1918, 1916, 1914, 1912, 1910, 1908, 1906, 1904, 1902, 1900, 1898, 1896, 1894, 1892, 1890, 1888, 1886, 1884, 1882, 1880, 1878, 1876, 1874, 1872, 1870, 1868, 1866, 1864, 1862, 1860, 1858, 1856, 1854, 1852, 1850, 1848, 1846, 1844, 1842, 1840, 1838, 1836, 1834, 1832, 1830, 1828, 1826, 1824, 1822, 1820, 1818, 1816, 1814, 1812, 1810, 1808, 1806, 1804, 1802, 1800, 1798, 1796, 1794, 1792, 1790, 1788, 1786, 1784, 1782, 1780, 1778, 1776, 1774, 1772, 1770, 1768, 1766, 1764, 1762, 1760, 1758, 1756, 1754, 1752, 1750, 1748, 1746, 1744, 1742, 1740, 1738, 1736, 1734, 1732, 1730, 1728, 1726, 1724, 1722, 1720, 1718, 1716, 1714, 1712, 1710, 1708, 1706, 1704, 1702, 1700, 1698, 1696, 1694, 1692, 1690, 1688, 1686, 1684, 1682, 1680, 1678, 1676, 1674, 1672, 1670, 1668, 1666, 1664, 1662, 1660, 1658, 1656, 1654, 1652, 1650, 1648, 1646, 1644, 1642, 1640, 1638, 1636, 1634, 1632, 1630, 1628, 1626, 1624, 1622, 1620, 1618, 1616, 1614, 1612, 1610, 1608, 1606, 1604, 1602, 1600, 1598, 1596, 1594, 1592, 1590, 1588, 1586, 1584, 1582, 1580, 1578, 1576, 1574, 1572, 1570, 1568, 1566, 1564, 1562, 1560, 1558, 1556, 1554, 1552, 1550, 1548, 1546, 1544, 1542, 1540, 1538, 1536, 1534, 1532, 1530, 1528, 1526, 1524, 1522, 1520, 1518, 1516, 1514, 1512, 1510, 1508, 1506, 1504, 1502, 1500, 1498, 1496, 1494, 1492, 1490, 1488, 1486, 1484, 1482, 1480, 1478, 1476, 1474, 1472, 1470, 1468, 1466, 1464, 1462, 1460, 1458, 1456, 1454, 1452, 1450, 1448, 1446, 1444, 1442, 1440, 1438, 1436, 1434, 1432, 1430, 1428, 1426, 1424, 1422, 1420, 1418, 1416, 1414, 1412, 1410, 1408, 1406, 1404, 1402, 1400, 1398, 1396, 1394, 1392, 1390, 1388, 1386, 1384, 1382, 1380, 1378, 1376, 1374, 1372, 1370, 1368, 1366, 1364, 1362, 1360, 1358, 1356, 1354, 1352, 1350, 1348, 1346, 1344, 1342, 1340, 1338, 1336, 1334, 1332, 1330, 1328, 1326, 1324, 1322, 1320, 1318, 1316, 1314, 1312, 1310, 1308, 1306, 1304, 1302, 1300, 1298, 1296, 1294, 1292, 1290, 1288, 1286, 1284, 1282, 1280, 1278, 1276, 1274, 1272, 1270, 1268, 1266, 1264, 1262, 1260, 1258, 1256, 1254, 1252, 1250, 1248, 1246, 1244, 1242, 1240, 1238, 1236, 1234, 1232, 1230, 1228, 1226, 1224, 1222, 1220, 1218, 1216, 1214, 1212, 1210, 1208, 1206, 1204, 1202, 1200, 1198, 1196, 1194, 1192, 1190, 1188, 1186, 1184, 1182, 1180, 1178, 1176, 1174, 1172, 1170, 1168, 1166, 1164, 1162, 1160, 1158, 1156, 1154, 1152, 1150, 1148, 1146, 1144, 1142, 1140, 1138, 1136, 1134, 1132, 1130, 1128, 1126, 1124, 1122, 1120, 1118, 1116, 1114, 1112, 1110, 1108, 1106, 1104, 1102, 1100, 1098, 1096, 1094, 1092, 1090, 1088, 1086, 1084, 1082, 1080, 1078, 1076, 1074, 1072, 1070, 1068, 1066, 1064, 1062, 1060, 1058, 1056, 1054, 1052, 1050, 1048, 1046, 1044, 1042, 1040, 1038, 1036, 1034, 1032, 1030, 1028, 1026, 1024, 1022, 1020, 1018, 1016, 1014, 1012, 1010, 1008, 1006, 1004, 1002, 1000, 998, 996, 994, 992, 990, 988, 986, 984, 982, 980, 978, 976, 974, 972, 970, 968, 966, 964, 962, 960, 958, 956, 954, 952, 950, 948, 946, 944, 942, 940, 938, 936, 934, 932, 930, 928, 926, 924, 922, 920, 918, 916, 914, 912, 910, 908, 906, 904, 902, 900, 898, 896, 894, 892, 890, 888, 886, 884, 882, 880, 878, 876, 874, 872, 870, 868, 866, 864, 862, 860, 858, 856, 854, 852, 850, 848, 846, 844, 842, 840, 838, 836, 834, 832, 830, 828, 826, 824, 822, 820, 818, 816, 814, 812, 810, 808, 806, 804, 802, 800, 798, 796, 794, 792, 790, 788, 786, 784, 782, 780, 778, 776, 774, 772, 770, 768, 766, 764, 762, 760, 758, 756, 754, 752, 750, 748, 746, 744, 742, 740, 738, 736, 734, 732, 730, 728, 726, 724, 722, 720, 718, 716, 714, 712, 710, 708, 706, 704, 702, 700, 698, 696, 694, 692, 690, 688, 686, 684, 682, 680, 678, 676, 674, 672, 670, 668, 666, 664, 662, 660, 658, 656, 654, 652, 650, 648, 646, 644, 642, 640, 638, 636, 634, 632, 630, 628, 626, 624, 622, 620, 618, 616, 614, 612, 610, 608, 606, 604, 602, 600, 598, 596, 594, 592, 590, 588, 586, 584, 582, 580, 578, 576, 574, 572, 570, 568, 566, 564, 562, 560, 558, 556, 554, 552, 550, 548, 546, 544, 542, 540, 538, 536, 534, 532, 530, 528, 526, 524, 522, 520, 518, 516, 514, 512, 510, 508, 506, 504, 502, 500, 498, 496, 494, 492, 490, 488, 486, 484, 482, 480, 478, 476, 474, 472, 470, 468, 466, 464, 462, 460, 458, 456, 454, 452, 450, 448, 446, 444, 442, 440, 438, 436, 434, 432, 430, 428, 426, 424, 422, 420, 418, 416, 414, 412, 410, 408, 406, 404, 402, 400, 398, 396, 394, 392, 390, 388, 386, 384, 382, 380, 378, 376, 374, 372, 370, 368, 366, 364, 362, 360, 358, 356, 354, 352, 350, 348, 346, 344, 342, 340, 338, 336, 334, 332, 330, 328, 326, 324, 322, 320, 318, 316, 314, 312, 310, 308, 306, 304, 302, 300, 298, 296, 294, 292, 290, 288, 286, 284, 282, 280, 278, 276, 274, 272, 270, 268, 266, 264, 262, 260, 258, 256, 254, 252, 250, 248, 246, 244, 242, 240, 238, 236, 234, 232, 230, 228, 226, 224, 222, 220, 218, 216, 214, 212, 210, 208, 206, 204, 202, 200, 198, 196, 194, 192, 190, 188, 186, 184, 182, 180, 178, 176, 174, 172, 170, 168, 166, 164, 162, 160, 158, 156, 154, 152, 150, 148, 146, 144, 142, 140, 138, 136, 134, 132, 130, 128, 126, 124, 122, 120, 118, 116, 114, 112, 110, 108, 106, 104, 102, 100, 98, 96, 94, 92, 90, 88, 86, 84, 82, 80, 78, 76, 74, 72, 70, 68, 66, 64, 62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 1000,x = 500,y = 750) == [2000, 2004, 2010, 2016, 2022, 2028, 2034, 2040, 2046, 2052, 2058, 2064, 2070, 2076, 2082, 2088, 2094, 2100, 2106, 2112, 2118, 2124, 2130, 2136, 2142, 2148, 2154, 2160, 2166, 2172, 2178, 2184, 2190, 2196, 2202, 2208, 2214, 2220, 2226, 2232, 2238, 2244, 2250, 2256, 2262, 2268, 2274, 2280, 2286, 2292, 2298, 2304, 2310, 2316, 2322, 2328, 2334, 2340, 2346, 2352, 2358, 2364, 2370, 2376, 2382, 2388, 2394, 2400, 2406, 2412, 2418, 2424, 2430, 2436, 2442, 2448, 2454, 2460, 2466, 2472, 2478, 2484, 2490, 2496, 2502, 2508, 2514, 2520, 2526, 2532, 2538, 2544, 2550, 2556, 2562, 2568, 2574, 2580, 2586, 2592, 2598, 2604, 2610, 2616, 2622, 2628, 2634, 2640, 2646, 2652, 2658, 2664, 2670, 2676, 2682, 2688, 2694, 2700, 2706, 2712, 2718, 2724, 2730, 2736, 2742, 2246, 2244, 2242, 2240, 2238, 2236, 2234, 2232, 2230, 2228, 2226, 2224, 2222, 2220, 2218, 2216, 2214, 2212, 2210, 2208, 2206, 2204, 2202, 2200, 2198, 2196, 2194, 2192, 2190, 2188, 2186, 2184, 2182, 2180, 2178, 2176, 2174, 2172, 2170, 2168, 2166, 2164, 2162, 2160, 2158, 2156, 2154, 2152, 2150, 2148, 2146, 2144, 2142, 2140, 2138, 2136, 2134, 2132, 2130, 2128, 2126, 2124, 2122, 2120, 2118, 2116, 2114, 2112, 2110, 2108, 2106, 2104, 2102, 2100, 2098, 2096, 2094, 2092, 2090, 2088, 2086, 2084, 2082, 2080, 2078, 2076, 2074, 2072, 2070, 2068, 2066, 2064, 2062, 2060, 2058, 2056, 2054, 2052, 2050, 2048, 2046, 2044, 2042, 2040, 2038, 2036, 2034, 2032, 2030, 2028, 2026, 2024, 2022, 2020, 2018, 2016, 2014, 2012, 2010, 2008, 2006, 2004, 2002, 2000, 1998, 1996, 1992, 1986, 1980, 1974, 1968, 1962, 1956, 1950, 1944, 1938, 1932, 1926, 1920, 1914, 1908, 1902, 1896, 1890, 1884, 1878, 1872, 1866, 1860, 1854, 1848, 1842, 1836, 1830, 1824, 1818, 1812, 1806, 1800, 1794, 1788, 1782, 1776, 1770, 1764, 1758, 1752, 1746, 1740, 1734, 1728, 1722, 1716, 1710, 1704, 1698, 1692, 1686, 1680, 1674, 1668, 1662, 1656, 1650, 1644, 1638, 1632, 1626, 1620, 1614, 1608, 1602, 1596, 1590, 1584, 1578, 1572, 1566, 1560, 1554, 1548, 1542, 1536, 1530, 1524, 1518, 1512, 1506, 1500, 1494, 1488, 1482, 1476, 1470, 1464, 1458, 1452, 1446, 1440, 1434, 1428, 1422, 1416, 1410, 1404, 1398, 1392, 1386, 1380, 1374, 1368, 1362, 1356, 1350, 1344, 1338, 1332, 1326, 1320, 1314, 1308, 1302, 1296, 1290, 1284, 1278, 1272, 1266, 1260, 1254, 1248, 1246, 1244, 1242, 1240, 1238, 1236, 1234, 1232, 1230, 1228, 1226, 1224, 1222, 1220, 1218, 1216, 1214, 1212, 1210, 1208, 1206, 1204, 1202, 1200, 1198, 1196, 1194, 1192, 1190, 1188, 1186, 1184, 1182, 1180, 1178, 1176, 1174, 1172, 1170, 1168, 1166, 1164, 1162, 1160, 1158, 1156, 1154, 1152, 1150, 1148, 1146, 1144, 1142, 1140, 1138, 1136, 1134, 1132, 1130, 1128, 1126, 1124, 1122, 1120, 1118, 1116, 1114, 1112, 1110, 1108, 1106, 1104, 1102, 1100, 1098, 1096, 1094, 1092, 1090, 1088, 1086, 1084, 1082, 1080, 1078, 1076, 1074, 1072, 1070, 1068, 1066, 1064, 1062, 1060, 1058, 1056, 1054, 1052, 1050, 1048, 1046, 1044, 1042, 1040, 1038, 1036, 1034, 1032, 1030, 1028, 1026, 1024, 1022, 1020, 1018, 1016, 1014, 1012, 1010, 1008, 1006, 1004, 1002, 1000, 996, 990, 984, 978, 972, 966, 960, 954, 948, 942, 936, 930, 924, 918, 912, 906, 900, 894, 888, 882, 876, 870, 864, 858, 852, 846, 840, 834, 828, 822, 816, 810, 804, 798, 792, 786, 780, 774, 768, 762, 756, 750, 744, 738, 732, 726, 720, 714, 708, 702, 696, 690, 684, 678, 672, 666, 660, 654, 648, 642, 636, 630, 624, 618, 612, 606, 600, 594, 588, 582, 576, 570, 564, 558, 552, 546, 540, 534, 528, 522, 516, 510, 504, 498, 492, 486, 480, 474, 468, 462, 456, 450, 444, 438, 432, 426, 420, 414, 408, 402, 396, 390, 384, 378, 372, 366, 360, 354, 348, 342, 336, 330, 324, 318, 312, 306, 300, 294, 288, 282, 276, 270, 264, 258, 252, 250, 248, 246, 244, 242, 240, 238, 236, 234, 232, 230, 228, 226, 224, 222, 220, 218, 216, 214, 212, 210, 208, 206, 204, 202, 200, 198, 196, 194, 192, 190, 188, 186, 184, 182, 180, 178, 176, 174, 172, 170, 168, 166, 164, 162, 160, 158, 156, 154, 152, 150, 148, 146, 144, 142, 140, 138, 136, 134, 132, 130, 128, 126, 124, 122, 120, 118, 116, 114, 112, 110, 108, 106, 104, 102, 100, 98, 96, 94, 92, 90, 88, 86, 84, 82, 80, 78, 76, 74, 72, 70, 68, 66, 64, 62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 120,x = 40,y = 80) == [240, 244, 250, 256, 262, 268, 274, 280, 286, 292, 298, 304, 310, 316, 322, 328, 334, 340, 346, 352, 276, 274, 272, 270, 268, 266, 264, 262, 260, 258, 256, 254, 252, 250, 248, 246, 244, 242, 240, 238, 234, 226, 216, 206, 196, 186, 176, 166, 156, 146, 136, 126, 116, 106, 96, 86, 76, 66, 56, 46, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 1000,x = 500,y = 600) == [2000, 2004, 2010, 2016, 2022, 2028, 2034, 2040, 2046, 2052, 2058, 2064, 2070, 2076, 2082, 2088, 2094, 2100, 2106, 2112, 2118, 2124, 2130, 2136, 2142, 2148, 2154, 2160, 2166, 2172, 2178, 2184, 2190, 2196, 2202, 2208, 2214, 2220, 2226, 2232, 2238, 2244, 2250, 2256, 2262, 2268, 2274, 2280, 2286, 2292, 2096, 2094, 2092, 2090, 2088, 2086, 2084, 2082, 2080, 2078, 2076, 2074, 2072, 2070, 2068, 2066, 2064, 2062, 2060, 2058, 2056, 2054, 2052, 2050, 2048, 2046, 2044, 2042, 2040, 2038, 2036, 2034, 2032, 2030, 2028, 2026, 2024, 2022, 2020, 2018, 2016, 2014, 2012, 2010, 2008, 2006, 2004, 2002, 2000, 1998, 1996, 1994, 1992, 1990, 1988, 1986, 1984, 1982, 1980, 1978, 1976, 1974, 1972, 1970, 1968, 1966, 1964, 1962, 1960, 1958, 1956, 1954, 1952, 1950, 1948, 1946, 1944, 1942, 1940, 1938, 1936, 1934, 1932, 1930, 1928, 1926, 1924, 1922, 1920, 1918, 1916, 1914, 1912, 1910, 1908, 1906, 1904, 1902, 1900, 1898, 1896, 1894, 1892, 1890, 1888, 1886, 1884, 1882, 1880, 1878, 1876, 1874, 1872, 1870, 1868, 1866, 1864, 1862, 1860, 1858, 1856, 1854, 1852, 1850, 1848, 1846, 1844, 1842, 1840, 1838, 1836, 1834, 1832, 1830, 1828, 1826, 1824, 1822, 1820, 1818, 1816, 1814, 1812, 1810, 1808, 1806, 1804, 1802, 1800, 1798, 1796, 1794, 1792, 1790, 1788, 1786, 1784, 1782, 1780, 1778, 1776, 1774, 1772, 1770, 1768, 1766, 1764, 1762, 1760, 1758, 1756, 1754, 1752, 1750, 1748, 1746, 1744, 1742, 1740, 1738, 1736, 1734, 1732, 1730, 1728, 1726, 1724, 1722, 1720, 1718, 1716, 1714, 1712, 1710, 1708, 1706, 1704, 1702, 1700, 1698, 1696, 1694, 1692, 1690, 1688, 1686, 1684, 1682, 1680, 1678, 1676, 1674, 1672, 1670, 1668, 1666, 1664, 1662, 1660, 1658, 1656, 1654, 1652, 1650, 1648, 1646, 1644, 1642, 1640, 1638, 1636, 1634, 1632, 1630, 1628, 1626, 1624, 1622, 1620, 1618, 1616, 1614, 1612, 1610, 1608, 1606, 1604, 1602, 1600, 1598, 1596, 1594, 1592, 1590, 1588, 1586, 1584, 1582, 1580, 1578, 1576, 1574, 1572, 1570, 1568, 1566, 1564, 1562, 1560, 1558, 1556, 1554, 1552, 1550, 1548, 1546, 1544, 1542, 1540, 1538, 1536, 1534, 1532, 1530, 1528, 1526, 1524, 1522, 1520, 1518, 1516, 1514, 1512, 1510, 1508, 1506, 1504, 1502, 1500, 1498, 1496, 1494, 1492, 1490, 1488, 1486, 1484, 1482, 1480, 1478, 1476, 1474, 1472, 1470, 1468, 1466, 1464, 1462, 1460, 1458, 1456, 1454, 1452, 1450, 1448, 1446, 1444, 1442, 1440, 1438, 1436, 1434, 1432, 1430, 1428, 1426, 1424, 1422, 1420, 1418, 1416, 1414, 1412, 1410, 1408, 1406, 1404, 1402, 1400, 1398, 1396, 1392, 1386, 1380, 1374, 1368, 1362, 1356, 1350, 1344, 1338, 1332, 1326, 1320, 1314, 1308, 1302, 1296, 1290, 1284, 1278, 1272, 1266, 1260, 1254, 1248, 1242, 1236, 1230, 1224, 1218, 1212, 1206, 1200, 1194, 1188, 1182, 1176, 1170, 1164, 1158, 1152, 1146, 1140, 1134, 1128, 1122, 1116, 1110, 1104, 1098, 1096, 1094, 1092, 1090, 1088, 1086, 1084, 1082, 1080, 1078, 1076, 1074, 1072, 1070, 1068, 1066, 1064, 1062, 1060, 1058, 1056, 1054, 1052, 1050, 1048, 1046, 1044, 1042, 1040, 1038, 1036, 1034, 1032, 1030, 1028, 1026, 1024, 1022, 1020, 1018, 1016, 1014, 1012, 1010, 1008, 1006, 1004, 1002, 1000, 996, 990, 984, 978, 972, 966, 960, 954, 948, 942, 936, 930, 924, 918, 912, 906, 900, 894, 888, 882, 876, 870, 864, 858, 852, 846, 840, 834, 828, 822, 816, 810, 804, 798, 792, 786, 780, 774, 768, 762, 756, 750, 744, 738, 732, 726, 720, 714, 708, 702, 700, 698, 696, 694, 692, 690, 688, 686, 684, 682, 680, 678, 676, 674, 672, 670, 668, 666, 664, 662, 660, 658, 656, 654, 652, 650, 648, 646, 644, 642, 640, 638, 636, 634, 632, 630, 628, 626, 624, 622, 620, 618, 616, 614, 612, 610, 608, 606, 604, 602, 600, 598, 596, 594, 592, 590, 588, 586, 584, 582, 580, 578, 576, 574, 572, 570, 568, 566, 564, 562, 560, 558, 556, 554, 552, 550, 548, 546, 544, 542, 540, 538, 536, 534, 532, 530, 528, 526, 524, 522, 520, 518, 516, 514, 512, 510, 508, 506, 504, 502, 500, 498, 496, 494, 492, 490, 488, 486, 484, 482, 480, 478, 476, 474, 472, 470, 468, 466, 464, 462, 460, 458, 456, 454, 452, 450, 448, 446, 444, 442, 440, 438, 436, 434, 432, 430, 428, 426, 424, 422, 420, 418, 416, 414, 412, 410, 408, 406, 404, 402, 400, 398, 396, 394, 392, 390, 388, 386, 384, 382, 380, 378, 376, 374, 372, 370, 368, 366, 364, 362, 360, 358, 356, 354, 352, 350, 348, 346, 344, 342, 340, 338, 336, 334, 332, 330, 328, 326, 324, 322, 320, 318, 316, 314, 312, 310, 308, 306, 304, 302, 300, 298, 296, 294, 292, 290, 288, 286, 284, 282, 280, 278, 276, 274, 272, 270, 268, 266, 264, 262, 260, 258, 256, 254, 252, 250, 248, 246, 244, 242, 240, 238, 236, 234, 232, 230, 228, 226, 224, 222, 220, 218, 216, 214, 212, 210, 208, 206, 204, 202, 200, 198, 196, 194, 192, 190, 188, 186, 184, 182, 180, 178, 176, 174, 172, 170, 168, 166, 164, 162, 160, 158, 156, 154, 152, 150, 148, 146, 144, 142, 140, 138, 136, 134, 132, 130, 128, 126, 124, 122, 120, 118, 116, 114, 112, 110, 108, 106, 104, 102, 100, 98, 96, 94, 92, 90, 88, 86, 84, 82, 80, 78, 76, 74, 72, 70, 68, 66, 64, 62, 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 200,x = 100,y = 150) == [400, 404, 410, 416, 422, 428, 434, 440, 446, 452, 458, 464, 470, 476, 482, 488, 494, 500, 506, 512, 518, 524, 530, 536, 542, 446, 444, 442, 440, 438, 436, 434, 432, 430, 428, 426, 424, 422, 420, 418, 416, 414, 412, 410, 408, 406, 404, 402, 400, 398, 396, 392, 386, 380, 374, 368, 362, 356, 350, 344, 338, 332, 326, 320, 314, 308, 302, 296, 290, 284, 278, 272, 266, 260, 254, 248, 246, 244, 242, 240, 238, 236, 234, 232, 230, 228, 226, 224, 222, 220, 218, 216, 214, 212, 210, 208, 206, 204, 202, 200, 196, 190, 184, 178, 172, 166, 160, 154, 148, 142, 136, 130, 124, 118, 112, 106, 100, 94, 88, 82, 76, 70, 64, 58, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 150,x = 75,y = 125) == [300, 304, 310, 316, 322, 328, 334, 340, 346, 352, 358, 364, 370, 376, 382, 388, 394, 400, 406, 412, 418, 424, 430, 436, 442, 346, 342, 336, 330, 324, 318, 312, 306, 300, 294, 288, 282, 276, 270, 264, 258, 252, 246, 240, 234, 228, 222, 216, 210, 204, 198, 196, 194, 192, 190, 188, 186, 184, 182, 180, 178, 176, 174, 172, 170, 168, 166, 164, 162, 160, 158, 156, 154, 152, 150, 146, 140, 134, 128, 122, 116, 110, 104, 98, 92, 86, 80, 74, 68, 62, 56, 50, 44, 38, 32, 26, 20, 14, 8, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 60,x = 20,y = 40) == [120, 124, 130, 136, 142, 148, 154, 160, 166, 172, 136, 134, 132, 130, 128, 126, 124, 122, 120, 118, 114, 106, 96, 86, 76, 66, 56, 46, 36, 26, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 2000,x = 1,y = 2000) == [4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 4000, 2000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 100,x = 3,y = 98) == [200, 204, 210, 212, 210, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 112, 12, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 12,x = 6,y = 6) == [22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0]\n"}, "metadata": {"canonical_parameter_names": ["n", "x", "y"], "leetcode_dataset_entry_point": "Solution().countOfPairs", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector countOfPairs(int n, int x, int y) {", "container": "Solution", "callable": "countOfPairs", "parameters": [{"name": "n", "type": "int"}, {"name": "x", "type": "int"}, {"name": "y", "type": "int"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3019, "task_id": "number-of-changing-keys", "difficulty": "Easy", "problem_description": "You are given a 0-indexed string s typed by a user. Changing a key is defined as using a key different from the last used key. For example, s = \"ab\" has a change of a key while s = \"bBBb\" does not have any.\nReturn the number of times the user had to change the key. \nNote: Modifiers like shift or caps lock won't be counted in changing the key that is if a user typed the letter 'a' and then the letter 'A' then it will not be considered as a changing of key.\n \nExample 1:\n\nInput: s = \"aAbBcC\"\nOutput: 2\nExplanation: \nFrom s[0] = 'a' to s[1] = 'A', there is no change of key as caps lock or shift is not counted.\nFrom s[1] = 'A' to s[2] = 'b', there is a change of key.\nFrom s[2] = 'b' to s[3] = 'B', there is no change of key as caps lock or shift is not counted.\nFrom s[3] = 'B' to s[4] = 'c', there is a change of key.\nFrom s[4] = 'c' to s[5] = 'C', there is no change of key as caps lock or shift is not counted.\n\n\nExample 2:\n\nInput: s = \"AaAaAaaA\"\nOutput: 0\nExplanation: There is no change of key since only the letters 'a' and 'A' are pressed which does not require change of key.\n\n \nConstraints:\n\n1 <= s.length <= 100\ns consists of only upper case and lower case English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"ZzZzZzZ\") == 0\n assert candidate(s = \"QwErTyUiOpAsDfGhJkLzXcVbNm\") == 25\n assert candidate(s = \"ABCDEFG\") == 6\n assert candidate(s = \"A\") == 0\n assert candidate(s = \"AaAaAaaA\") == 0\n assert candidate(s = \"zZyYxXwW\") == 3\n assert candidate(s = \"zZyYxXwWvVuUtTsSrRqQpPoOnNmMlLkKjJiIhHgGfFeEdDcCbBaA\") == 25\n assert candidate(s = \"aAbBcC\") == 2\n assert candidate(s = \"aBcDeFg\") == 6\n assert candidate(s = \"aBAcB\") == 4\n assert candidate(s = \"AbCdEfGhIjK\") == 10\n assert candidate(s = \"zzzzzzzz\") == 0\n assert candidate(s = \"aAaAaAaAaA\") == 0\n assert candidate(s = \"AAAAaaaAAA\") == 0\n assert candidate(s = \"AAaaaAA\") == 0\n assert candidate(s = \"a\") == 0\n assert candidate(s = \"abcdefg\") == 6\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == 25\n assert candidate(s = \"abcABCdefDEFghiGHIjklJKLmnoMNOpqrPQRstuSTUvwxVWXyzYZ\") == 51\n assert candidate(s = \"ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ\") == 51\n assert candidate(s = \"AbCdEfGhIjKlMnoPqRsTuVwXyZ\") == 25\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == 51\n assert candidate(s = \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaA\") == 0\n assert candidate(s = \"aBCdeFGhIJKlmNoPQRstUVwXYz\") == 25\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStUvWxYzA\") == 26\n assert candidate(s = \"aBcDefGhIjKlMnOpQrStUvWxYz\") == 25\n assert candidate(s = \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaA\") == 0\n assert candidate(s = \"abcDefGhIjKlMnOpQrStUvWxYzABC\") == 28\n assert candidate(s = \"AaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAa\") == 0\n assert candidate(s = \"abABcdCDefEFghGHijIJklKLmnMNopOPqrQRstSTuvUVwxWXyzYZ\") == 51\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == 25\n assert candidate(s = \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaA\") == 0\n assert candidate(s = \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAa\") == 0\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\") == 51\n assert candidate(s = \"bAcAdAeAfAgAhAiAjAkAlAmAnAoApAqArAsAtAuAvAwAxAyAz\") == 48\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\") == 77\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == 51\n assert candidate(s = \"mNbvCxZlkJhGfDsApOiUrYtWeQ\") == 25\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ\") == 77\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZ\") == 25\n assert candidate(s = \"abcdEFGHijklMNOPqrstUVWXyz\") == 25\n assert candidate(s = \"zYxWvUtSrQpOnMlKjIhGfEdCbA\") == 25\n assert candidate(s = \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAb\") == 1\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStUvWxYz\") == 25\n assert candidate(s = \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaA\") == 0\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\") == 77\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzAa\") == 26\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBc\") == 28\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzAaBbCcDdEeFf\") == 31\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcde\") == 30\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 51\n assert candidate(s = \"abcdefGHIJKLmnopQRstuvwxyzAbCdEfGHIJKLmnopQRstuvwxyz\") == 51\n assert candidate(s = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\") == 51\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZ\") == 51\n assert candidate(s = \"zZyYxXwWvVuUtTsSrRpPqQoOnNmMlLkKjJiIhHgGfFeEdDaA\") == 23\n assert candidate(s = \"aBcDabcdEFGHefghIJKLijklMNOpQRmnopqrSTUVstuvWXYZwxyz\") == 51\n assert candidate(s = \"aBcDabcdEFGHefghIJKLijklMNOpQRmnopqrSTUVstuvWXYZwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\") == 77\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzBb\") == 26\n assert candidate(s = \"zZyYxXwWvVuUtTsSrRpPqQoOnNmMlLkJiIhHgGfFeEdDcCbBaA\") == 25\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZ\") == 77\n assert candidate(s = \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaA\") == 0\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(s = \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaA\") == 0\n assert candidate(s = \"AaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAa\") == 0\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcDEFdef\") == 34\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStUvWxYzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == 51\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\") == 103\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzAaBbCc\") == 28\n assert candidate(s = \"abcdEFGHijklMNOpQRstUVWXyz\") == 25\n assert candidate(s = \"aBcDefGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYz\") == 51\n assert candidate(s = \"AaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAa\") == 0\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 25\n assert candidate(s = \"ZYXWVUTSRQPONMLKJIHGFEDCBAzyxwvutsrqponmlkjihgfedcba\") == 51\n assert candidate(s = \"zYxWvUtSrQpOnMlKjIhGfEdCbAbaCBEDFGHIJKLNMOPQRSTU VWXYZ\") == 53\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYz\") == 51\n assert candidate(s = \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaA\") == 0\n assert candidate(s = \"mNbVcXzLkJhGfDsApoIuYtReWq\") == 25\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().countKeyChanges", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int countKeyChanges(string s) {", "container": "Solution", "callable": "countKeyChanges", "parameters": [{"name": "s", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3020, "task_id": "find-the-maximum-number-of-elements-in-subset", "difficulty": "Medium", "problem_description": "You are given an array of positive integers nums.\nYou need to select a subset of nums which satisfies the following condition:\n\nYou can place the selected elements in a 0-indexed array such that it follows the pattern: [x, x2, x4, ..., xk/2, xk, xk/2, ..., x4, x2, x] (Note that k can be be any non-negative power of 2). For example, [2, 4, 16, 4, 2] and [3, 9, 3] follow the pattern while [2, 4, 8, 4, 2] does not.\n\nReturn the maximum number of elements in a subset that satisfies these conditions.\n \nExample 1:\n\nInput: nums = [5,4,1,2,2]\nOutput: 3\nExplanation: We can select the subset {4,2,2}, which can be placed in the array as [2,4,2] which follows the pattern and 22 == 4. Hence the answer is 3.\n\nExample 2:\n\nInput: nums = [1,3,2,4]\nOutput: 1\nExplanation: We can select the subset {1}, which can be placed in the array as [1] which follows the pattern. Hence the answer is 1. Note that we could have also selected the subsets {2}, {3}, or {4}, there may be multiple subsets which provide the same answer. \n\n \nConstraints:\n\n2 <= nums.length <= 105\n1 <= nums[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [9, 81, 729, 6561, 729, 81, 9]) == 5\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 1\n assert candidate(nums = [2, 4, 8, 16, 32, 16, 8, 4, 2]) == 5\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 1\n assert candidate(nums = [5, 5, 25, 25, 625, 625, 390625, 390625]) == 7\n assert candidate(nums = [2, 4, 8, 4, 2]) == 3\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 1\n assert candidate(nums = [5, 25, 625, 390625, 152587890625]) == 1\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 1\n assert candidate(nums = [7, 49, 343, 2401, 16807, 117649, 823543, 5764801, 40353607, 282475249, 1977326743]) == 1\n assert candidate(nums = [16, 4, 2, 8, 1, 32, 64, 128, 256, 512]) == 1\n assert candidate(nums = [7, 49, 343, 2401, 16807, 117649, 823543, 5764801, 40353607, 282475249, 2004767441, 14028366653, 98205841377, 686303773649, 4818903056257]) == 1\n assert candidate(nums = [5, 4, 1, 2, 2]) == 3\n assert candidate(nums = [2, 2, 2, 2, 2, 4, 4, 4, 16, 16, 256]) == 7\n assert candidate(nums = [3, 9, 27, 81, 27, 9, 3]) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1]) == 7\n assert candidate(nums = [2, 2, 4, 4, 16, 16, 256, 256]) == 7\n assert candidate(nums = [5, 25, 125, 625, 3125, 15625, 3125, 625, 125, 25, 5]) == 5\n assert candidate(nums = [3, 9, 3]) == 3\n assert candidate(nums = [6, 36, 216, 1296, 7776, 46656, 279936, 1679616, 10077696, 60466176, 362797056]) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 9\n assert candidate(nums = [1, 1, 1, 1, 1]) == 5\n assert candidate(nums = [9, 3, 1, 3, 9, 27, 27, 9, 3, 1]) == 3\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049]) == 1\n assert candidate(nums = [10, 100, 1000, 100, 10]) == 3\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 1\n assert candidate(nums = [7, 49, 343, 2401, 343, 49, 7]) == 5\n assert candidate(nums = [5, 5, 25, 625, 390625]) == 3\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31]) == 1\n assert candidate(nums = [2, 4, 16, 4, 2]) == 5\n assert candidate(nums = [3, 9, 3, 27, 9, 3]) == 3\n assert candidate(nums = [1, 3, 2, 4]) == 1\n assert candidate(nums = [10, 100, 1000, 10000, 100000, 10000, 1000, 100, 10]) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 31\n assert candidate(nums = [7, 49, 343, 2401, 16807, 117649, 823543, 5764801, 40353607, 282475249, 40353607, 5764801, 823543, 117649, 16807, 2401, 343, 49, 7]) == 7\n assert candidate(nums = [7, 49, 343, 2401, 16807, 117649, 823543, 5764801, 40353607, 282475249, 1977326743, 13841287201, 13841287201, 9765625, 25, 625, 15625, 390625, 15625, 625, 25]) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 25\n assert candidate(nums = [10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 1\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2]) == 7\n assert candidate(nums = [2, 8, 32, 128, 512, 2048, 8192, 32768, 131072, 524288, 2097152, 8388608, 33554432, 134217728, 536870912, 2147483648, 536870912, 134217728, 33554432, 8388608, 2097152, 524288, 131072, 32768, 8192, 2048, 512, 128, 32, 8, 2]) == 1\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049, 177147, 531441, 1594323, 4782969, 14348907, 43046721, 129140163, 387420489, 1162261467, 3486784401]) == 1\n assert candidate(nums = [13, 169, 2197, 28561, 371293, 4826809, 62748517, 815730721, 10604499373, 137858491849, 1792160394037, 23298085122481, 23298085122481, 1792160394037, 137858491849, 10604499373, 815730721, 62748517, 4826809, 371293, 28561, 2197, 169, 13]) == 7\n assert candidate(nums = [5, 25, 125, 625, 3125, 15625, 78125, 390625, 1953125, 9765625, 48828125, 244140625, 1220703125, 6103515625, 30517578125, 152587890625, 762939453125, 3814697265625, 19073486328125, 95367431640625, 95367431640625, 19073486328125, 3814697265625, 762939453125, 152587890625, 30517578125, 152587890625, 762939453125, 3814697265625, 19073486328125, 95367431640625, 476837158203125, 2384185791015625, 11920928955078125, 59604644775390625, 298023223876953125, 1490116119384765625, 7450580596923828125, 37252902984619140625, 37252902984619140625, 7450580596923828125, 1490116119384765625, 298023223876953125, 59604644775390625, 11920928955078125, 2384185791015625, 476837158203125]) == 1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == 1\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049, 177147, 531441, 1594323, 4782969, 14348907, 43046721, 129140163]) == 1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824]) == 1\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049, 177147, 531441, 1594323, 4782969, 14348907, 43046721, 129140163, 387420489, 1162261467, 3486784401, 3486784401, 1162261467, 387420489, 129140163, 43046721, 14348907, 4782969, 1594323, 531441, 177147, 59049, 19683, 6561, 2187, 729, 243, 81, 27, 9, 3]) == 9\n assert candidate(nums = [6, 36, 216, 1296, 7776, 46656, 279936, 1679616, 10077696, 60466176, 362797056, 2176782336, 13060694016, 78364164096, 470184984576, 2821109907456, 169262177488256, 101559956668416, 609359740010496, 3656158440062976]) == 1\n assert candidate(nums = [13, 169, 2197, 28561, 371293, 4826809, 62748517, 815730721, 10604499373, 137858491849, 1792160394037, 232980851224801, 29859888240166241, 389500817792690521, 4991423193762892481, 64363433748678318089, 832972009277289353601, 10828567056293836722761, 135649908587918453196281, 1700339869968924548498081]) == 1\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2]) == 7\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 1\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]) == 1\n assert candidate(nums = [7, 49, 343, 2401, 16807, 117649, 823543, 5764801, 40353607, 282475249, 1977326743]) == 1\n assert candidate(nums = [1, 16, 256, 4096, 65536, 1048576, 16777216, 268435456, 4294967296, 68719476736, 1099511627776, 17592186044416, 281474976710656, 4503599627370496, 72057594037927936, 1152921504606846976, 18446744073709551616, 18446744073709551616, 1152921504606846976, 72057594037927936, 4503599627370496, 281474976710656, 17592186044416, 1099511627776, 68719476736, 4294967296, 268435456, 16777216, 1048576, 65536, 4096, 256, 16, 1]) == 9\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199]) == 1\n assert candidate(nums = [5, 25, 125, 625, 3125, 15625, 78125, 390625, 1953125, 9765625, 48828125, 244140625, 1220703125, 6103515625, 30517578125, 152587890625, 762939453125, 3814697265625, 19073486328125, 95367431640625]) == 1\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 2187, 729, 243, 81, 27, 9, 3]) == 7\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049, 177147, 531441, 1594323, 4782969, 14348907, 43046721, 129140163, 387420489, 1162261467]) == 1\n assert candidate(nums = [1, 4, 16, 256, 65536, 4294967296, 18446744073709551616, 340282366920938463463374607431768211456, 115792089237316195423570985008687907853269984665640564039457584007913129639935]) == 1\n assert candidate(nums = [1, 4, 16, 64, 4096, 262144, 65536, 4096, 64, 16, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 11\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 19\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049, 177147, 531441, 1594323, 4782969, 14348907, 43046721, 129140163, 387420489, 1162261467, 3486784401, 3486784401, 1162261467, 387420489, 129140163, 43046721, 14348907, 4782969, 1594323, 531441, 177147, 59049, 19683, 6561, 2187, 729, 243, 81, 27, 9, 3]) == 9\n assert candidate(nums = [2, 8, 128, 32768, 8388608, 2147483648, 549755813888, 140737488355328, 36028797018963968, 9223372036854775808, 2417851639229258349412352, 618970019642690137449562112]) == 1\n assert candidate(nums = [2, 4, 16, 256, 65536, 4294967296, 65536, 256, 16, 4, 2]) == 11\n assert candidate(nums = [5, 25, 125, 625, 3125, 15625, 3125, 625, 125, 25, 5, 4, 16, 2, 8, 32, 64, 128, 256, 512]) == 5\n assert candidate(nums = [5, 25, 125, 625, 3125, 15625, 3125, 625, 125, 25, 5, 10, 100, 1000, 10000, 10000, 1000, 100, 10, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2]) == 7\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]) == 1\n assert candidate(nums = [7, 49, 343, 2401, 16807, 117649, 823543, 5764801, 40353607, 282475249, 1977326743, 13841287201, 96889010407, 678223072849, 4747561509943, 33232930569601, 232980851224811, 1630777592533921]) == 1\n assert candidate(nums = [10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 100000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10]) == 7\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 27\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 19\n assert candidate(nums = [9, 81, 729, 6561, 59049, 531441, 4782969, 43046721, 387420489, 3486784401, 31381059609, 282429536481, 2541865828329, 22876792454961, 205891132094649, 1853020188851841, 16679885062227201, 150094635296999121, 1350851717672992089, 12157665459056928701, 109418989131512358309]) == 1\n assert candidate(nums = [5, 25, 125, 625, 3125, 15625, 78125, 390625, 1953125, 9765625, 48828125, 244140625, 1220703125, 6103515625, 30517578125, 152587890625, 762939453125, 3814697265625, 19073486328125, 95367431640625]) == 1\n assert candidate(nums = [4, 16, 64, 256, 1024, 4096, 16384, 65536, 262144, 1048576, 4194304, 16777216, 4194304, 1048576, 262144, 65536, 16384, 4096, 1024, 256, 64, 16, 4]) == 7\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 8, 8, 8, 8, 16, 16, 16, 16, 32, 32, 32, 32, 64, 64, 64, 64, 128, 128, 128, 128, 256, 256, 256, 256, 512, 512, 512, 512]) == 7\n assert candidate(nums = [9, 81, 729, 6561, 59049, 531441, 4782969, 43046721, 387420489, 3486784401, 3486784401, 387420489, 43046721, 4782969, 531441, 59049, 6561, 729, 81, 9]) == 7\n assert candidate(nums = [5, 25, 125, 625, 3125, 15625, 3125, 625, 125, 25, 5, 4, 16, 2, 8, 32, 64, 128, 256, 512, 3, 9, 27, 81, 243, 729, 2187, 6561, 2187, 729, 243, 81, 27, 9, 3]) == 7\n assert candidate(nums = [7, 49, 343, 2401, 16807, 117649, 823543, 5764801, 40353607, 282475249, 1977326743, 13841287201, 96889010407, 678223072849, 4747561509943, 33232930569601, 232980851224807, 1628413597910449, 11398895185373143, 79792266297612001]) == 1\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824]) == 1\n assert candidate(nums = [2, 8, 32, 128, 512, 2048, 8192, 32768, 131072, 524288, 131072, 32768, 8192, 2048, 512, 128, 32, 8, 2]) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 47\n assert candidate(nums = [9, 81, 729, 6561, 59049, 531441, 4782969, 43046721, 387420489, 3486784401, 31381059609, 282429536481, 2541865828329, 22876792454961, 205891132094649, 1845281407153073, 16384135970557337, 14348907, 81, 9]) == 5\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824, 1073741824, 536870912, 268435456, 134217728, 67108864, 33554432, 16777216, 8388608, 4194304, 2097152, 1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2]) == 9\n assert candidate(nums = [5, 25, 125, 625, 3125, 15625, 78125, 390625, 1953125, 9765625, 48828125, 244140625, 1220703125, 6103515625, 30517578125, 152587890625, 762939453125, 3814697265625, 19073486328125]) == 1\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maximumLength", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maximumLength(vector& nums) {", "container": "Solution", "callable": "maximumLength", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3021, "task_id": "alice-and-bob-playing-flower-game", "difficulty": "Medium", "problem_description": "Alice and Bob are playing a turn-based game on a circular field surrounded by flowers. The circle represents the field, and there are x flowers in the clockwise direction between Alice and Bob, and y flowers in the anti-clockwise direction between them.\nThe game proceeds as follows:\n\nAlice takes the first turn.\nIn each turn, a player must choose either the clockwise or anti-clockwise direction and pick one flower from that side.\nAt the end of the turn, if there are no flowers left at all, the current player captures their opponent and wins the game.\n\nGiven two integers, n and m, the task is to compute the number of possible pairs (x, y) that satisfy the conditions:\n\nAlice must win the game according to the described rules.\nThe number of flowers x in the clockwise direction must be in the range [1,n].\nThe number of flowers y in the anti-clockwise direction must be in the range [1,m].\n\nReturn the number of possible pairs (x, y) that satisfy the conditions mentioned in the statement.\n \nExample 1:\n\nInput: n = 3, m = 2\nOutput: 3\nExplanation: The following pairs satisfy conditions described in the statement: (1,2), (3,2), (2,1).\n\nExample 2:\n\nInput: n = 1, m = 1\nOutput: 0\nExplanation: No pairs satisfy the conditions described in the statement.\n\n \nConstraints:\n\n1 <= n, m <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 5,m = 7) == 17\n assert candidate(n = 5,m = 4) == 10\n assert candidate(n = 1,m = 1) == 0\n assert candidate(n = 100,m = 200) == 10000\n assert candidate(n = 4,m = 3) == 6\n assert candidate(n = 100000,m = 100000) == 5000000000\n assert candidate(n = 3,m = 2) == 3\n assert candidate(n = 10,m = 10) == 50\n assert candidate(n = 5,m = 5) == 12\n assert candidate(n = 2,m = 2) == 2\n assert candidate(n = 75000,m = 25000) == 937500000\n assert candidate(n = 7,m = 11) == 38\n assert candidate(n = 25000,m = 75000) == 937500000\n assert candidate(n = 99,m = 101) == 4999\n assert candidate(n = 30000,m = 40000) == 600000000\n assert candidate(n = 1,m = 200000) == 100000\n assert candidate(n = 99999,m = 2) == 99999\n assert candidate(n = 50000,m = 100000) == 2500000000\n assert candidate(n = 10,m = 1) == 5\n assert candidate(n = 1000,m = 1000) == 500000\n assert candidate(n = 33333,m = 66667) == 1111105555\n assert candidate(n = 7,m = 8) == 28\n assert candidate(n = 33333,m = 66666) == 1111088889\n assert candidate(n = 75000,m = 85000) == 3187500000\n assert candidate(n = 99999,m = 99999) == 4999900000\n assert candidate(n = 10000,m = 5000) == 25000000\n assert candidate(n = 99999,m = 100000) == 4999950000\n assert candidate(n = 3,m = 3) == 4\n assert candidate(n = 500,m = 500) == 125000\n assert candidate(n = 100,m = 100) == 5000\n assert candidate(n = 15,m = 25) == 187\n assert candidate(n = 50000,m = 50000) == 1250000000\n assert candidate(n = 60000,m = 40000) == 1200000000\n assert candidate(n = 20000,m = 10000) == 100000000\n assert candidate(n = 5000,m = 5000) == 12500000\n assert candidate(n = 1,m = 99999) == 49999\n assert candidate(n = 55,m = 88) == 2420\n assert candidate(n = 1,m = 10) == 5\n assert candidate(n = 20,m = 15) == 150\n assert candidate(n = 50,m = 60) == 1500\n assert candidate(n = 2,m = 99999) == 99999\n assert candidate(n = 1,m = 100000) == 50000\n assert candidate(n = 300,m = 200) == 30000\n assert candidate(n = 20000,m = 20000) == 200000000\n assert candidate(n = 50000,m = 1) == 25000\n assert candidate(n = 10,m = 15) == 75\n assert candidate(n = 50,m = 50) == 1250\n assert candidate(n = 7,m = 5) == 17\n assert candidate(n = 1000,m = 500) == 250000\n assert candidate(n = 200000,m = 1) == 100000\n assert candidate(n = 20000,m = 30000) == 300000000\n assert candidate(n = 200,m = 300) == 30000\n assert candidate(n = 150,m = 150) == 11250\n assert candidate(n = 23456,m = 65432) == 767386496\n assert candidate(n = 30000,m = 20000) == 300000000\n assert candidate(n = 1000,m = 1500) == 750000\n assert candidate(n = 49999,m = 50001) == 1249999999\n assert candidate(n = 2,m = 3) == 3\n assert candidate(n = 80000,m = 20000) == 800000000\n assert candidate(n = 25,m = 30) == 375\n assert candidate(n = 99999,m = 1) == 49999\n assert candidate(n = 10000,m = 10000) == 50000000\n assert candidate(n = 12345,m = 67890) == 419051025\n assert candidate(n = 15,m = 15) == 112\n assert candidate(n = 66667,m = 33333) == 1111105555\n assert candidate(n = 100000,m = 1) == 50000\n"}, "metadata": {"canonical_parameter_names": ["n", "m"], "leetcode_dataset_entry_point": "Solution().flowerGame", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "long long flowerGame(int n, int m) {", "container": "Solution", "callable": "flowerGame", "parameters": [{"name": "n", "type": "int"}, {"name": "m", "type": "int"}], "return_type": "long long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3022, "task_id": "minimize-or-of-remaining-elements-using-operations", "difficulty": "Hard", "problem_description": "You are given a 0-indexed integer array nums and an integer k.\nIn one operation, you can pick any index i of nums such that 0 <= i < nums.length - 1 and replace nums[i] and nums[i + 1] with a single occurrence of nums[i] & nums[i + 1], where & represents the bitwise AND operator.\nReturn the minimum possible value of the bitwise OR of the remaining elements of nums after applying at most k operations.\n \nExample 1:\n\nInput: nums = [3,5,3,2,7], k = 2\nOutput: 3\nExplanation: Let's do the following operations:\n1. Replace nums[0] and nums[1] with (nums[0] & nums[1]) so that nums becomes equal to [1,3,2,7].\n2. Replace nums[2] and nums[3] with (nums[2] & nums[3]) so that nums becomes equal to [1,3,2].\nThe bitwise-or of the final array is 3.\nIt can be shown that 3 is the minimum possible value of the bitwise OR of the remaining elements of nums after applying at most k operations.\nExample 2:\n\nInput: nums = [7,3,15,14,2,8], k = 4\nOutput: 2\nExplanation: Let's do the following operations:\n1. Replace nums[0] and nums[1] with (nums[0] & nums[1]) so that nums becomes equal to [3,15,14,2,8]. \n2. Replace nums[0] and nums[1] with (nums[0] & nums[1]) so that nums becomes equal to [3,14,2,8].\n3. Replace nums[0] and nums[1] with (nums[0] & nums[1]) so that nums becomes equal to [2,2,8].\n4. Replace nums[1] and nums[2] with (nums[1] & nums[2]) so that nums becomes equal to [2,0].\nThe bitwise-or of the final array is 2.\nIt can be shown that 2 is the minimum possible value of the bitwise OR of the remaining elements of nums after applying at most k operations.\n\nExample 3:\n\nInput: nums = [10,7,10,3,9,14,9,4], k = 1\nOutput: 15\nExplanation: Without applying any operations, the bitwise-or of nums is 15.\nIt can be shown that 15 is the minimum possible value of the bitwise OR of the remaining elements of nums after applying at most k operations.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n0 <= nums[i] < 230\n0 <= k < nums.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [30, 20, 10, 0],k = 2) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5],k = 5) == 5\n assert candidate(nums = [0, 0, 0, 0, 0],k = 0) == 0\n assert candidate(nums = [1, 0, 1, 0, 1],k = 2) == 1\n assert candidate(nums = [31, 31, 31, 31, 31],k = 3) == 31\n assert candidate(nums = [1, 2, 3, 4, 5],k = 3) == 0\n assert candidate(nums = [0, 0, 0, 0, 0],k = 2) == 0\n assert candidate(nums = [30, 29, 28, 27, 26],k = 5) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 7\n assert candidate(nums = [8, 8, 8, 8, 8],k = 2) == 8\n assert candidate(nums = [29, 29, 29, 29, 29],k = 4) == 29\n assert candidate(nums = [25, 15, 5, 1, 0],k = 3) == 1\n assert candidate(nums = [1, 3, 5, 7, 9, 11],k = 3) == 1\n assert candidate(nums = [30, 29, 28, 27, 26, 25],k = 5) == 24\n assert candidate(nums = [10, 7, 10, 3, 9, 14, 9, 4],k = 1) == 15\n assert candidate(nums = [1, 2, 4, 8, 16],k = 2) == 1\n assert candidate(nums = [8, 12, 4, 6, 10],k = 2) == 12\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 9) == 1\n assert candidate(nums = [7, 3, 15, 14, 2, 8],k = 4) == 2\n assert candidate(nums = [31, 15, 7, 3, 1],k = 4) == 1\n assert candidate(nums = [16, 16, 16, 16, 16],k = 0) == 16\n assert candidate(nums = [31, 31, 31, 31, 31],k = 4) == 31\n assert candidate(nums = [3, 5, 3, 2, 7],k = 2) == 3\n assert candidate(nums = [1, 1, 1, 1, 1],k = 4) == 1\n assert candidate(nums = [31, 15, 7, 3, 1],k = 3) == 3\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7],k = 6) == 7\n assert candidate(nums = [255, 127, 63, 31, 15, 7, 3, 1],k = 3) == 31\n assert candidate(nums = [31, 31, 31, 31, 31, 31, 31, 31, 31, 31],k = 9) == 31\n assert candidate(nums = [15, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 4) == 7\n assert candidate(nums = [16, 8, 4, 2, 1, 32, 16, 8, 4, 2, 1],k = 7) == 0\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023],k = 9) == 1\n assert candidate(nums = [30, 21, 45, 12, 8, 16, 32, 64, 128, 256],k = 7) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 10) == 7\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 5) == 31\n assert candidate(nums = [255, 254, 253, 252, 251, 250, 249, 248, 247, 246],k = 5) == 254\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 10) == 3\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023],k = 5) == 31\n assert candidate(nums = [128, 64, 32, 16, 8, 4, 2, 1, 0],k = 7) == 0\n assert candidate(nums = [18, 5, 12, 9, 3, 14, 7, 11, 6, 4, 10, 8, 2, 13, 1],k = 10) == 1\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575],k = 19) == 1\n assert candidate(nums = [1048575, 524287, 262143, 131071, 65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],k = 19) == 1\n assert candidate(nums = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15],k = 25) == 15\n assert candidate(nums = [31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31],k = 18) == 31\n assert candidate(nums = [31, 14, 7, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 28) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 4) == 62\n assert candidate(nums = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1],k = 5) == 15\n assert candidate(nums = [31, 14, 7, 3, 1, 0, 0, 0, 0, 0],k = 10) == 0\n assert candidate(nums = [512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],k = 19) == 0\n assert candidate(nums = [2147483647, 1073741823, 536870911, 268435455, 134217727, 67108863, 33554431, 16777215, 8388607, 4194303],k = 9) == 4194303\n assert candidate(nums = [1048575, 524287, 262143, 131071, 65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 25) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 25) == 1\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],k = 8) == 7\n assert candidate(nums = [1048575, 524287, 262143, 131071, 65535, 32767, 16383, 8191, 4095, 2047],k = 9) == 2047\n assert candidate(nums = [10, 20, 40, 80, 160, 320, 640, 1280, 2560, 5120],k = 9) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 9) == 1\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 29) == 3\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],k = 9) == 1\n assert candidate(nums = [31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 29) == 0\n assert candidate(nums = [1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023],k = 9) == 1023\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 15) == 15\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 19) == 1\n assert candidate(nums = [2147483647, 2147483647, 2147483647, 2147483647, 2147483647],k = 100000) == 0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97],k = 20) == 3\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 25) == 7\n assert candidate(nums = [255, 255, 255, 255, 255, 255, 255, 255, 255, 255],k = 9) == 255\n assert candidate(nums = [255, 127, 63, 31, 15, 7, 3, 1, 0, 255, 128],k = 10) == 0\n assert candidate(nums = [30, 15, 7, 3, 1, 15, 7, 3, 1, 15, 7, 3, 1, 15, 7, 3, 1, 15, 7, 3],k = 15) == 3\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21],k = 5) == 28\n assert candidate(nums = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21],k = 5) == 15\n assert candidate(nums = [1023, 1022, 1021, 1020, 1019, 1018, 1017, 1016, 1015, 1014, 1013, 1012, 1011, 1010, 1009],k = 13) == 1008\n assert candidate(nums = [29, 21, 13, 5, 1],k = 3) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 29) == 1\n assert candidate(nums = [29, 31, 28, 27, 26, 25, 24, 23, 22, 21],k = 8) == 20\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],k = 5) == 4088\n assert candidate(nums = [29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 29) == 0\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],k = 13) == 0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113],k = 15) == 63\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],k = 9) == 0\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0],k = 9) == 1\n assert candidate(nums = [4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0, 0, 0, 0],k = 13) == 0\n assert candidate(nums = [50, 40, 30, 20, 10, 5, 3, 1],k = 6) == 0\n assert candidate(nums = [255, 127, 63, 31, 15, 7, 3, 1, 255, 127, 63],k = 10) == 1\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],k = 10) == 0\n assert candidate(nums = [1048575, 524287, 262143, 131071, 65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],k = 15) == 31\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 7) == 5\n assert candidate(nums = [30, 14, 7, 3, 1, 0, 15, 8, 4, 2],k = 6) == 2\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095],k = 11) == 1\n assert candidate(nums = [255, 128, 64, 32, 16, 8, 4, 2, 1],k = 7) == 0\n assert candidate(nums = [255, 128, 64, 32, 16, 8, 4, 2, 1, 255, 128, 64, 32, 16, 8, 4, 2, 1],k = 17) == 0\n assert candidate(nums = [2147483647, 1073741823, 536870911, 268435455, 134217727, 67108863, 33554431, 16777215, 8388607, 4194303],k = 3) == 268435455\n assert candidate(nums = [31, 62, 124, 248, 496, 992, 1984, 3968, 7936, 15872],k = 8) == 24\n assert candidate(nums = [30, 28, 24, 16, 8, 4, 2, 1],k = 6) == 0\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],k = 8) == 3\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 14) == 0\n assert candidate(nums = [128, 64, 32, 16, 8, 4, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0],k = 14) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 1\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],k = 5) == 31\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 7) == 5\n assert candidate(nums = [29, 21, 14, 7, 3, 1, 0],k = 6) == 0\n assert candidate(nums = [255, 127, 63, 31, 15, 7, 3, 1, 255, 127, 63, 31, 15, 7, 3, 1, 255, 127, 63, 31],k = 18) == 1\n assert candidate(nums = [1048575, 524287, 262143, 131071, 65535, 32767, 16383, 8191, 4095, 2047],k = 8) == 4095\n assert candidate(nums = [29, 17, 3, 15, 8, 12, 7],k = 3) == 15\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125],k = 5) == 16777215\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576],k = 19) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 4) == 1\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 9) == 3\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 25) == 3\n assert candidate(nums = [17, 34, 68, 136, 272, 544, 1088, 2176, 4352, 8704],k = 5) == 0\n assert candidate(nums = [2147483647, 1073741823, 536870911, 268435455, 134217727, 67108863, 33554431, 16777215, 8388607, 4194303, 2097151, 1048575, 524287, 262143, 131071, 65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],k = 25) == 63\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().minOrAfterOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minOrAfterOperations(vector& nums, int k) {", "container": "Solution", "callable": "minOrAfterOperations", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3024, "task_id": "type-of-triangle", "difficulty": "Easy", "problem_description": "You are given a 0-indexed integer array nums of size 3 which can form the sides of a triangle.\n\nA triangle is called equilateral if it has all sides of equal length.\nA triangle is called isosceles if it has exactly two sides of equal length.\nA triangle is called scalene if all its sides are of different lengths.\n\nReturn a string representing the type of triangle that can be formed or \"none\" if it cannot form a triangle.\n \nExample 1:\n\nInput: nums = [3,3,3]\nOutput: \"equilateral\"\nExplanation: Since all the sides are of equal length, therefore, it will form an equilateral triangle.\n\nExample 2:\n\nInput: nums = [3,4,5]\nOutput: \"scalene\"\nExplanation: \nnums[0] + nums[1] = 3 + 4 = 7, which is greater than nums[2] = 5.\nnums[0] + nums[2] = 3 + 5 = 8, which is greater than nums[1] = 4.\nnums[1] + nums[2] = 4 + 5 = 9, which is greater than nums[0] = 3. \nSince the sum of the two sides is greater than the third side for all three cases, therefore, it can form a triangle.\nAs all the sides are of different lengths, it will form a scalene triangle.\n\n \nConstraints:\n\nnums.length == 3\n1 <= nums[i] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [2, 2, 3]) == \"isosceles\"\n assert candidate(nums = [10, 10, 10]) == \"equilateral\"\n assert candidate(nums = [1, 1, 2]) == \"none\"\n assert candidate(nums = [6, 6, 10]) == \"isosceles\"\n assert candidate(nums = [6, 6, 12]) == \"none\"\n assert candidate(nums = [3, 4, 5]) == \"scalene\"\n assert candidate(nums = [8, 15, 17]) == \"scalene\"\n assert candidate(nums = [1, 2, 3]) == \"none\"\n assert candidate(nums = [5, 7, 10]) == \"scalene\"\n assert candidate(nums = [6, 6, 6]) == \"equilateral\"\n assert candidate(nums = [50, 50, 50]) == \"equilateral\"\n assert candidate(nums = [5, 5, 8]) == \"isosceles\"\n assert candidate(nums = [5, 7, 5]) == \"isosceles\"\n assert candidate(nums = [3, 3, 3]) == \"equilateral\"\n assert candidate(nums = [7, 10, 5]) == \"scalene\"\n assert candidate(nums = [4, 4, 7]) == \"isosceles\"\n assert candidate(nums = [99, 99, 98]) == \"isosceles\"\n assert candidate(nums = [5, 5, 5]) == \"equilateral\"\n assert candidate(nums = [25, 25, 40]) == \"isosceles\"\n assert candidate(nums = [30, 40, 50]) == \"scalene\"\n assert candidate(nums = [12, 16, 20]) == \"scalene\"\n assert candidate(nums = [10, 15, 25]) == \"none\"\n assert candidate(nums = [99, 99, 1]) == \"isosceles\"\n assert candidate(nums = [5, 5, 8]) == \"isosceles\"\n assert candidate(nums = [99, 99, 198]) == \"none\"\n assert candidate(nums = [7, 7, 14]) == \"none\"\n assert candidate(nums = [45, 45, 89]) == \"isosceles\"\n assert candidate(nums = [20, 21, 21]) == \"isosceles\"\n assert candidate(nums = [20, 25, 30]) == \"scalene\"\n assert candidate(nums = [45, 45, 45]) == \"equilateral\"\n assert candidate(nums = [3, 4, 6]) == \"scalene\"\n assert candidate(nums = [50, 60, 60]) == \"isosceles\"\n assert candidate(nums = [50, 50, 80]) == \"isosceles\"\n assert candidate(nums = [99, 99, 99]) == \"equilateral\"\n assert candidate(nums = [3, 5, 5]) == \"isosceles\"\n assert candidate(nums = [13, 14, 15]) == \"scalene\"\n assert candidate(nums = [9, 12, 15]) == \"scalene\"\n assert candidate(nums = [6, 6, 10]) == \"isosceles\"\n assert candidate(nums = [23, 23, 23]) == \"equilateral\"\n assert candidate(nums = [7, 10, 5]) == \"scalene\"\n assert candidate(nums = [5, 5, 5]) == \"equilateral\"\n assert candidate(nums = [9, 9, 9]) == \"equilateral\"\n assert candidate(nums = [100, 100, 1]) == \"isosceles\"\n assert candidate(nums = [6, 6, 11]) == \"isosceles\"\n assert candidate(nums = [45, 45, 45]) == \"equilateral\"\n assert candidate(nums = [9, 4, 6]) == \"scalene\"\n assert candidate(nums = [1, 2, 2]) == \"isosceles\"\n assert candidate(nums = [6, 8, 10]) == \"scalene\"\n assert candidate(nums = [9, 12, 15]) == \"scalene\"\n assert candidate(nums = [99, 1, 1]) == \"none\"\n assert candidate(nums = [45, 45, 90]) == \"none\"\n assert candidate(nums = [40, 40, 41]) == \"isosceles\"\n assert candidate(nums = [50, 51, 100]) == \"scalene\"\n assert candidate(nums = [5, 12, 13]) == \"scalene\"\n assert candidate(nums = [50, 51, 100]) == \"scalene\"\n assert candidate(nums = [2, 2, 4]) == \"none\"\n assert candidate(nums = [5, 12, 13]) == \"scalene\"\n assert candidate(nums = [100, 100, 1]) == \"isosceles\"\n assert candidate(nums = [10, 10, 15]) == \"isosceles\"\n assert candidate(nums = [5, 5, 9]) == \"isosceles\"\n assert candidate(nums = [10, 10, 20]) == \"none\"\n assert candidate(nums = [30, 30, 59]) == \"isosceles\"\n assert candidate(nums = [10, 10, 10]) == \"equilateral\"\n assert candidate(nums = [2, 2, 4]) == \"none\"\n assert candidate(nums = [15, 15, 29]) == \"isosceles\"\n assert candidate(nums = [10, 10, 15]) == \"isosceles\"\n assert candidate(nums = [100, 100, 100]) == \"equilateral\"\n assert candidate(nums = [25, 25, 30]) == \"isosceles\"\n assert candidate(nums = [7, 24, 25]) == \"scalene\"\n assert candidate(nums = [9, 40, 41]) == \"scalene\"\n assert candidate(nums = [17, 17, 34]) == \"none\"\n assert candidate(nums = [33, 44, 55]) == \"scalene\"\n assert candidate(nums = [50, 50, 80]) == \"isosceles\"\n assert candidate(nums = [3, 4, 4]) == \"isosceles\"\n assert candidate(nums = [25, 25, 49]) == \"isosceles\"\n assert candidate(nums = [10, 15, 25]) == \"none\"\n assert candidate(nums = [10, 14, 14]) == \"isosceles\"\n assert candidate(nums = [5, 7, 12]) == \"none\"\n assert candidate(nums = [12, 16, 20]) == \"scalene\"\n assert candidate(nums = [1, 1, 1]) == \"equilateral\"\n assert candidate(nums = [7, 24, 25]) == \"scalene\"\n assert candidate(nums = [51, 51, 100]) == \"isosceles\"\n assert candidate(nums = [6, 8, 10]) == \"scalene\"\n assert candidate(nums = [45, 45, 89]) == \"isosceles\"\n assert candidate(nums = [7, 7, 10]) == \"isosceles\"\n assert candidate(nums = [50, 50, 100]) == \"none\"\n assert candidate(nums = [1, 1, 2]) == \"none\"\n assert candidate(nums = [2, 2, 3]) == \"isosceles\"\n assert candidate(nums = [30, 40, 50]) == \"scalene\"\n assert candidate(nums = [33, 33, 34]) == \"isosceles\"\n assert candidate(nums = [50, 50, 70]) == \"isosceles\"\n assert candidate(nums = [1, 100, 100]) == \"isosceles\"\n assert candidate(nums = [1, 100, 1]) == \"none\"\n assert candidate(nums = [15, 15, 25]) == \"isosceles\"\n assert candidate(nums = [9, 9, 12]) == \"isosceles\"\n assert candidate(nums = [100, 100, 100]) == \"equilateral\"\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().triangleType", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string triangleType(vector& nums) {", "container": "Solution", "callable": "triangleType", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3025, "task_id": "find-the-number-of-ways-to-place-people-i", "difficulty": "Medium", "problem_description": "You are given a 2D array points of size n x 2 representing integer coordinates of some points on a 2D plane, where points[i] = [xi, yi].\nCount the number of pairs of points (A, B), where\n\nA is on the upper left side of B, and\nthere are no other points in the rectangle (or line) they make (including the border).\n\nReturn the count.\n \nExample 1:\n\nInput: points = [[1,1],[2,2],[3,3]]\nOutput: 0\nExplanation:\n\nThere is no way to choose A and B so A is on the upper left side of B.\n\nExample 2:\n\nInput: points = [[6,2],[4,4],[2,6]]\nOutput: 2\nExplanation:\n\n\nThe left one is the pair (points[1], points[0]), where points[1] is on the upper left side of points[0] and the rectangle is empty.\nThe middle one is the pair (points[2], points[1]), same as the left one it is a valid pair.\nThe right one is the pair (points[2], points[0]), where points[2] is on the upper left side of points[0], but points[1] is inside the rectangle so it's not a valid pair.\n\n\nExample 3:\n\nInput: points = [[3,1],[1,3],[1,1]]\nOutput: 2\nExplanation:\n\n\nThe left one is the pair (points[2], points[0]), where points[2] is on the upper left side of points[0] and there are no other points on the line they form. Note that it is a valid state when the two points form a line.\nThe middle one is the pair (points[1], points[2]), it is a valid pair same as the left one.\nThe right one is the pair (points[1], points[0]), it is not a valid pair as points[2] is on the border of the rectangle.\n\n\n \nConstraints:\n\n2 <= n <= 50\npoints[i].length == 2\n0 <= points[i][0], points[i][1] <= 50\nAll points[i] are distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(points = [[3, 1], [1, 3], [1, 1]]) == 2\n assert candidate(points = [[1, 1], [1, 2], [2, 1], [2, 2], [3, 1], [3, 2], [1, 3], [2, 3], [3, 3]]) == 12\n assert candidate(points = [[2, 4], [4, 2], [1, 3], [3, 1], [5, 0], [0, 5]]) == 8\n assert candidate(points = [[50, 50], [49, 49], [48, 48], [47, 47], [46, 46]]) == 0\n assert candidate(points = [[1, 1], [2, 2], [3, 3]]) == 0\n assert candidate(points = [[1, 2], [2, 3], [3, 4], [4, 5]]) == 0\n assert candidate(points = [[5, 5], [4, 4], [3, 3], [2, 2], [1, 1]]) == 0\n assert candidate(points = [[10, 10], [10, 9], [9, 10], [9, 9]]) == 4\n assert candidate(points = [[10, 10], [10, 20], [20, 10], [20, 20]]) == 4\n assert candidate(points = [[0, 0], [50, 50], [25, 25], [25, 50], [50, 25]]) == 4\n assert candidate(points = [[0, 50], [50, 0], [25, 25], [20, 30]]) == 3\n assert candidate(points = [[5, 5], [10, 10], [15, 15], [20, 20], [25, 25], [30, 30]]) == 0\n assert candidate(points = [[6, 2], [4, 4], [2, 6]]) == 2\n assert candidate(points = [[50, 50], [0, 0], [25, 25], [10, 10], [40, 40], [30, 30]]) == 0\n assert candidate(points = [[30, 20], [20, 30], [10, 40], [40, 10], [25, 25]]) == 4\n assert candidate(points = [[0, 0], [50, 50], [25, 25], [30, 30]]) == 0\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == 0\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]]) == 0\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3]]) == 0\n assert candidate(points = [[5, 5], [4, 6], [3, 7], [2, 8], [1, 9]]) == 4\n assert candidate(points = [[1, 5], [2, 4], [3, 3], [4, 2], [5, 1]]) == 4\n assert candidate(points = [[0, 50], [50, 0], [25, 25], [10, 40], [40, 10]]) == 4\n assert candidate(points = [[0, 1], [1, 0], [2, 3], [3, 2]]) == 2\n assert candidate(points = [[10, 5], [3, 7], [2, 8], [5, 3], [9, 4]]) == 4\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]]) == 0\n assert candidate(points = [[1, 2], [2, 1], [3, 4], [4, 3], [5, 6], [6, 5]]) == 3\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40]]) == 0\n assert candidate(points = [[1, 2], [3, 4], [5, 6], [1, 4], [3, 6], [1, 6]]) == 6\n assert candidate(points = [[10, 20], [10, 10], [20, 20], [20, 10], [15, 15], [15, 10], [10, 15]]) == 8\n assert candidate(points = [[50, 50], [49, 49], [48, 48], [47, 47], [46, 46], [45, 45], [44, 44], [43, 43], [42, 42], [41, 41]]) == 0\n assert candidate(points = [[2, 3], [4, 5], [1, 1], [5, 2], [3, 4], [4, 4], [5, 5], [1, 5], [5, 1], [3, 2]]) == 14\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2]]) == 13\n assert candidate(points = [[25, 25], [24, 26], [26, 24], [23, 27], [27, 23], [22, 28], [28, 22], [21, 29], [29, 21], [30, 30]]) == 8\n assert candidate(points = [[20, 20], [18, 18], [16, 16], [14, 14], [12, 12], [10, 10], [8, 8], [6, 6], [4, 4], [2, 2]]) == 0\n assert candidate(points = [[1, 50], [2, 49], [3, 48], [4, 47], [5, 46], [6, 45], [7, 44], [8, 43], [9, 42], [10, 41], [11, 40], [12, 39], [13, 38], [14, 37]]) == 13\n assert candidate(points = [[5, 1], [4, 2], [3, 3], [2, 4], [1, 5], [5, 2], [4, 3], [3, 4], [2, 5]]) == 8\n assert candidate(points = [[1, 2], [2, 1], [3, 4], [4, 3], [1, 3], [3, 1], [2, 4], [4, 2]]) == 10\n assert candidate(points = [[45, 45], [40, 50], [50, 40], [35, 55], [55, 35], [30, 60], [60, 30], [25, 65], [65, 25]]) == 8\n assert candidate(points = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20], [21, 22]]) == 0\n assert candidate(points = [[40, 5], [45, 10], [35, 5], [50, 10], [25, 5], [55, 10], [20, 5], [60, 10], [15, 5], [65, 10], [10, 5], [70, 10], [5, 5], [75, 10], [0, 5], [80, 10]]) == 14\n assert candidate(points = [[1, 1], [50, 50], [25, 25], [10, 10], [40, 40], [30, 30]]) == 0\n assert candidate(points = [[25, 25], [20, 30], [30, 20], [15, 35], [35, 15], [10, 40], [40, 10], [5, 45], [45, 5]]) == 8\n assert candidate(points = [[1, 1], [1, 5], [5, 1], [5, 5], [2, 2], [2, 4], [4, 2], [4, 4], [3, 3], [3, 5]]) == 15\n assert candidate(points = [[1, 49], [2, 48], [3, 47], [4, 46], [5, 45], [6, 44], [7, 43], [8, 42], [9, 41], [10, 40], [11, 39], [12, 38], [13, 37], [14, 36], [15, 35], [16, 34], [17, 33], [18, 32], [19, 31], [20, 30], [21, 29], [22, 28], [23, 27], [24, 26], [25, 25], [26, 24], [27, 23], [28, 22], [29, 21], [30, 20], [31, 19], [32, 18], [33, 17], [34, 16], [35, 15], [36, 14], [37, 13], [38, 12], [39, 11], [40, 10], [41, 9], [42, 8], [43, 7], [44, 6], [45, 5], [46, 4], [47, 3], [48, 2], [49, 1]]) == 48\n assert candidate(points = [[5, 5], [5, 4], [5, 3], [5, 2], [5, 1], [4, 5], [3, 5], [2, 5], [1, 5], [4, 4]]) == 10\n assert candidate(points = [[5, 5], [10, 5], [15, 5], [20, 5], [25, 5], [30, 5], [35, 5], [40, 5], [45, 5], [50, 5], [5, 10], [10, 10], [15, 10], [20, 10], [25, 10], [30, 10], [35, 10], [40, 10], [45, 10], [50, 10]]) == 28\n assert candidate(points = [[5, 5], [3, 3], [4, 4], [2, 2], [1, 1], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 0\n assert candidate(points = [[10, 40], [20, 30], [30, 20], [40, 10], [10, 10], [20, 20], [30, 30], [40, 40]]) == 10\n assert candidate(points = [[1, 1], [2, 3], [3, 2], [4, 4], [5, 5], [6, 7], [7, 6], [8, 8], [9, 9], [10, 10], [1, 10], [10, 1], [5, 1], [5, 10], [1, 5], [10, 5]]) == 24\n assert candidate(points = [[10, 1], [9, 2], [8, 3], [7, 4], [6, 5], [5, 6], [4, 7], [3, 8], [2, 9], [1, 10]]) == 9\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5]]) == 22\n assert candidate(points = [[1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1], [10, 0]]) == 9\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [1, 3], [2, 3], [3, 3], [4, 3], [5, 3]]) == 22\n assert candidate(points = [[1, 1], [1, 2], [2, 1], [2, 2], [3, 3], [3, 4], [4, 3], [4, 4]]) == 8\n assert candidate(points = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]]) == 0\n assert candidate(points = [[5, 10], [10, 5], [3, 8], [8, 3], [2, 2], [7, 7], [4, 6], [6, 4]]) == 9\n assert candidate(points = [[2, 3], [4, 1], [5, 7], [3, 6], [7, 2], [6, 4], [8, 8], [1, 5], [5, 1], [7, 6]]) == 13\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 5], [3, 5], [4, 5], [5, 5]]) == 8\n assert candidate(points = [[30, 10], [10, 30], [20, 20], [15, 15], [25, 25], [5, 5], [35, 35], [40, 40], [5, 40], [40, 5]]) == 14\n assert candidate(points = [[5, 5], [10, 10], [15, 15], [20, 20], [25, 25], [30, 30], [35, 35], [40, 40], [45, 45], [50, 50], [2, 2], [4, 4], [6, 6], [8, 8], [12, 12], [14, 14], [16, 16], [18, 18], [22, 22], [24, 24], [26, 26], [28, 28], [32, 32], [34, 34], [36, 36], [38, 38], [42, 42], [44, 44], [46, 46], [48, 48]]) == 0\n assert candidate(points = [[1, 5], [3, 4], [2, 3], [5, 2], [4, 1], [6, 0]]) == 8\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [10, 20], [20, 30], [30, 40], [40, 50], [50, 10]]) == 13\n assert candidate(points = [[1, 49], [2, 48], [3, 47], [4, 46], [5, 45], [6, 44], [7, 43], [8, 42], [9, 41], [10, 40], [11, 39], [12, 38], [13, 37], [14, 36]]) == 13\n assert candidate(points = [[5, 1], [4, 2], [3, 3], [2, 4], [1, 5], [0, 6], [1, 1], [2, 2], [3, 1], [4, 0]]) == 14\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [9, 1], [8, 2], [7, 3], [6, 4], [5, 5], [4, 6], [3, 7], [2, 8], [1, 9]]) == 25\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [10, 2], [10, 3], [10, 4], [10, 5]]) == 13\n assert candidate(points = [[5, 5], [4, 4], [3, 3], [2, 2], [1, 1], [5, 4], [4, 3], [3, 2], [2, 1]]) == 8\n assert candidate(points = [[1, 5], [2, 5], [1, 4], [2, 4], [1, 3], [2, 3], [1, 2], [2, 2], [1, 1], [2, 1]]) == 13\n assert candidate(points = [[1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1]]) == 8\n assert candidate(points = [[50, 50], [49, 49], [48, 48], [47, 47], [46, 46], [45, 45], [44, 44], [43, 43], [42, 42], [41, 41], [40, 40], [39, 39], [38, 38], [37, 37], [36, 36], [35, 35], [34, 34], [33, 33], [32, 32], [31, 31], [30, 30], [29, 29], [28, 28], [27, 27], [26, 26], [25, 25], [24, 24], [23, 23], [22, 22], [21, 21], [20, 20], [19, 19], [18, 18], [17, 17], [16, 16], [15, 15], [14, 14], [13, 13], [12, 12], [11, 11], [10, 10], [9, 9], [8, 8], [7, 7], [6, 6], [5, 5], [4, 4], [3, 3], [2, 2], [1, 1]]) == 0\n assert candidate(points = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == 0\n assert candidate(points = [[5, 1], [10, 2], [15, 3], [20, 4], [25, 5], [30, 6], [35, 7], [40, 8], [45, 9], [50, 10], [4, 2], [9, 3], [14, 4], [19, 5], [24, 6], [29, 7], [34, 8], [39, 9], [44, 10], [49, 11]]) == 19\n assert candidate(points = [[5, 5], [4, 4], [3, 3], [2, 2], [1, 1], [0, 0]]) == 0\n assert candidate(points = [[5, 5], [10, 5], [15, 5], [5, 10], [10, 10], [15, 10], [5, 15], [10, 15], [15, 15]]) == 12\n assert candidate(points = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]]) == 9\n assert candidate(points = [[1, 5], [2, 3], [2, 4], [4, 2], [4, 3], [4, 4], [5, 1], [5, 2], [5, 3]]) == 10\n assert candidate(points = [[5, 10], [10, 5], [15, 0], [20, 5], [25, 10], [30, 15], [35, 10], [40, 5], [45, 0]]) == 10\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 0\n assert candidate(points = [[1, 5], [5, 1], [2, 4], [4, 2], [3, 3], [6, 6], [6, 1], [1, 6], [7, 7], [7, 2], [2, 7], [8, 8], [8, 3], [3, 8], [9, 9], [9, 4], [4, 9], [10, 10], [10, 5], [5, 10]]) == 44\n assert candidate(points = [[30, 30], [25, 35], [20, 40], [15, 45], [10, 50], [5, 55], [0, 60]]) == 6\n assert candidate(points = [[50, 50], [25, 25], [0, 0], [25, 50], [50, 25]]) == 4\n assert candidate(points = [[5, 5], [10, 10], [15, 15], [20, 20], [1, 1], [6, 6], [11, 11], [16, 16], [2, 2], [7, 7], [12, 12], [17, 17], [3, 3], [8, 8], [13, 13], [18, 18], [4, 4], [9, 9], [14, 14], [19, 19]]) == 0\n assert candidate(points = [[1, 3], [3, 3], [5, 3], [2, 2], [4, 2], [6, 2], [1, 1], [3, 1], [5, 1]]) == 14\n assert candidate(points = [[30, 30], [25, 25], [20, 20], [15, 15], [10, 10], [5, 5], [0, 0], [35, 35], [40, 40], [45, 45], [50, 50], [2, 2], [7, 7], [12, 12], [17, 17], [22, 22], [27, 27], [32, 32], [37, 37], [42, 42], [47, 47], [3, 3], [8, 8], [13, 13], [18, 18], [23, 23], [28, 28], [33, 33], [38, 38], [43, 43], [48, 48], [4, 4], [9, 9], [14, 14], [19, 19], [24, 24], [29, 29], [34, 34], [39, 39], [44, 44], [49, 49]]) == 0\n assert candidate(points = [[30, 20], [15, 25], [10, 30], [5, 35], [40, 10], [35, 15], [45, 5], [5, 5]]) == 8\n assert candidate(points = [[5, 5], [4, 4], [3, 3], [2, 2], [1, 1], [0, 0], [6, 6], [7, 7], [8, 8], [9, 9]]) == 0\n assert candidate(points = [[1, 1], [5, 5], [2, 4], [3, 3], [4, 2], [1, 5], [5, 1], [2, 3], [3, 2], [4, 4]]) == 12\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 10], [3, 10], [4, 10], [5, 10]]) == 13\n assert candidate(points = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 5], [5, 4], [4, 3], [3, 2], [2, 1]]) == 13\n assert candidate(points = [[1, 2], [2, 1], [1, 3], [3, 1], [2, 3], [3, 2], [1, 4], [4, 1], [2, 4], [4, 2], [3, 3]]) == 15\n assert candidate(points = [[2, 3], [4, 3], [1, 2], [1, 1], [3, 2], [3, 1], [5, 1], [5, 2], [4, 1]]) == 12\n assert candidate(points = [[1, 1], [2, 1], [1, 2], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 4\n assert candidate(points = [[5, 5], [4, 6], [3, 7], [2, 8], [1, 9], [0, 10], [1, 9], [2, 8], [3, 7], [4, 6], [5, 5]]) == 10\n assert candidate(points = [[10, 1], [10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8], [10, 9], [10, 10]]) == 9\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [1, 3], [2, 1], [3, 1], [1, 2], [2, 3], [3, 2], [2, 4]]) == 13\n assert candidate(points = [[5, 5], [3, 3], [1, 1], [2, 2], [4, 4], [6, 6], [7, 7]]) == 0\n assert candidate(points = [[1, 1], [5, 5], [3, 3], [2, 2], [4, 4], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 0\n assert candidate(points = [[2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [1, 1]]) == 0\n assert candidate(points = [[1, 5], [1, 4], [1, 3], [1, 2], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1]]) == 8\n assert candidate(points = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 0\n assert candidate(points = [[1, 50], [2, 49], [3, 48], [4, 47], [5, 46], [6, 45], [7, 44], [8, 43], [9, 42], [10, 41], [40, 40], [39, 39], [38, 38], [37, 37]]) == 13\n assert candidate(points = [[20, 30], [15, 25], [10, 20], [5, 15], [0, 10], [25, 35], [20, 40], [15, 35], [10, 40], [5, 45], [0, 50], [30, 45], [35, 50], [40, 55], [45, 60], [50, 65]]) == 14\n assert candidate(points = [[30, 30], [29, 29], [28, 28], [27, 27], [26, 26], [25, 25], [24, 24], [23, 23], [22, 22], [21, 21], [20, 20]]) == 0\n assert candidate(points = [[3, 1], [1, 3], [1, 1], [4, 4], [2, 2], [5, 5]]) == 4\n assert candidate(points = [[4, 4], [3, 3], [2, 2], [1, 1], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 0\n assert candidate(points = [[10, 10], [10, 9], [9, 10], [9, 9], [8, 8], [8, 7], [7, 8], [7, 7], [6, 6], [6, 5]]) == 9\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [4, 1], [4, 2], [4, 3], [4, 4], [4, 5], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5]]) == 40\n assert candidate(points = [[1, 5], [2, 4], [3, 3], [4, 2], [5, 1], [6, 0], [7, 1], [8, 2], [9, 3], [10, 4]]) == 9\n assert candidate(points = [[1, 49], [3, 48], [5, 47], [7, 46], [9, 45], [11, 44], [13, 43], [15, 42], [17, 41], [19, 40]]) == 9\n assert candidate(points = [[5, 5], [4, 5], [3, 5], [2, 5], [1, 5], [5, 4], [5, 3], [5, 2], [5, 1], [4, 4], [3, 3], [2, 2], [1, 1]]) == 16\n assert candidate(points = [[2, 4], [4, 2], [3, 5], [5, 3], [1, 6], [6, 1], [7, 7], [8, 8], [9, 9], [10, 10]]) == 8\n"}, "metadata": {"canonical_parameter_names": ["points"], "leetcode_dataset_entry_point": "Solution().numberOfPairs", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int numberOfPairs(vector>& points) {", "container": "Solution", "callable": "numberOfPairs", "parameters": [{"name": "points", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3026, "task_id": "maximum-good-subarray-sum", "difficulty": "Medium", "problem_description": "You are given an array nums of length n and a positive integer k.\nA subarray of nums is called good if the absolute difference between its first and last element is exactly k, in other words, the subarray nums[i..j] is good if |nums[i] - nums[j]| == k.\nReturn the maximum sum of a good subarray of nums. If there are no good subarrays, return 0.\n \nExample 1:\n\nInput: nums = [1,2,3,4,5,6], k = 1\nOutput: 11\nExplanation: The absolute difference between the first and last element must be 1 for a good subarray. All the good subarrays are: [1,2], [2,3], [3,4], [4,5], and [5,6]. The maximum subarray sum is 11 for the subarray [5,6].\n\nExample 2:\n\nInput: nums = [-1,3,2,4,5], k = 3\nOutput: 11\nExplanation: The absolute difference between the first and last element must be 3 for a good subarray. All the good subarrays are: [-1,3,2], and [2,4,5]. The maximum subarray sum is 11 for the subarray [2,4,5].\n\nExample 3:\n\nInput: nums = [-1,-2,-3,-4], k = 2\nOutput: -6\nExplanation: The absolute difference between the first and last element must be 2 for a good subarray. All the good subarrays are: [-1,-2,-3], and [-2,-3,-4]. The maximum subarray sum is -6 for the subarray [-1,-2,-3].\n\n \nConstraints:\n\n2 <= nums.length <= 105\n-109 <= nums[i] <= 109\n1 <= k <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1000000000, -1000000000],k = 2000000000) == 0\n assert candidate(nums = [-1, 3, 2, 4, 5],k = 3) == 11\n assert candidate(nums = [10, 20, 30, 40, 50],k = 20) == 120\n assert candidate(nums = [1000000000, 1000000000, 1000000000],k = 0) == 3000000000\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 0) == 10\n assert candidate(nums = [-1000000000, 1000000000, -1000000000, 1000000000],k = 2000000000) == 0\n assert candidate(nums = [1, 3, 5, 7, 9],k = 8) == 25\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 9) == 55\n assert candidate(nums = [10, 20, 30, 40, 50],k = 40) == 150\n assert candidate(nums = [-1, -2, -3, -4],k = 2) == -6\n assert candidate(nums = [1, -1, 1, -1, 1],k = 2) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6],k = 1) == 11\n assert candidate(nums = [1, 3, 1, 5, 4, 1, 3, 5],k = 2) == 22\n assert candidate(nums = [1, 3, 1, 5, 4, 1],k = 4) == 10\n assert candidate(nums = [5, 4, 3, 2, 1],k = 4) == 15\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 9) == 55\n assert candidate(nums = [10, 20, 30, 40, 50],k = 10) == 90\n assert candidate(nums = [5, 5, 5, 5, 5],k = 0) == 25\n assert candidate(nums = [1, 1, 1, 1, 1],k = 0) == 5\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1],k = 0) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 19) == 210\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1, 2, 3, 4, 5],k = 14) == 120\n assert candidate(nums = [1, 3, 1, 5, 1, 7, 1, 9, 1, 11],k = 8) == 39\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5],k = 19) == 210\n assert candidate(nums = [-1, 0, 1, -2, 2, -3, 3, -4, 4, -5, 5],k = 5) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 9) == 55\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100, -10, -20, -30, -40, -50],k = 90) == -110\n assert candidate(nums = [-5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19],k = 9) == -95\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 19) == -35\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1],k = 999) == 1001\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1],k = 5) == 45\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40],k = 20) == 40\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9],k = 18) == 0\n assert candidate(nums = [500000000, 500000000, 500000000, 500000000, 500000000, 500000000, 500000000, 500000000, 500000000, 500000000],k = 0) == 5000000000\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15],k = 1) == -3\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11],k = 1) == 51\n assert candidate(nums = [-1, 0, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, 8, -9, 9],k = 1) == 8\n assert candidate(nums = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, 8, -9, 9],k = 8) == 1\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],k = 90) == -550\n assert candidate(nums = [-5, -10, 0, -15, 5, 10, 20, -5],k = 15) == 35\n assert candidate(nums = [5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5],k = 4) == 15\n assert candidate(nums = [5, 6, 7, 8, 9, 5, 6, 7, 8, 9],k = 3) == 65\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 20],k = 19) == 210\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 18) == 300\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == 190\n assert candidate(nums = [5, 3, 8, 5, 12, 7, 5],k = 7) == 33\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 0) == 0\n assert candidate(nums = [1, 5, 3, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 18) == 300\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 50) == 450\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995],k = 5) == 5999999985\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 0) == 50\n assert candidate(nums = [5, 1, 9, 10, 3, 8, 7, 6, 4, 2],k = 5) == 47\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],k = 5) == 3\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 190) == 2100\n assert candidate(nums = [-1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000],k = 2000) == 0\n assert candidate(nums = [5, 3, 1, 4, 7, 9, 2, 5],k = 4) == 29\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 9) == 110\n assert candidate(nums = [500000000, 500000001, 500000002, 500000003, 500000004, 500000005, 500000000],k = 5) == 3000000015\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5],k = 5) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 14) == 120\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2],k = 2) == 36\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2],k = 1) == 22\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 14) == 120\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],k = 18) == 589\n assert candidate(nums = [5, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 8) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 1) == 39\n assert candidate(nums = [5, -5, 15, -15, 25, -25, 35, -35, 45],k = 10) == 45\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 1) == 49\n assert candidate(nums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 19) == 10\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 50) == 850\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],k = 2) == 10\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400],k = 100) == 400\n assert candidate(nums = [0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10],k = 1) == 45\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 1) == 38\n assert candidate(nums = [2, 4, 2, 6, 2, 8, 2, 10, 2, 12],k = 10) == 50\n assert candidate(nums = [-5, -3, -1, 0, 2, 4, 6, 8, 10, 12],k = 10) == 42\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1],k = 1) == 21\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1],k = 19) == 210\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 19) == 210\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 0) == 20\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40],k = 10) == 40\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 8) == 90\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110],k = 90) == 650\n assert candidate(nums = [1000000000, -1000000000, 1000000000, -1000000000, 1000000000],k = 2000000000) == 0\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 999999999) == 9999999956\n assert candidate(nums = [1000000000, -1000000000, 1000000000, -1000000000, 1000000000],k = 2000000000) == 0\n assert candidate(nums = [5, 1, 3, 5, 7, 9, 3, 5],k = 2) == 33\n assert candidate(nums = [100, 200, 300, 400, 500, 400, 300, 200, 100, 0, -100, -200, -300, -400, -500, -400, -300, -200, -100],k = 200) == 2400\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],k = 6) == 4\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 1) == 29\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, -10, -20, -30, -40],k = 100) == 550\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000],k = 0) == 5000000000\n assert candidate(nums = [1, 3, 1, 5, 1, 7, 1, 9, 1, 11, 1, 13, 1, 15, 1, 17, 1, 19],k = 18) == 108\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 9) == 55\n assert candidate(nums = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5],k = 5) == 15\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2],k = 1) == 27\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15],k = 14) == -120\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 19) == 210\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995],k = 5) == 5999999985\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 9) == 110\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 90) == 550\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],k = 20) == -60\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 1) == 29\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 0) == 11\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],k = 4) == 5\n assert candidate(nums = [5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5],k = 9) == 5\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 38) == 400\n assert candidate(nums = [5, 3, 8, 6, 7, 2, 9, 1, 4, 10],k = 7) == 50\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 9) == 55\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50],k = 90) == 550\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 9) == 55\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 50) == 450\n assert candidate(nums = [1, 5, 2, 5, 3, 5, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 4) == 90\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 900) == 5500\n assert candidate(nums = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5],k = 10) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 400, 300, 200, 100, 500, 400, 300, 200, 100],k = 400) == 3000\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().maximumSubarraySum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "long long maximumSubarraySum(vector& nums, int k) {", "container": "Solution", "callable": "maximumSubarraySum", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "long long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3027, "task_id": "find-the-number-of-ways-to-place-people-ii", "difficulty": "Hard", "problem_description": "You are given a 2D array points of size n x 2 representing integer coordinates of some points on a 2D-plane, where points[i] = [xi, yi].\nWe define the right direction as positive x-axis (increasing x-coordinate) and the left direction as negative x-axis (decreasing x-coordinate). Similarly, we define the up direction as positive y-axis (increasing y-coordinate) and the down direction as negative y-axis (decreasing y-coordinate)\nYou have to place n people, including Alice and Bob, at these points such that there is exactly one person at every point. Alice wants to be alone with Bob, so Alice will build a rectangular fence with Alice's position as the upper left corner and Bob's position as the lower right corner of the fence (Note that the fence might not enclose any area, i.e. it can be a line). If any person other than Alice and Bob is either inside the fence or on the fence, Alice will be sad.\nReturn the number of pairs of points where you can place Alice and Bob, such that Alice does not become sad on building the fence.\nNote that Alice can only build a fence with Alice's position as the upper left corner, and Bob's position as the lower right corner. For example, Alice cannot build either of the fences in the picture below with four corners (1, 1), (1, 3), (3, 1), and (3, 3), because:\n\nWith Alice at (3, 3) and Bob at (1, 1), Alice's position is not the upper left corner and Bob's position is not the lower right corner of the fence.\nWith Alice at (1, 3) and Bob at (1, 1), Bob's position is not the lower right corner of the fence.\n\n\n \nExample 1:\n\n\nInput: points = [[1,1],[2,2],[3,3]]\nOutput: 0\nExplanation: There is no way to place Alice and Bob such that Alice can build a fence with Alice's position as the upper left corner and Bob's position as the lower right corner. Hence we return 0. \n\nExample 2:\n\n\nInput: points = [[6,2],[4,4],[2,6]]\nOutput: 2\nExplanation: There are two ways to place Alice and Bob such that Alice will not be sad:\n- Place Alice at (4, 4) and Bob at (6, 2).\n- Place Alice at (2, 6) and Bob at (4, 4).\nYou cannot place Alice at (2, 6) and Bob at (6, 2) because the person at (4, 4) will be inside the fence.\n\nExample 3:\n\n\nInput: points = [[3,1],[1,3],[1,1]]\nOutput: 2\nExplanation: There are two ways to place Alice and Bob such that Alice will not be sad:\n- Place Alice at (1, 1) and Bob at (3, 1).\n- Place Alice at (1, 3) and Bob at (1, 1).\nYou cannot place Alice at (1, 3) and Bob at (3, 1) because the person at (1, 1) will be on the fence.\nNote that it does not matter if the fence encloses any area, the first and second fences in the image are valid.\n\n \nConstraints:\n\n2 <= n <= 1000\npoints[i].length == 2\n-109 <= points[i][0], points[i][1] <= 109\nAll points[i] are distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(points = [[3, 1], [1, 3], [1, 1]]) == 2\n assert candidate(points = [[1, 1], [2, 2], [3, 1], [1, 3], [2, 1], [1, 2]]) == 6\n assert candidate(points = [[1, 1], [2, 2], [1, 2], [2, 1]]) == 4\n assert candidate(points = [[-1, 5], [0, 0], [2, 4], [4, -2]]) == 4\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5]]) == 4\n assert candidate(points = [[0, 0], [1, 1], [2, 0], [2, 2], [3, 1]]) == 5\n assert candidate(points = [[-1, 1], [1, -1], [-2, 2], [2, -2]]) == 3\n assert candidate(points = [[-1, -1], [-2, -2], [-3, -3], [-4, -4], [-5, -5]]) == 0\n assert candidate(points = [[1, 10], [2, 9], [3, 8], [4, 7]]) == 3\n assert candidate(points = [[1, 1], [2, 2], [3, 3]]) == 0\n assert candidate(points = [[5, 5], [5, 4], [5, 3], [5, 2], [5, 1]]) == 4\n assert candidate(points = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == 0\n assert candidate(points = [[-10, 10], [10, -10], [0, 0], [5, 5], [-5, -5]]) == 6\n assert candidate(points = [[1, 1], [1, 2], [2, 1], [2, 2]]) == 4\n assert candidate(points = [[-1, -1], [-2, -2], [-3, -3]]) == 0\n assert candidate(points = [[-1, 1], [1, -1], [0, 0]]) == 2\n assert candidate(points = [[-1, -1], [0, 0], [1, 1], [2, 2]]) == 0\n assert candidate(points = [[6, 2], [4, 4], [2, 6]]) == 2\n assert candidate(points = [[10, 1], [9, 2], [8, 3], [7, 4]]) == 3\n assert candidate(points = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5]]) == 4\n assert candidate(points = [[0, 0], [1, 1], [2, 0], [2, 2]]) == 3\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3]]) == 0\n assert candidate(points = [[1, 1], [2, 3], [3, 2], [4, 4]]) == 1\n assert candidate(points = [[0, 10], [10, 0], [5, 5], [15, 15]]) == 2\n assert candidate(points = [[-1, 1], [-2, 2], [-3, 3], [-4, 4], [-5, 5]]) == 4\n assert candidate(points = [[1, 5], [2, 3], [3, 2], [4, 1]]) == 3\n assert candidate(points = [[-1, -1], [1, 1], [-2, -2], [2, 2]]) == 0\n assert candidate(points = [[1, 5], [2, 4], [3, 3], [4, 2], [5, 1]]) == 4\n assert candidate(points = [[10, 10], [5, 5], [0, 0], [-5, -5], [-10, -10]]) == 0\n assert candidate(points = [[1, -1], [2, -2], [3, -3], [4, -4], [5, -5]]) == 4\n assert candidate(points = [[10, 10], [20, 20], [15, 15], [5, 5]]) == 0\n assert candidate(points = [[1, 2], [2, 1], [3, 4], [4, 3], [5, 6], [6, 5]]) == 3\n assert candidate(points = [[-1000000000, 1000000000], [1000000000, -1000000000], [0, 0], [1, 1], [2, 2], [3, 3]]) == 8\n assert candidate(points = [[-2, 3], [1, 1], [0, 0], [-1, -1], [2, 2], [3, -3], [4, 4], [-4, -4], [5, 5]]) == 8\n assert candidate(points = [[-1, -1], [-2, -2], [-3, -3], [-1, -3], [-2, -1], [-3, -2]]) == 7\n assert candidate(points = [[5, 5], [5, 6], [5, 7], [6, 5], [6, 6], [6, 7], [7, 5], [7, 6], [7, 7], [8, 5], [8, 6], [8, 7]]) == 17\n assert candidate(points = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 0\n assert candidate(points = [[10, 10], [10, 9], [10, 8], [10, 7], [10, 6], [9, 10], [9, 9], [9, 8], [9, 7], [9, 6], [8, 10], [8, 9], [8, 8], [8, 7], [8, 6], [7, 10], [7, 9], [7, 8], [7, 7], [7, 6], [6, 10], [6, 9], [6, 8], [6, 7], [6, 6]]) == 40\n assert candidate(points = [[0, 0], [100, 100], [50, 50], [75, 25], [25, 75], [125, 125], [25, 25], [75, 75], [100, 50], [50, 100]]) == 12\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2]]) == 13\n assert candidate(points = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]]) == 9\n assert candidate(points = [[-1, 1], [0, 0], [1, -1], [1, 1], [-1, -1]]) == 6\n assert candidate(points = [[5, 1], [1, 5], [3, 3], [4, 2], [2, 4], [6, 0], [0, 6], [7, 1], [1, 7]]) == 8\n assert candidate(points = [[1, 1], [1, 3], [1, 5], [1, 7], [1, 9], [3, 1], [3, 3], [3, 5], [3, 7], [3, 9]]) == 13\n assert candidate(points = [[1000000000, 1000000000], [500000000, 500000000], [0, 0], [-500000000, -500000000], [-1000000000, -1000000000]]) == 0\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [1, 3], [2, 3], [3, 3], [4, 3], [5, 3], [1, 4], [2, 4], [3, 4], [4, 4], [5, 4]]) == 31\n assert candidate(points = [[5, 5], [5, 6], [6, 5], [6, 6], [5, 4], [4, 5], [4, 4], [7, 7], [7, 6], [6, 7]]) == 12\n assert candidate(points = [[-1, -1], [1, 1], [2, 2], [-2, -2], [0, 0]]) == 0\n assert candidate(points = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [1, 0], [1, 1], [1, 2], [1, 3], [1, 4]]) == 13\n assert candidate(points = [[1, 1], [1, 2], [2, 1], [2, 2], [1, 3], [2, 3], [3, 1], [3, 2], [3, 3], [4, 4]]) == 12\n assert candidate(points = [[-1, -1], [-2, -2], [-3, -3], [-1, -2], [-2, -3], [-1, -3], [-3, -1], [-3, -2], [0, 0], [0, -1], [0, -2], [0, -3]]) == 16\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 0\n assert candidate(points = [[1000000000, 1000000000], [1, 1], [500000000, 500000000], [2, 2], [999999999, 999999999]]) == 0\n assert candidate(points = [[10, 10], [10, 9], [10, 8], [9, 9], [8, 8], [9, 8], [8, 9]]) == 8\n assert candidate(points = [[100, 100], [90, 90], [80, 80], [70, 70], [60, 60], [50, 50], [40, 40], [30, 30], [20, 20], [10, 10]]) == 0\n assert candidate(points = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]]) == 9\n assert candidate(points = [[-10, 10], [-9, 9], [-8, 8], [-7, 7], [-6, 6], [-5, 5], [-4, 4], [-3, 3], [-2, 2], [-1, 1]]) == 9\n assert candidate(points = [[1, 5], [2, 3], [3, 2], [4, 1], [5, 4]]) == 4\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3]]) == 12\n assert candidate(points = [[-1, 1], [-1, -1], [1, -1], [1, 1], [0, 0], [0, 1], [0, -1], [1, 0], [-1, 0], [2, 2], [-2, -2], [2, -2], [-2, 2], [3, 3], [-3, -3], [3, -3], [-3, 3]]) == 24\n assert candidate(points = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0], [10, 0], [0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]]) == 31\n assert candidate(points = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1], [1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1], [2, 10], [3, 9], [4, 8], [5, 7], [6, 6], [7, 5], [8, 4], [9, 3], [10, 2], [3, 10], [4, 9], [5, 8], [6, 7], [7, 6], [8, 5], [9, 4], [10, 3], [4, 10], [5, 9], [6, 8], [7, 7], [8, 6], [9, 5], [10, 4], [5, 10], [6, 9], [7, 8], [8, 7], [9, 6], [10, 5], [6, 10], [7, 9], [8, 8], [9, 7], [10, 6], [7, 10], [8, 9], [9, 8], [10, 7], [8, 10], [9, 9], [10, 8], [9, 10], [10, 9], [10, 10]]) == 108\n assert candidate(points = [[0, 0], [1, 0], [2, 0], [0, 1], [1, 1], [2, 1], [0, 2], [1, 2], [2, 2], [3, 0], [3, 1], [3, 2]]) == 17\n assert candidate(points = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [1, 9], [2, 9], [3, 9], [4, 9], [5, 9], [1, 8], [2, 8], [3, 8], [4, 8], [5, 8]]) == 22\n assert candidate(points = [[-5, -5], [-4, -4], [-3, -3], [-2, -2], [-1, -1], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == 0\n assert candidate(points = [[10, 1], [9, 2], [8, 3], [7, 4], [6, 5], [5, 6], [4, 7], [3, 8], [2, 9], [1, 10], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 26\n assert candidate(points = [[10, 1], [9, 2], [8, 3], [7, 4], [6, 5], [5, 6], [4, 7], [3, 8], [2, 9], [1, 10]]) == 9\n assert candidate(points = [[-100, 100], [0, 0], [100, -100], [50, 50], [-50, -50], [75, 25], [25, 75], [25, 25], [75, 75], [-25, -25], [-75, -75]]) == 16\n assert candidate(points = [[5, 5], [6, 4], [7, 3], [8, 2], [9, 1], [10, 0], [9, 0], [8, 0], [7, 0], [6, 0], [5, 0], [4, 1], [3, 2], [2, 3], [1, 4]]) == 22\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [4, 1], [4, 2], [4, 3], [4, 4], [4, 5]]) == 31\n assert candidate(points = [[0, 1], [1, 0], [2, 3], [3, 2], [4, 5], [5, 4], [6, 7], [7, 6], [8, 9], [9, 8]]) == 5\n assert candidate(points = [[5, 5], [5, 4], [5, 3], [5, 2], [5, 1], [4, 5], [3, 5], [2, 5], [1, 5], [5, 0]]) == 9\n assert candidate(points = [[-5, -5], [5, 5], [0, 0], [3, 3], [2, 2], [1, 1]]) == 0\n assert candidate(points = [[1000000000, -1000000000], [-1000000000, 1000000000], [0, 0], [500000000, 500000000], [-500000000, -500000000]]) == 6\n assert candidate(points = [[-1, -1], [-2, -2], [-3, -3], [-4, -4], [-5, -5], [-6, -6], [-7, -7], [-8, -8], [-9, -9]]) == 0\n assert candidate(points = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 0\n assert candidate(points = [[-1, -1], [-2, -2], [-3, -3], [-1, -2], [-2, -1], [-1, -3], [-3, -1]]) == 8\n assert candidate(points = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 2], [2, 3], [3, 2], [3, 3]]) == 8\n assert candidate(points = [[1, 5], [2, 5], [3, 5], [1, 4], [2, 4], [3, 4], [1, 3], [2, 3], [3, 3], [1, 2], [2, 2], [3, 2], [1, 1], [2, 1], [3, 1]]) == 22\n assert candidate(points = [[1, 10], [10, 1], [3, 3], [5, 5], [2, 8], [8, 2]]) == 6\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [1, 4], [2, 1], [2, 2], [2, 3], [2, 4], [3, 1], [3, 2], [3, 3], [3, 4], [4, 1], [4, 2], [4, 3], [4, 4]]) == 24\n assert candidate(points = [[1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1]]) == 8\n assert candidate(points = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [600, 600], [700, 700], [800, 800], [900, 900]]) == 0\n assert candidate(points = [[10, 20], [10, 19], [10, 18], [9, 20], [9, 19], [9, 18], [8, 20], [8, 19], [8, 18], [7, 20], [7, 19], [7, 18]]) == 17\n assert candidate(points = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13]]) == 0\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1]]) == 25\n assert candidate(points = [[-1, 1], [-2, 2], [-3, 3], [-4, 4], [-5, 5], [-6, 6], [-7, 7], [-8, 8], [-9, 9], [-1, 9], [-2, 8], [-3, 7], [-4, 6], [-5, 5], [-6, 4], [-7, 3], [-8, 2], [-9, 1]]) == 25\n assert candidate(points = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 0\n assert candidate(points = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]]) == 9\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]]) == 9\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2]]) == 13\n assert candidate(points = [[1, 1], [2, 2], [2, 1], [3, 3], [3, 2], [3, 1], [4, 4], [4, 3], [4, 2], [4, 1]]) == 12\n assert candidate(points = [[1, 5], [1, 4], [1, 3], [1, 2], [1, 1], [2, 5], [2, 4], [2, 3], [2, 2], [2, 1]]) == 13\n assert candidate(points = [[1000000000, 1000000000], [999999999, 999999999], [999999998, 999999998], [999999997, 999999997], [999999996, 999999996], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == 0\n assert candidate(points = [[-1, -1], [-2, -2], [-3, -3], [-4, -4], [-5, -5], [-6, -6], [-7, -7], [-8, -8], [-9, -9], [-10, -10]]) == 0\n assert candidate(points = [[1, 1], [2, 1], [1, 2], [2, 2], [3, 1], [3, 2], [3, 3], [2, 3], [1, 3], [1, 4], [2, 4], [3, 4]]) == 17\n assert candidate(points = [[1, 5], [5, 1], [3, 3], [2, 4], [4, 2], [1, 3], [3, 1], [2, 3], [3, 2], [4, 1], [5, 2], [2, 5]]) == 14\n assert candidate(points = [[1, 5], [5, 1], [3, 3], [2, 4], [4, 2]]) == 4\n assert candidate(points = [[1, 5], [3, 7], [5, 9], [2, 3], [4, 6], [6, 8]]) == 3\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 0\n assert candidate(points = [[-10, 10], [10, -10], [0, 0], [5, 5], [-5, -5], [7, 3], [3, 7]]) == 8\n assert candidate(points = [[10, 10], [10, 9], [10, 8], [10, 7], [10, 6], [10, 5], [10, 4], [10, 3], [10, 2], [10, 1]]) == 9\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]) == 9\n assert candidate(points = [[1, 2], [2, 1], [1, 3], [3, 1], [2, 3], [3, 2], [1, 4], [4, 1], [2, 4], [4, 2], [3, 3]]) == 15\n assert candidate(points = [[1, 2], [2, 1], [3, 4], [4, 3], [5, 6], [6, 5], [7, 8], [8, 7], [9, 10], [10, 9]]) == 5\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]) == 9\n assert candidate(points = [[1, 10], [3, 9], [5, 8], [7, 7], [9, 6], [11, 5], [13, 4], [15, 3], [17, 2], [19, 1]]) == 9\n assert candidate(points = [[-10, 10], [10, -10], [0, 0], [5, 5], [-5, -5], [3, 3], [-3, -3]]) == 10\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]]) == 0\n assert candidate(points = [[5, 5], [5, 10], [10, 5], [10, 10], [7, 7], [8, 8], [3, 3], [3, 8], [8, 3]]) == 16\n assert candidate(points = [[-5, 5], [0, 0], [5, -5], [10, -10], [5, 0], [0, 5]]) == 5\n assert candidate(points = [[-5, 5], [-4, 4], [-3, 3], [-2, 2], [-1, 1], [1, -1], [2, -2], [3, -3], [4, -4], [5, -5]]) == 9\n assert candidate(points = [[1000000000, 1000000000], [-1000000000, -1000000000], [0, 0], [500000000, 500000000], [-500000000, -500000000]]) == 0\n assert candidate(points = [[-10, -10], [10, 10], [0, 0], [5, 5], [-5, -5], [5, -5], [-5, 5]]) == 6\n assert candidate(points = [[5, 10], [10, 5], [15, 0], [20, 5], [25, 10], [30, 5], [35, 0], [40, 5], [45, 10]]) == 10\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [4, 1], [4, 2], [4, 3], [4, 4], [4, 5], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5]]) == 40\n assert candidate(points = [[-100, -100], [-200, -200], [-300, -300], [-400, -400], [-500, -500], [-600, -600], [-700, -700], [-800, -800], [-900, -900]]) == 0\n assert candidate(points = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [0, 2], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2]]) == 27\n assert candidate(points = [[10, 10], [11, 11], [12, 12], [9, 12], [8, 13], [7, 14], [6, 15], [5, 16], [4, 17], [3, 18], [2, 19], [1, 20]]) == 11\n assert candidate(points = [[5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [6, 5], [6, 6], [6, 7], [6, 8], [6, 9], [7, 5], [7, 6], [7, 7], [7, 8], [7, 9], [8, 5], [8, 6], [8, 7], [8, 8], [8, 9], [9, 5], [9, 6], [9, 7], [9, 8], [9, 9]]) == 40\n"}, "metadata": {"canonical_parameter_names": ["points"], "leetcode_dataset_entry_point": "Solution().numberOfPairs", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int numberOfPairs(vector>& points) {", "container": "Solution", "callable": "numberOfPairs", "parameters": [{"name": "points", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3028, "task_id": "ant-on-the-boundary", "difficulty": "Easy", "problem_description": "An ant is on a boundary. It sometimes goes left and sometimes right.\nYou are given an array of non-zero integers nums. The ant starts reading nums from the first element of it to its end. At each step, it moves according to the value of the current element:\n\nIf nums[i] < 0, it moves left by -nums[i] units.\nIf nums[i] > 0, it moves right by nums[i] units.\n\nReturn the number of times the ant returns to the boundary.\nNotes:\n\nThere is an infinite space on both sides of the boundary.\nWe check whether the ant is on the boundary only after it has moved |nums[i]| units. In other words, if the ant crosses the boundary during its movement, it does not count.\n\n \nExample 1:\n\nInput: nums = [2,3,-5]\nOutput: 1\nExplanation: After the first step, the ant is 2 steps to the right of the boundary.\nAfter the second step, the ant is 5 steps to the right of the boundary.\nAfter the third step, the ant is on the boundary.\nSo the answer is 1.\n\nExample 2:\n\nInput: nums = [3,2,-3,-4]\nOutput: 0\nExplanation: After the first step, the ant is 3 steps to the right of the boundary.\nAfter the second step, the ant is 5 steps to the right of the boundary.\nAfter the third step, the ant is 2 steps to the right of the boundary.\nAfter the fourth step, the ant is 2 steps to the left of the boundary.\nThe ant never returned to the boundary, so the answer is 0.\n\n \nConstraints:\n\n1 <= nums.length <= 100\n-10 <= nums[i] <= 10\nnums[i] != 0\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [-1, 1, -1, 1]) == 2\n assert candidate(nums = [10]) == 0\n assert candidate(nums = [1]) == 0\n assert candidate(nums = [-2, 2, -2, 2]) == 2\n assert candidate(nums = [1, -1, 1, -1]) == 2\n assert candidate(nums = [2, 3, -5]) == 1\n assert candidate(nums = [5, 5, -10]) == 1\n assert candidate(nums = [10, 10, 10, -30]) == 1\n assert candidate(nums = [1, 2, 3, -6]) == 1\n assert candidate(nums = [10, 20, -30, 10]) == 1\n assert candidate(nums = [10, -5, -5]) == 1\n assert candidate(nums = [10, -10, 10, -10]) == 2\n assert candidate(nums = [1, 1, 1, 1, -4]) == 1\n assert candidate(nums = [-5, 5, -5, 5]) == 2\n assert candidate(nums = [-10]) == 0\n assert candidate(nums = [-1, -2, -3, 6]) == 1\n assert candidate(nums = [3, 2, -3, -4]) == 0\n assert candidate(nums = [5, -2, -3, 1, 4, -4]) == 1\n assert candidate(nums = [-5, -5, 10]) == 1\n assert candidate(nums = [7, -3, 2, -4, 1, -1, 3, -3, 2, -2]) == 0\n assert candidate(nums = [5, -2, -3, 1, 4, -4, -6, 6]) == 1\n assert candidate(nums = [-1, -1, -1, -1, -1, 5, -1, -1, -1, -1, -1]) == 1\n assert candidate(nums = [2, -2, 2, -2, 2, -2, 2, -2, 2, -2, 2, -2]) == 6\n assert candidate(nums = [5, -2, 3, -3, 2, -5, 1]) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -20]) == 0\n assert candidate(nums = [1, 2, 3, 4, -10, 1, 2, 3, 4, -10]) == 2\n assert candidate(nums = [-2, -2, -2, 6, -2, -2, -2, 6, -2, -2, -2]) == 2\n assert candidate(nums = [2, -1, 2, -1, 2, -1, 2, -1, 2, -1]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, -15]) == 1\n assert candidate(nums = [5, 5, -10, 1, -1, 1]) == 2\n assert candidate(nums = [5, -2, 3, -6, 4, -1, -6]) == 1\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4]) == 4\n assert candidate(nums = [10, -10, 10, -10, 10, -10]) == 3\n assert candidate(nums = [-3, 3, -3, 3, -3, 3]) == 3\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 1]) == 0\n assert candidate(nums = [1, 1, 1, 1, -4, 1, 1, 1, 1, -4, 1, 1, 1, 1, -4]) == 3\n assert candidate(nums = [7, -3, 2, -6, 1, 1, 1, -1, 1]) == 1\n assert candidate(nums = [5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5]) == 8\n assert candidate(nums = [5, -5, 5, -5, 5, -5, 5, -5, 5, -5]) == 5\n assert candidate(nums = [2, -2, 2, -2, 2, -2, 2, -2, 2, -2, 2, -2, 2, -2, 2, -2, 2, -2, 2, -2, 2, -2]) == 11\n assert candidate(nums = [4, -1, -3, 2, 2, -4]) == 2\n assert candidate(nums = [7, -3, 3, -7, 4, -2, 2, -4]) == 2\n assert candidate(nums = [-7, 3, 4, -1, -2, 2, 1, -4, 6, -2]) == 3\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20]) == 0\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, 9]) == 1\n assert candidate(nums = [-2, 4, -2, -2, 4, -2, -2, 4]) == 2\n assert candidate(nums = [-1, -1, 2, 2, -4, 4, -5, 5, -6, 6]) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, -9]) == 1\n assert candidate(nums = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == 5\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 10\n assert candidate(nums = [5, 5, -10, 5, -5, 5, -5]) == 3\n assert candidate(nums = [-3, -2, 5, -1, 4, -6, 2, 3]) == 1\n assert candidate(nums = [-3, 1, 2, -4, 1, 1, 1, -1]) == 1\n assert candidate(nums = [-10, 5, 5, -5, 5, -5, 5, -5, 5]) == 4\n assert candidate(nums = [-1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6]) == 0\n assert candidate(nums = [1, 2, 3, -3, -2, -1, 4, -4, 5, -5]) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, -5, 1, 1, 1, -4, 1, 1, 1]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, -45]) == 1\n assert candidate(nums = [2, 2, 2, -6, 1, -1, 1, -1, 1]) == 3\n assert candidate(nums = [5, -3, 2, -2, 2, -2, -2, 2]) == 1\n assert candidate(nums = [-2, 2, -2, 2, -2, 2]) == 3\n assert candidate(nums = [10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 1\n assert candidate(nums = [-5, 5, -5, 5, -5, 5, -5]) == 3\n assert candidate(nums = [-10, 5, 5, -3, 3, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 3\n assert candidate(nums = [7, -2, -2, -2, -1, 8, -1, -2, -2, -2]) == 1\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1]) == 3\n assert candidate(nums = [4, -1, 2, -5, 0, 3, -3]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5]) == 1\n assert candidate(nums = [5, -2, -2, -1, 10, -5, 5]) == 1\n assert candidate(nums = [3, -1, -2, 3, -1, -2, 3, -1, -2, 3, -1, -2]) == 4\n assert candidate(nums = [7, -3, -1, -2, 3, -4, 1, 1, 1, -3, 5, -2, -1, 1, -1, -1, -1, -1, -1, 1]) == 3\n assert candidate(nums = [1, -1, 2, -2, 3, -3]) == 3\n assert candidate(nums = [-10, 10, -5, 5, -3, 3, -2, 2]) == 4\n assert candidate(nums = [4, -3, 2, -1, 4, -3, 2, -1]) == 0\n assert candidate(nums = [5, -2, 3, -6, 4, -1, -2, 3]) == 1\n assert candidate(nums = [10, -1, -2, -3, -4, -5, -6, -7, -8, -9, 45]) == 1\n assert candidate(nums = [10, -5, 3, -8, 2, -2, 4, -4, 6, -6, 5, -5]) == 5\n assert candidate(nums = [2, 2, 2, 2, -8, 2, 2, 2, 2, -8]) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -100]) == 0\n assert candidate(nums = [2, 3, -5, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == 9\n assert candidate(nums = [-10, 5, 3, -8, 2, 1, -2, 2, 1, -1]) == 0\n assert candidate(nums = [3, -3, 3, -3, 3, -3, 3, -3, 3, -3]) == 5\n assert candidate(nums = [10, -10, 10, -10, 10, -10, 10, -10, 10, -10, 10, -10, 10, -10, 10, -10, 10, -10, 10, -10]) == 10\n assert candidate(nums = [10, -10, 10, -10, 10, -10, 10, -10]) == 4\n assert candidate(nums = [1, 1, -2, 1, -1, 3, -3, 2, -1, -1]) == 4\n assert candidate(nums = [-1, -2, -3, -4, -5, 15]) == 1\n assert candidate(nums = [2, 3, -5, 4, -4, -3, 3, 2, -2, 1, -1]) == 5\n assert candidate(nums = [-10, 5, 5, -1, 1, -1, 1, 0, 3, -3]) == 5\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10]) == 0\n assert candidate(nums = [10, -10, 5, -5, 3, -3, 2, -2, 1, -1]) == 5\n assert candidate(nums = [-10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10]) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, -5, 5, -5, 5, -5]) == 3\n assert candidate(nums = [7, -3, -4, 1, 2, -2, -1, 4, -6, 2]) == 3\n assert candidate(nums = [2, -2, 3, -3, 4, -4]) == 3\n assert candidate(nums = [5, -2, -2, -1, 1, 5, -5, 2, -2, 2, -2, 2, -2, 2, -2, 2, -2, 2, -2, 2]) == 1\n assert candidate(nums = [5, -2, 3, -6, 1, 2, -3]) == 2\n assert candidate(nums = [7, -3, -2, 1, 2, -1, 2, -2]) == 0\n assert candidate(nums = [10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 1\n assert candidate(nums = [2, -1, -1, 2, -2, 2, -1, 1, -2, 2]) == 3\n assert candidate(nums = [10, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, -15, 5, 5, 5, -15]) == 2\n assert candidate(nums = [4, -1, -3, 2, 1, -3]) == 2\n assert candidate(nums = [-1, -1, -1, -1, 4, -1, -1, -1, -1, 4, -1, -1, -1, -1, 4]) == 3\n assert candidate(nums = [1, 2, 3, 4, -1, -2, -3, -4]) == 1\n assert candidate(nums = [2, -2, 2, -2, 2, -2, 2, -2, 2, -2]) == 5\n assert candidate(nums = [5, -2, -3, 1, 2, -1, 3, -3, 2, -2, 5, -5]) == 1\n assert candidate(nums = [3, -1, -2, -1, 4, -4, 1, 1, 1, -3]) == 2\n assert candidate(nums = [-10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [7, -3, 2, -2, 2, -2, 3, -7]) == 1\n assert candidate(nums = [7, 2, -9, 4, -5, 3, -2, 1]) == 2\n assert candidate(nums = [7, 7, -14, 7, -7, 7, -7]) == 3\n assert candidate(nums = [-1, -2, -3, -4, 5, 5, 6, 6, -7, 7]) == 1\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1]) == 4\n assert candidate(nums = [1, -1, 1, -1, 1, -1]) == 3\n assert candidate(nums = [5, -10, 5, 5, -10, 5]) == 2\n assert candidate(nums = [10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1]) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, -5, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 8\n assert candidate(nums = [3, 3, 3, -9, 3, -3, 3, -3, 3, -3]) == 4\n assert candidate(nums = [-1, 2, -2, 1, -1, 3, -3, 2, -2]) == 1\n assert candidate(nums = [2, 3, -1, -2, 1, -3, 4, -4, 5, -5, 6, -6, 7, -7]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -55]) == 1\n assert candidate(nums = [4, -1, 2, -5, 6, -3, 2, -1, 5, -10]) == 1\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().returnToBoundaryCount", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int returnToBoundaryCount(vector& nums) {", "container": "Solution", "callable": "returnToBoundaryCount", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3029, "task_id": "minimum-time-to-revert-word-to-initial-state-i", "difficulty": "Medium", "problem_description": "You are given a 0-indexed string word and an integer k.\nAt every second, you must perform the following operations:\n\nRemove the first k characters of word.\nAdd any k characters to the end of word.\n\nNote that you do not necessarily need to add the same characters that you removed. However, you must perform both operations at every second.\nReturn the minimum time greater than zero required for word to revert to its initial state.\n \nExample 1:\n\nInput: word = \"abacaba\", k = 3\nOutput: 2\nExplanation: At the 1st second, we remove characters \"aba\" from the prefix of word, and add characters \"bac\" to the end of word. Thus, word becomes equal to \"cababac\".\nAt the 2nd second, we remove characters \"cab\" from the prefix of word, and add \"aba\" to the end of word. Thus, word becomes equal to \"abacaba\" and reverts to its initial state.\nIt can be shown that 2 seconds is the minimum time greater than zero required for word to revert to its initial state.\n\nExample 2:\n\nInput: word = \"abacaba\", k = 4\nOutput: 1\nExplanation: At the 1st second, we remove characters \"abac\" from the prefix of word, and add characters \"caba\" to the end of word. Thus, word becomes equal to \"abacaba\" and reverts to its initial state.\nIt can be shown that 1 second is the minimum time greater than zero required for word to revert to its initial state.\n\nExample 3:\n\nInput: word = \"abcbabcd\", k = 2\nOutput: 4\nExplanation: At every second, we will remove the first 2 characters of word, and add the same characters to the end of word.\nAfter 4 seconds, word becomes equal to \"abcbabcd\" and reverts to its initial state.\nIt can be shown that 4 seconds is the minimum time greater than zero required for word to revert to its initial state.\n\n \nConstraints:\n\n1 <= word.length <= 50 \n1 <= k <= word.length\nword consists only of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word = \"aabbcc\",k = 2) == 3\n assert candidate(word = \"hello\",k = 5) == 1\n assert candidate(word = \"xyzxyzxyz\",k = 4) == 3\n assert candidate(word = \"abcdef\",k = 1) == 6\n assert candidate(word = \"ababab\",k = 2) == 1\n assert candidate(word = \"pattern\",k = 1) == 7\n assert candidate(word = \"abcdefg\",k = 2) == 4\n assert candidate(word = \"abacaba\",k = 3) == 2\n assert candidate(word = \"abacaba\",k = 4) == 1\n assert candidate(word = \"xyzxyz\",k = 2) == 3\n assert candidate(word = \"banana\",k = 3) == 2\n assert candidate(word = \"abcabcabc\",k = 3) == 1\n assert candidate(word = \"hellohello\",k = 5) == 1\n assert candidate(word = \"racecar\",k = 2) == 3\n assert candidate(word = \"abcd\",k = 1) == 4\n assert candidate(word = \"aaaa\",k = 1) == 1\n assert candidate(word = \"aaaa\",k = 2) == 1\n assert candidate(word = \"abcbabcd\",k = 2) == 4\n assert candidate(word = \"abcdef\",k = 6) == 1\n assert candidate(word = \"rotate\",k = 3) == 2\n assert candidate(word = \"abcdefghiabcdefghiabcdefghi\",k = 9) == 1\n assert candidate(word = \"abcabcabcabcabcabcabcabc\",k = 7) == 3\n assert candidate(word = \"abcdefabcdef\",k = 2) == 3\n assert candidate(word = \"mississippi\",k = 2) == 6\n assert candidate(word = \"abcdefghabcdefgh\",k = 5) == 4\n assert candidate(word = \"abacabadabacabadabacabad\",k = 5) == 5\n assert candidate(word = \"abacabadabacabad\",k = 2) == 4\n assert candidate(word = \"abacabacabacabacabacaba\",k = 5) == 4\n assert candidate(word = \"racecar\",k = 1) == 6\n assert candidate(word = \"abcabcabcabcabcabcabcabc\",k = 6) == 1\n assert candidate(word = \"aaaaaa\",k = 1) == 1\n assert candidate(word = \"cascadecascade\",k = 2) == 7\n assert candidate(word = \"aaabbbcccdddaa\",k = 3) == 4\n assert candidate(word = \"zzzzzzzzzzzzzzzz\",k = 3) == 1\n assert candidate(word = \"aaaabbbbcccc\",k = 4) == 3\n assert candidate(word = \"abcabcabcabc\",k = 3) == 1\n assert candidate(word = \"abcdefabcdefabcdefabcdef\",k = 6) == 1\n assert candidate(word = \"qwertyuiopqwertyuiopqwertyuiop\",k = 8) == 4\n assert candidate(word = \"abcabcabcabcabc\",k = 5) == 3\n assert candidate(word = \"abcdefgabcdefg\",k = 3) == 5\n assert candidate(word = \"abcdefgabcdefg\",k = 5) == 3\n assert candidate(word = \"aabbccddeeff\",k = 6) == 2\n assert candidate(word = \"abcdefghabcdefghabcdefgh\",k = 8) == 1\n assert candidate(word = \"aaaaabbbbbccccdddd\",k = 4) == 5\n assert candidate(word = \"abcdefghabcdefgh\",k = 8) == 1\n assert candidate(word = \"abcdeabcdeabcdeabcdeabcdeabcde\",k = 9) == 4\n assert candidate(word = \"xyzxyzxyzxyz\",k = 3) == 1\n assert candidate(word = \"qwertyuiopqwertyuiopqwerty\",k = 11) == 3\n assert candidate(word = \"abcdabcdabcdabcdabcdabcdabcdabcd\",k = 8) == 1\n assert candidate(word = \"mnopqrstmnopqrstmnopqr\",k = 7) == 4\n assert candidate(word = \"hellohellohello\",k = 5) == 1\n assert candidate(word = \"deeddeed\",k = 4) == 1\n assert candidate(word = \"abababababababab\",k = 3) == 2\n assert candidate(word = \"repetitionrepetition\",k = 7) == 3\n assert candidate(word = \"civiccivicciviccivic\",k = 4) == 5\n assert candidate(word = \"aabbccddeeaabbccddee\",k = 5) == 2\n assert candidate(word = \"mnopmnopmnopmnop\",k = 2) == 2\n assert candidate(word = \"abcabcabcabcabcabc\",k = 5) == 3\n assert candidate(word = \"aabbccddeeffgghhiijj\",k = 10) == 2\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzz\",k = 10) == 1\n assert candidate(word = \"qqwweerrttyy\",k = 2) == 6\n assert candidate(word = \"abcdabcdabcdabcd\",k = 4) == 1\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzz\",k = 10) == 1\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 10) == 1\n assert candidate(word = \"abababababababababababab\",k = 9) == 2\n assert candidate(word = \"pneumonoultramicroscopicsilicovolcanoconiosis\",k = 10) == 5\n assert candidate(word = \"abcdefabcdefabcdef\",k = 6) == 1\n assert candidate(word = \"banana\",k = 1) == 6\n assert candidate(word = \"abracadabraabracadabra\",k = 5) == 5\n assert candidate(word = \"repeatedrepeated\",k = 8) == 1\n assert candidate(word = \"repeatedstringrepeatedstring\",k = 9) == 4\n assert candidate(word = \"abcdefgabcdefgabcdefg\",k = 6) == 4\n assert candidate(word = \"banana\",k = 2) == 3\n assert candidate(word = \"abcdefabcdef\",k = 3) == 2\n assert candidate(word = \"abababababababababababab\",k = 3) == 2\n assert candidate(word = \"aabbccddeeff\",k = 2) == 6\n assert candidate(word = \"abcabcabcabc\",k = 4) == 3\n assert candidate(word = \"abcdefghijabcdefghijabcdefghij\",k = 10) == 1\n assert candidate(word = \"xyxxyxyxxyxyxy\",k = 3) == 4\n assert candidate(word = \"abcdabcdabcd\",k = 5) == 3\n assert candidate(word = \"aaaabbbbccccddddeeeeffff\",k = 5) == 5\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyz\",k = 1) == 26\n assert candidate(word = \"mississippi\",k = 3) == 4\n assert candidate(word = \"repetitionrepetitionrepetition\",k = 6) == 5\n assert candidate(word = \"aabbccddeeff\",k = 3) == 4\n assert candidate(word = \"abcdabcdabcdabcd\",k = 7) == 3\n assert candidate(word = \"abacabadabacaba\",k = 4) == 2\n assert candidate(word = \"aaaaabbbbbccccc\",k = 5) == 3\n assert candidate(word = \"aaaaaaaaaa\",k = 1) == 1\n assert candidate(word = \"abracadabra\",k = 5) == 2\n assert candidate(word = \"abcdabcdabcd\",k = 3) == 4\n assert candidate(word = \"hellohellohello\",k = 6) == 3\n assert candidate(word = \"aaaaabbbbb\",k = 5) == 2\n assert candidate(word = \"abacabadabacaba\",k = 5) == 3\n assert candidate(word = \"bananaananabayananabanana\",k = 5) == 5\n assert candidate(word = \"palindromemordnilap\",k = 8) == 3\n assert candidate(word = \"abracadabraabracadabra\",k = 7) == 3\n assert candidate(word = \"abcdefghijkabcdefghijk\",k = 7) == 4\n assert candidate(word = \"abcdabcdabcdabcd\",k = 5) == 4\n assert candidate(word = \"mississippi\",k = 4) == 3\n assert candidate(word = \"xyxzyzyzxzyzyzxzyz\",k = 3) == 6\n assert candidate(word = \"aabbccddeeffgghhiijj\",k = 6) == 4\n assert candidate(word = \"xyzxyzxyzxyzxyzxyzxyzxyz\",k = 8) == 3\n assert candidate(word = \"abcabcabcabcabcabc\",k = 4) == 3\n assert candidate(word = \"mnopqrnopqrmon\",k = 6) == 3\n assert candidate(word = \"abcdefghabcdefghabcdefghabcdefgh\",k = 7) == 5\n assert candidate(word = \"abcdabcdabcd\",k = 4) == 1\n assert candidate(word = \"qwertyqwertyqwerty\",k = 6) == 1\n"}, "metadata": {"canonical_parameter_names": ["word", "k"], "leetcode_dataset_entry_point": "Solution().minimumTimeToInitialState", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumTimeToInitialState(string word, int k) {", "container": "Solution", "callable": "minimumTimeToInitialState", "parameters": [{"name": "word", "type": "string"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3030, "task_id": "find-the-grid-of-region-average", "difficulty": "Medium", "problem_description": "You are given m x n grid image which represents a grayscale image, where image[i][j] represents a pixel with intensity in the range [0..255]. You are also given a non-negative integer threshold.\nTwo pixels are adjacent if they share an edge.\nA region is a 3 x 3 subgrid where the absolute difference in intensity between any two adjacent pixels is less than or equal to threshold.\nAll pixels in a region belong to that region, note that a pixel can belong to multiple regions.\nYou need to calculate a m x n grid result, where result[i][j] is the average intensity of the regions to which image[i][j] belongs, rounded down to the nearest integer. If image[i][j] belongs to multiple regions, result[i][j] is the average of the rounded-down average intensities of these regions, rounded down to the nearest integer. If image[i][j] does not belong to any region, result[i][j] is equal to image[i][j].\nReturn the grid result.\n \nExample 1:\n\nInput: image = [[5,6,7,10],[8,9,10,10],[11,12,13,10]], threshold = 3\nOutput: [[9,9,9,9],[9,9,9,9],[9,9,9,9]]\nExplanation:\n\nThere are two regions as illustrated above. The average intensity of the first region is 9, while the average intensity of the second region is 9.67 which is rounded down to 9. The average intensity of both of the regions is (9 + 9) / 2 = 9. As all the pixels belong to either region 1, region 2, or both of them, the intensity of every pixel in the result is 9.\nPlease note that the rounded-down values are used when calculating the average of multiple regions, hence the calculation is done using 9 as the average intensity of region 2, not 9.67.\n\nExample 2:\n\nInput: image = [[10,20,30],[15,25,35],[20,30,40],[25,35,45]], threshold = 12\nOutput: [[25,25,25],[27,27,27],[27,27,27],[30,30,30]]\nExplanation:\n\nThere are two regions as illustrated above. The average intensity of the first region is 25, while the average intensity of the second region is 30. The average intensity of both of the regions is (25 + 30) / 2 = 27.5 which is rounded down to 27.\nAll the pixels in row 0 of the image belong to region 1, hence all the pixels in row 0 in the result are 25. Similarly, all the pixels in row 3 in the result are 30. The pixels in rows 1 and 2 of the image belong to region 1 and region 2, hence their assigned value is 27 in the result.\n\nExample 3:\n\nInput: image = [[5,6,7],[8,9,10],[11,12,13]], threshold = 1\nOutput: [[5,6,7],[8,9,10],[11,12,13]]\nExplanation:\nThere is only one 3 x 3 subgrid, while it does not have the condition on difference of adjacent pixels, for example, the difference between image[0][0] and image[1][0] is |5 - 8| = 3 > threshold = 1. None of them belong to any valid regions, so the result should be the same as image.\n\n \nConstraints:\n\n3 <= n, m <= 500\n0 <= image[i][j] <= 255\n0 <= threshold <= 255\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(image = [[5, 6, 7], [8, 9, 10], [11, 12, 13]],threshold = 1) == [[5, 6, 7], [8, 9, 10], [11, 12, 13]]\n assert candidate(image = [[10, 20, 30, 40, 50], [15, 25, 35, 45, 55], [20, 30, 40, 50, 60], [25, 35, 45, 55, 65]],threshold = 15) == [[25, 30, 35, 40, 45], [27, 32, 37, 42, 47], [27, 32, 37, 42, 47], [30, 35, 40, 45, 50]]\n assert candidate(image = [[100, 101, 102], [101, 102, 103], [102, 103, 104]],threshold = 2) == [[102, 102, 102], [102, 102, 102], [102, 102, 102]]\n assert candidate(image = [[0, 0, 0], [0, 0, 0], [0, 0, 0]],threshold = 255) == [[0, 0, 0], [0, 0, 0], [0, 0, 0]]\n assert candidate(image = [[5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5]],threshold = 0) == [[5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5]]\n assert candidate(image = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]],threshold = 2) == [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]\n assert candidate(image = [[255, 255, 255], [255, 255, 255], [255, 255, 255]],threshold = 0) == [[255, 255, 255], [255, 255, 255], [255, 255, 255]]\n assert candidate(image = [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8], [5, 6, 7, 8, 9]],threshold = 1) == [[3, 3, 4, 4, 5], [3, 4, 4, 5, 5], [4, 4, 5, 5, 6], [4, 5, 5, 6, 6], [5, 5, 6, 6, 7]]\n assert candidate(image = [[10, 20, 30], [15, 25, 35], [20, 30, 40], [25, 35, 45]],threshold = 12) == [[25, 25, 25], [27, 27, 27], [27, 27, 27], [30, 30, 30]]\n assert candidate(image = [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8], [5, 6, 7, 8, 9]],threshold = 2) == [[3, 3, 4, 4, 5], [3, 4, 4, 5, 5], [4, 4, 5, 5, 6], [4, 5, 5, 6, 6], [5, 5, 6, 6, 7]]\n assert candidate(image = [[5, 6, 7, 10], [8, 9, 10, 10], [11, 12, 13, 10]],threshold = 3) == [[9, 9, 9, 9], [9, 9, 9, 9], [9, 9, 9, 9]]\n assert candidate(image = [[255, 0, 255, 0, 255], [0, 255, 0, 255, 0], [255, 0, 255, 0, 255], [0, 255, 0, 255, 0], [255, 0, 255, 0, 255]],threshold = 127) == [[255, 0, 255, 0, 255], [0, 255, 0, 255, 0], [255, 0, 255, 0, 255], [0, 255, 0, 255, 0], [255, 0, 255, 0, 255]]\n assert candidate(image = [[255, 254, 253, 252, 251], [254, 253, 252, 251, 250], [253, 252, 251, 250, 249], [252, 251, 250, 249, 248], [251, 250, 249, 248, 247]],threshold = 2) == [[253, 252, 252, 251, 251], [252, 252, 251, 251, 250], [252, 251, 251, 250, 250], [251, 251, 250, 250, 249], [251, 250, 250, 249, 249]]\n assert candidate(image = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],threshold = 0) == [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]\n assert candidate(image = [[255, 0, 255, 0, 255], [0, 255, 0, 255, 0], [255, 0, 255, 0, 255], [0, 255, 0, 255, 0], [255, 0, 255, 0, 255]],threshold = 0) == [[255, 0, 255, 0, 255], [0, 255, 0, 255, 0], [255, 0, 255, 0, 255], [0, 255, 0, 255, 0], [255, 0, 255, 0, 255]]\n assert candidate(image = [[1, 3, 5, 7, 9, 11], [3, 5, 7, 9, 11, 13], [5, 7, 9, 11, 13, 15], [7, 9, 11, 13, 15, 17], [9, 11, 13, 15, 17, 19], [11, 13, 15, 17, 19, 21]],threshold = 2) == [[5, 6, 7, 9, 10, 11], [6, 7, 8, 10, 11, 12], [7, 8, 9, 11, 12, 13], [9, 10, 11, 13, 14, 15], [10, 11, 12, 14, 15, 16], [11, 12, 13, 15, 16, 17]]\n assert candidate(image = [[255, 254, 253, 252, 251], [254, 253, 252, 251, 250], [253, 252, 251, 250, 249], [252, 251, 250, 249, 248], [251, 250, 249, 248, 247]],threshold = 2) == [[253, 252, 252, 251, 251], [252, 252, 251, 251, 250], [252, 251, 251, 250, 250], [251, 251, 250, 250, 249], [251, 250, 250, 249, 249]]\n assert candidate(image = [[10, 20, 10, 20, 10], [20, 10, 20, 10, 20], [10, 20, 10, 20, 10], [20, 10, 20, 10, 20], [10, 20, 10, 20, 10]],threshold = 10) == [[14, 14, 14, 14, 14], [14, 14, 14, 14, 14], [14, 14, 14, 14, 14], [14, 14, 14, 14, 14], [14, 14, 14, 14, 14]]\n assert candidate(image = [[5, 10, 15, 20, 25, 30, 35], [10, 15, 20, 25, 30, 35, 40], [15, 20, 25, 30, 35, 40, 45], [20, 25, 30, 35, 40, 45, 50], [25, 30, 35, 40, 45, 50, 55], [30, 35, 40, 45, 50, 55, 60]],threshold = 20) == [[15, 17, 20, 25, 30, 32, 35], [17, 20, 22, 27, 32, 35, 37], [20, 22, 25, 30, 35, 37, 40], [25, 27, 30, 35, 40, 42, 45], [27, 30, 32, 37, 42, 45, 47], [30, 32, 35, 40, 45, 47, 50]]\n assert candidate(image = [[255, 0, 255, 0, 255], [0, 255, 0, 255, 0], [255, 0, 255, 0, 255], [0, 255, 0, 255, 0], [255, 0, 255, 0, 255]],threshold = 254) == [[255, 0, 255, 0, 255], [0, 255, 0, 255, 0], [255, 0, 255, 0, 255], [0, 255, 0, 255, 0], [255, 0, 255, 0, 255]]\n assert candidate(image = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25], [26, 27, 28, 29, 30]],threshold = 1) == [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25], [26, 27, 28, 29, 30]]\n assert candidate(image = [[10, 20, 30, 40, 50], [10, 20, 30, 40, 50], [10, 20, 30, 40, 50], [10, 20, 30, 40, 50], [10, 20, 30, 40, 50], [10, 20, 30, 40, 50]],threshold = 15) == [[20, 25, 30, 35, 40], [20, 25, 30, 35, 40], [20, 25, 30, 35, 40], [20, 25, 30, 35, 40], [20, 25, 30, 35, 40], [20, 25, 30, 35, 40]]\n assert candidate(image = [[10, 20, 30, 40], [15, 25, 35, 45], [20, 30, 40, 50], [25, 35, 45, 55]],threshold = 15) == [[25, 30, 30, 35], [27, 32, 32, 37], [27, 32, 32, 37], [30, 35, 35, 40]]\n assert candidate(image = [[50, 50, 50, 50, 50, 50, 50], [50, 60, 60, 60, 60, 60, 50], [50, 60, 70, 70, 70, 60, 50], [50, 60, 70, 80, 70, 60, 50], [50, 60, 70, 70, 70, 60, 50], [50, 60, 60, 60, 60, 60, 50], [50, 50, 50, 50, 50, 50, 50]],threshold = 10) == [[55, 56, 57, 58, 57, 56, 55], [56, 59, 60, 62, 60, 59, 56], [57, 60, 62, 64, 62, 60, 57], [58, 62, 64, 66, 64, 62, 58], [57, 60, 62, 64, 62, 60, 57], [56, 59, 60, 62, 60, 59, 56], [55, 56, 57, 58, 57, 56, 55]]\n assert candidate(image = [[10, 20, 30, 40, 50], [15, 25, 35, 45, 55], [20, 30, 40, 50, 60], [25, 35, 45, 55, 65], [30, 40, 50, 60, 70]],threshold = 15) == [[25, 30, 35, 40, 45], [27, 32, 37, 42, 47], [30, 35, 40, 45, 50], [32, 37, 42, 47, 52], [35, 40, 45, 50, 55]]\n assert candidate(image = [[255, 255, 255, 255], [255, 254, 253, 252], [254, 253, 252, 251], [253, 252, 251, 250]],threshold = 1) == [[255, 255, 255, 255], [253, 252, 252, 252], [253, 252, 252, 252], [253, 252, 252, 252]]\n assert candidate(image = [[1, 5, 9, 13, 17], [2, 6, 10, 14, 18], [3, 7, 11, 15, 19], [4, 8, 12, 16, 20]],threshold = 4) == [[6, 8, 10, 12, 14], [6, 8, 10, 12, 14], [6, 8, 10, 12, 14], [7, 9, 11, 13, 15]]\n assert candidate(image = [[1, 255, 1, 255, 1], [255, 1, 255, 1, 255], [1, 255, 1, 255, 1], [255, 1, 255, 1, 255], [1, 255, 1, 255, 1]],threshold = 128) == [[1, 255, 1, 255, 1], [255, 1, 255, 1, 255], [1, 255, 1, 255, 1], [255, 1, 255, 1, 255], [1, 255, 1, 255, 1]]\n assert candidate(image = [[50, 51, 52, 53, 54, 55], [51, 52, 53, 54, 55, 56], [52, 53, 54, 55, 56, 57], [53, 54, 55, 56, 57, 58], [54, 55, 56, 57, 58, 59], [55, 56, 57, 58, 59, 60]],threshold = 2) == [[52, 52, 53, 54, 54, 55], [52, 53, 53, 54, 55, 55], [53, 53, 54, 55, 55, 56], [54, 54, 55, 56, 56, 57], [54, 55, 55, 56, 57, 57], [55, 55, 56, 57, 57, 58]]\n assert candidate(image = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],threshold = 1) == [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]\n assert candidate(image = [[50, 50, 50, 50, 50, 50], [50, 55, 55, 55, 55, 50], [50, 55, 60, 60, 55, 50], [50, 55, 60, 65, 55, 50], [50, 55, 60, 60, 55, 50], [50, 55, 55, 55, 55, 50], [50, 50, 50, 50, 50, 50]],threshold = 5) == [[52, 53, 53, 53, 53, 52], [53, 54, 54, 54, 53, 52], [53, 55, 54, 55, 53, 52], [54, 55, 55, 57, 55, 50], [53, 55, 54, 55, 53, 52], [53, 54, 54, 54, 53, 52], [52, 53, 53, 53, 53, 52]]\n assert candidate(image = [[10, 11, 12, 13, 14], [15, 16, 17, 18, 19], [20, 21, 22, 23, 24], [25, 26, 27, 28, 29], [30, 31, 32, 33, 34]],threshold = 1) == [[10, 11, 12, 13, 14], [15, 16, 17, 18, 19], [20, 21, 22, 23, 24], [25, 26, 27, 28, 29], [30, 31, 32, 33, 34]]\n assert candidate(image = [[255, 0, 255, 0, 255, 0], [0, 255, 0, 255, 0, 255], [255, 0, 255, 0, 255, 0], [0, 255, 0, 255, 0, 255], [255, 0, 255, 0, 255, 0], [0, 255, 0, 255, 0, 255]],threshold = 0) == [[255, 0, 255, 0, 255, 0], [0, 255, 0, 255, 0, 255], [255, 0, 255, 0, 255, 0], [0, 255, 0, 255, 0, 255], [255, 0, 255, 0, 255, 0], [0, 255, 0, 255, 0, 255]]\n assert candidate(image = [[10, 15, 20, 25, 30], [15, 20, 25, 30, 35], [20, 25, 30, 35, 40], [25, 30, 35, 40, 45], [30, 35, 40, 45, 50]],threshold = 5) == [[20, 22, 25, 27, 30], [22, 25, 27, 30, 32], [25, 27, 30, 32, 35], [27, 30, 32, 35, 37], [30, 32, 35, 37, 40]]\n assert candidate(image = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [2, 3, 4, 5, 6, 7, 8, 9, 10], [3, 4, 5, 6, 7, 8, 9, 10, 11], [4, 5, 6, 7, 8, 9, 10, 11, 12], [5, 6, 7, 8, 9, 10, 11, 12, 13], [6, 7, 8, 9, 10, 11, 12, 13, 14], [7, 8, 9, 10, 11, 12, 13, 14, 15]],threshold = 1) == [[3, 3, 4, 5, 6, 7, 8, 8, 9], [3, 4, 4, 5, 6, 7, 8, 9, 9], [4, 4, 5, 6, 7, 8, 9, 9, 10], [5, 5, 6, 7, 8, 9, 10, 10, 11], [6, 6, 7, 8, 9, 10, 11, 11, 12], [6, 7, 7, 8, 9, 10, 11, 12, 12], [7, 7, 8, 9, 10, 11, 12, 12, 13]]\n assert candidate(image = [[0, 10, 20, 30, 40, 50], [10, 20, 30, 40, 50, 60], [20, 30, 40, 50, 60, 70], [30, 40, 50, 60, 70, 80], [40, 50, 60, 70, 80, 90], [50, 60, 70, 80, 90, 100]],threshold = 15) == [[20, 25, 30, 40, 45, 50], [25, 30, 35, 45, 50, 55], [30, 35, 40, 50, 55, 60], [40, 45, 50, 60, 65, 70], [45, 50, 55, 65, 70, 75], [50, 55, 60, 70, 75, 80]]\n assert candidate(image = [[5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5]],threshold = 10) == [[5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5]]\n assert candidate(image = [[50, 51, 52, 53, 54, 55, 56], [51, 52, 53, 54, 55, 56, 57], [52, 53, 54, 55, 56, 57, 58], [53, 54, 55, 56, 57, 58, 59], [54, 55, 56, 57, 58, 59, 60]],threshold = 2) == [[52, 52, 53, 54, 55, 55, 56], [52, 53, 53, 54, 55, 56, 56], [53, 53, 54, 55, 56, 56, 57], [53, 54, 54, 55, 56, 57, 57], [54, 54, 55, 56, 57, 57, 58]]\n assert candidate(image = [[50, 51, 52, 53, 54], [51, 52, 53, 54, 55], [52, 53, 54, 55, 56], [53, 54, 55, 56, 57], [54, 55, 56, 57, 58]],threshold = 3) == [[52, 52, 53, 53, 54], [52, 53, 53, 54, 54], [53, 53, 54, 54, 55], [53, 54, 54, 55, 55], [54, 54, 55, 55, 56]]\n assert candidate(image = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [2, 3, 4, 5, 6, 7, 8, 9, 10], [3, 4, 5, 6, 7, 8, 9, 10, 11], [4, 5, 6, 7, 8, 9, 10, 11, 12]],threshold = 1) == [[3, 3, 4, 5, 6, 7, 8, 8, 9], [3, 4, 4, 5, 6, 7, 8, 9, 9], [3, 4, 4, 5, 6, 7, 8, 9, 9], [4, 4, 5, 6, 7, 8, 9, 9, 10]]\n assert candidate(image = [[10, 20, 30, 40, 50, 60, 70], [20, 30, 40, 50, 60, 70, 80], [30, 40, 50, 60, 70, 80, 90], [40, 50, 60, 70, 80, 90, 100], [50, 60, 70, 80, 90, 100, 110], [60, 70, 80, 90, 100, 110, 120]],threshold = 10) == [[30, 35, 40, 50, 60, 65, 70], [35, 40, 45, 55, 65, 70, 75], [40, 45, 50, 60, 70, 75, 80], [50, 55, 60, 70, 80, 85, 90], [55, 60, 65, 75, 85, 90, 95], [60, 65, 70, 80, 90, 95, 100]]\n assert candidate(image = [[10, 15, 20, 25, 30], [12, 17, 22, 27, 32], [14, 19, 24, 29, 34], [16, 21, 26, 31, 36], [18, 23, 28, 33, 38]],threshold = 5) == [[17, 19, 22, 24, 27], [18, 20, 23, 25, 28], [19, 21, 24, 26, 29], [20, 22, 25, 27, 30], [21, 23, 26, 28, 31]]\n assert candidate(image = [[10, 10, 10, 10, 10, 10, 10, 10, 10, 10], [10, 10, 10, 10, 10, 10, 10, 10, 10, 10], [10, 10, 10, 10, 10, 10, 10, 10, 10, 10], [10, 10, 10, 10, 10, 10, 10, 10, 10, 10], [10, 10, 10, 10, 10, 10, 10, 10, 10, 10], [10, 10, 10, 10, 10, 10, 10, 10, 10, 10], [10, 10, 10, 10, 10, 10, 10, 10, 10, 10], [10, 10, 10, 10, 10, 10, 10, 10, 10, 10], [10, 10, 10, 10, 10, 10, 10, 10, 10, 10], [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]],threshold = 100) == [[10, 10, 10, 10, 10, 10, 10, 10, 10, 10], [10, 10, 10, 10, 10, 10, 10, 10, 10, 10], [10, 10, 10, 10, 10, 10, 10, 10, 10, 10], [10, 10, 10, 10, 10, 10, 10, 10, 10, 10], [10, 10, 10, 10, 10, 10, 10, 10, 10, 10], [10, 10, 10, 10, 10, 10, 10, 10, 10, 10], [10, 10, 10, 10, 10, 10, 10, 10, 10, 10], [10, 10, 10, 10, 10, 10, 10, 10, 10, 10], [10, 10, 10, 10, 10, 10, 10, 10, 10, 10], [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]]\n assert candidate(image = [[20, 20, 20, 20, 20, 20, 20, 20, 20], [20, 20, 20, 20, 20, 20, 20, 20, 20], [20, 20, 20, 20, 20, 20, 20, 20, 20], [20, 20, 20, 20, 20, 20, 20, 20, 20], [20, 20, 20, 20, 20, 20, 20, 20, 20], [20, 20, 20, 20, 20, 20, 20, 20, 20], [20, 20, 20, 20, 20, 20, 20, 20, 20], [20, 20, 20, 20, 20, 20, 20, 20, 20], [20, 20, 20, 20, 20, 20, 20, 20, 20]],threshold = 0) == [[20, 20, 20, 20, 20, 20, 20, 20, 20], [20, 20, 20, 20, 20, 20, 20, 20, 20], [20, 20, 20, 20, 20, 20, 20, 20, 20], [20, 20, 20, 20, 20, 20, 20, 20, 20], [20, 20, 20, 20, 20, 20, 20, 20, 20], [20, 20, 20, 20, 20, 20, 20, 20, 20], [20, 20, 20, 20, 20, 20, 20, 20, 20], [20, 20, 20, 20, 20, 20, 20, 20, 20], [20, 20, 20, 20, 20, 20, 20, 20, 20]]\n assert candidate(image = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7]],threshold = 1) == [[3, 3, 3], [3, 3, 3], [4, 4, 4], [4, 4, 4], [5, 5, 5]]\n assert candidate(image = [[10, 10, 10, 10, 10], [10, 20, 20, 20, 10], [10, 20, 30, 20, 10], [10, 20, 20, 20, 10], [10, 10, 10, 10, 10]],threshold = 10) == [[15, 16, 15, 16, 15], [16, 17, 17, 17, 16], [15, 17, 16, 17, 15], [16, 17, 17, 17, 16], [15, 16, 15, 16, 15]]\n assert candidate(image = [[5, 15, 25, 35, 45, 55], [10, 20, 30, 40, 50, 60], [15, 25, 35, 45, 55, 65], [20, 30, 40, 50, 60, 70], [25, 35, 45, 55, 65, 75]],threshold = 5) == [[5, 15, 25, 35, 45, 55], [10, 20, 30, 40, 50, 60], [15, 25, 35, 45, 55, 65], [20, 30, 40, 50, 60, 70], [25, 35, 45, 55, 65, 75]]\n assert candidate(image = [[128, 129, 130, 131, 132], [129, 130, 131, 132, 133], [130, 131, 132, 133, 134], [131, 132, 133, 134, 135], [132, 133, 134, 135, 136]],threshold = 3) == [[130, 130, 131, 131, 132], [130, 131, 131, 132, 132], [131, 131, 132, 132, 133], [131, 132, 132, 133, 133], [132, 132, 133, 133, 134]]\n assert candidate(image = [[10, 20, 30, 40], [20, 30, 40, 50], [30, 40, 50, 60], [40, 50, 60, 70]],threshold = 5) == [[10, 20, 30, 40], [20, 30, 40, 50], [30, 40, 50, 60], [40, 50, 60, 70]]\n assert candidate(image = [[50, 55, 60, 65, 70], [55, 60, 65, 70, 75], [60, 65, 70, 75, 80], [65, 70, 75, 80, 85], [70, 75, 80, 85, 90]],threshold = 5) == [[60, 62, 65, 67, 70], [62, 65, 67, 70, 72], [65, 67, 70, 72, 75], [67, 70, 72, 75, 77], [70, 72, 75, 77, 80]]\n assert candidate(image = [[50, 60, 70, 80, 90], [60, 70, 80, 90, 100], [70, 80, 90, 100, 110], [80, 90, 100, 110, 120], [90, 100, 110, 120, 130]],threshold = 10) == [[70, 75, 80, 85, 90], [75, 80, 85, 90, 95], [80, 85, 90, 95, 100], [85, 90, 95, 100, 105], [90, 95, 100, 105, 110]]\n assert candidate(image = [[50, 51, 52, 53, 54, 55], [51, 52, 53, 54, 55, 56], [52, 53, 54, 55, 56, 57], [53, 54, 55, 56, 57, 58], [54, 55, 56, 57, 58, 59], [55, 56, 57, 58, 59, 60]],threshold = 2) == [[52, 52, 53, 54, 54, 55], [52, 53, 53, 54, 55, 55], [53, 53, 54, 55, 55, 56], [54, 54, 55, 56, 56, 57], [54, 55, 55, 56, 57, 57], [55, 55, 56, 57, 57, 58]]\n assert candidate(image = [[50, 50, 50, 100, 100, 100], [50, 50, 50, 100, 100, 100], [50, 50, 50, 100, 100, 100], [100, 100, 100, 150, 150, 150], [100, 100, 100, 150, 150, 150], [100, 100, 100, 150, 150, 150]],threshold = 50) == [[50, 58, 66, 83, 91, 100], [58, 66, 74, 91, 99, 108], [66, 74, 83, 99, 108, 116], [83, 91, 99, 116, 124, 133], [91, 99, 108, 124, 133, 141], [100, 108, 116, 133, 141, 150]]\n assert candidate(image = [[1, 2, 3, 4, 5, 6, 7], [2, 3, 4, 5, 6, 7, 8], [3, 4, 5, 6, 7, 8, 9], [4, 5, 6, 7, 8, 9, 10], [5, 6, 7, 8, 9, 10, 11]],threshold = 1) == [[3, 3, 4, 5, 6, 6, 7], [3, 4, 4, 5, 6, 7, 7], [4, 4, 5, 6, 7, 7, 8], [4, 5, 5, 6, 7, 8, 8], [5, 5, 6, 7, 8, 8, 9]]\n assert candidate(image = [[255, 255, 255, 0, 0, 0], [255, 255, 255, 0, 0, 0], [255, 255, 255, 0, 0, 0], [0, 0, 0, 255, 255, 255], [0, 0, 0, 255, 255, 255], [0, 0, 0, 255, 255, 255]],threshold = 255) == [[255, 212, 170, 85, 42, 0], [212, 184, 155, 99, 70, 42], [170, 155, 141, 113, 99, 85], [85, 99, 113, 141, 155, 170], [42, 70, 99, 155, 184, 212], [0, 42, 85, 170, 212, 255]]\n assert candidate(image = [[10, 20, 30, 40, 50], [15, 25, 35, 45, 55], [20, 30, 40, 50, 60], [25, 35, 45, 55, 65], [30, 40, 50, 60, 70]],threshold = 10) == [[25, 30, 35, 40, 45], [27, 32, 37, 42, 47], [30, 35, 40, 45, 50], [32, 37, 42, 47, 52], [35, 40, 45, 50, 55]]\n assert candidate(image = [[100, 200, 100, 200], [200, 100, 200, 100], [100, 200, 100, 200], [200, 100, 200, 100]],threshold = 50) == [[100, 200, 100, 200], [200, 100, 200, 100], [100, 200, 100, 200], [200, 100, 200, 100]]\n assert candidate(image = [[10, 20, 30], [15, 25, 35], [20, 30, 40], [25, 35, 45], [30, 40, 50], [35, 45, 55]],threshold = 15) == [[25, 25, 25], [27, 27, 27], [30, 30, 30], [35, 35, 35], [37, 37, 37], [40, 40, 40]]\n assert candidate(image = [[255, 254, 253, 252, 251], [254, 253, 252, 251, 250], [253, 252, 251, 250, 249], [252, 251, 250, 249, 248], [251, 250, 249, 248, 247]],threshold = 5) == [[253, 252, 252, 251, 251], [252, 252, 251, 251, 250], [252, 251, 251, 250, 250], [251, 251, 250, 250, 249], [251, 250, 250, 249, 249]]\n assert candidate(image = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [2, 3, 4, 5, 6, 7, 8, 9, 10], [3, 4, 5, 6, 7, 8, 9, 10, 11], [4, 5, 6, 7, 8, 9, 10, 11, 12], [5, 6, 7, 8, 9, 10, 11, 12, 13]],threshold = 2) == [[3, 3, 4, 5, 6, 7, 8, 8, 9], [3, 4, 4, 5, 6, 7, 8, 9, 9], [4, 4, 5, 6, 7, 8, 9, 9, 10], [4, 5, 5, 6, 7, 8, 9, 10, 10], [5, 5, 6, 7, 8, 9, 10, 10, 11]]\n assert candidate(image = [[5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5]],threshold = 0) == [[5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5]]\n assert candidate(image = [[128, 130, 128, 130, 128], [130, 132, 130, 132, 130], [128, 130, 128, 130, 128], [130, 132, 130, 132, 130], [128, 130, 128, 130, 128]],threshold = 2) == [[129, 129, 129, 129, 129], [129, 129, 129, 129, 129], [129, 129, 129, 129, 129], [129, 129, 129, 129, 129], [129, 129, 129, 129, 129]]\n assert candidate(image = [[255, 255, 255, 255, 255], [255, 250, 245, 240, 235], [255, 245, 240, 235, 230], [255, 240, 235, 230, 225], [255, 235, 230, 225, 220]],threshold = 10) == [[250, 250, 250, 255, 255], [250, 245, 241, 237, 235], [250, 241, 238, 235, 232], [255, 237, 235, 235, 232], [255, 235, 232, 232, 230]]\n assert candidate(image = [[200, 201, 202, 203], [201, 202, 203, 204], [202, 203, 204, 205], [203, 204, 205, 206], [204, 205, 206, 207], [205, 206, 207, 208]],threshold = 5) == [[202, 202, 202, 203], [202, 203, 203, 203], [203, 203, 203, 204], [204, 204, 204, 205], [204, 205, 205, 205], [205, 205, 205, 206]]\n assert candidate(image = [[255, 255, 255, 0, 0, 0], [255, 255, 255, 0, 0, 0], [255, 255, 255, 0, 0, 0], [0, 0, 0, 255, 255, 255], [0, 0, 0, 255, 255, 255], [0, 0, 0, 255, 255, 255]],threshold = 254) == [[255, 255, 255, 0, 0, 0], [255, 255, 255, 0, 0, 0], [255, 255, 255, 0, 0, 0], [0, 0, 0, 255, 255, 255], [0, 0, 0, 255, 255, 255], [0, 0, 0, 255, 255, 255]]\n assert candidate(image = [[100, 100, 100, 100, 100], [100, 200, 200, 200, 100], [100, 200, 255, 200, 100], [100, 200, 200, 200, 100], [100, 100, 100, 100, 100]],threshold = 100) == [[150, 161, 157, 161, 150], [161, 175, 170, 175, 161], [157, 170, 166, 170, 157], [161, 175, 170, 175, 161], [150, 161, 157, 161, 150]]\n assert candidate(image = [[0, 127, 255, 127, 0], [127, 255, 127, 0, 127], [255, 127, 0, 127, 255], [127, 0, 127, 255, 127], [0, 127, 255, 127, 0]],threshold = 127) == [[0, 127, 255, 127, 0], [127, 255, 127, 0, 127], [255, 127, 0, 127, 255], [127, 0, 127, 255, 127], [0, 127, 255, 127, 0]]\n assert candidate(image = [[128, 128, 128, 128, 128], [128, 128, 128, 128, 128], [128, 128, 128, 128, 128], [128, 128, 128, 128, 128], [128, 128, 128, 128, 128]],threshold = 0) == [[128, 128, 128, 128, 128], [128, 128, 128, 128, 128], [128, 128, 128, 128, 128], [128, 128, 128, 128, 128], [128, 128, 128, 128, 128]]\n assert candidate(image = [[10, 20, 30, 40, 50], [15, 25, 35, 45, 55], [20, 30, 40, 50, 60], [25, 35, 45, 55, 65], [30, 40, 50, 60, 70]],threshold = 25) == [[25, 30, 35, 40, 45], [27, 32, 37, 42, 47], [30, 35, 40, 45, 50], [32, 37, 42, 47, 52], [35, 40, 45, 50, 55]]\n assert candidate(image = [[10, 20, 30, 40, 50], [20, 30, 40, 50, 60], [30, 40, 50, 60, 70], [40, 50, 60, 70, 80], [50, 60, 70, 80, 90]],threshold = 10) == [[30, 35, 40, 45, 50], [35, 40, 45, 50, 55], [40, 45, 50, 55, 60], [45, 50, 55, 60, 65], [50, 55, 60, 65, 70]]\n assert candidate(image = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [2, 3, 4, 5, 6, 7, 8, 9, 10], [3, 4, 5, 6, 7, 8, 9, 10, 11], [4, 5, 6, 7, 8, 9, 10, 11, 12], [5, 6, 7, 8, 9, 10, 11, 12, 13], [6, 7, 8, 9, 10, 11, 12, 13, 14], [7, 8, 9, 10, 11, 12, 13, 14, 15], [8, 9, 10, 11, 12, 13, 14, 15, 16], [9, 10, 11, 12, 13, 14, 15, 16, 17]],threshold = 1) == [[3, 3, 4, 5, 6, 7, 8, 8, 9], [3, 4, 4, 5, 6, 7, 8, 9, 9], [4, 4, 5, 6, 7, 8, 9, 9, 10], [5, 5, 6, 7, 8, 9, 10, 10, 11], [6, 6, 7, 8, 9, 10, 11, 11, 12], [7, 7, 8, 9, 10, 11, 12, 12, 13], [8, 8, 9, 10, 11, 12, 13, 13, 14], [8, 9, 9, 10, 11, 12, 13, 14, 14], [9, 9, 10, 11, 12, 13, 14, 14, 15]]\n assert candidate(image = [[255, 254, 253, 252, 251], [254, 253, 252, 251, 250], [253, 252, 251, 250, 249], [252, 251, 250, 249, 248], [251, 250, 249, 248, 247]],threshold = 1) == [[253, 252, 252, 251, 251], [252, 252, 251, 251, 250], [252, 251, 251, 250, 250], [251, 251, 250, 250, 249], [251, 250, 250, 249, 249]]\n assert candidate(image = [[30, 30, 30, 30, 30, 30, 30], [30, 30, 30, 30, 30, 30, 30], [30, 30, 30, 30, 30, 30, 30], [30, 30, 30, 30, 30, 30, 30], [30, 30, 30, 30, 30, 30, 30]],threshold = 0) == [[30, 30, 30, 30, 30, 30, 30], [30, 30, 30, 30, 30, 30, 30], [30, 30, 30, 30, 30, 30, 30], [30, 30, 30, 30, 30, 30, 30], [30, 30, 30, 30, 30, 30, 30]]\n assert candidate(image = [[255, 255, 255], [255, 0, 255], [255, 255, 255]],threshold = 100) == [[255, 255, 255], [255, 0, 255], [255, 255, 255]]\n assert candidate(image = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]],threshold = 0) == [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]\n assert candidate(image = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [10, 11, 12, 13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24, 25, 26, 27], [28, 29, 30, 31, 32, 33, 34, 35, 36], [37, 38, 39, 40, 41, 42, 43, 44, 45], [46, 47, 48, 49, 50, 51, 52, 53, 54], [55, 56, 57, 58, 59, 60, 61, 62, 63], [64, 65, 66, 67, 68, 69, 70, 71, 72], [73, 74, 75, 76, 77, 78, 79, 80, 81]],threshold = 5) == [[1, 2, 3, 4, 5, 6, 7, 8, 9], [10, 11, 12, 13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24, 25, 26, 27], [28, 29, 30, 31, 32, 33, 34, 35, 36], [37, 38, 39, 40, 41, 42, 43, 44, 45], [46, 47, 48, 49, 50, 51, 52, 53, 54], [55, 56, 57, 58, 59, 60, 61, 62, 63], [64, 65, 66, 67, 68, 69, 70, 71, 72], [73, 74, 75, 76, 77, 78, 79, 80, 81]]\n assert candidate(image = [[100, 100, 100, 100, 100], [100, 100, 100, 100, 100], [100, 100, 100, 100, 100], [100, 100, 100, 100, 100], [100, 100, 100, 100, 100]],threshold = 0) == [[100, 100, 100, 100, 100], [100, 100, 100, 100, 100], [100, 100, 100, 100, 100], [100, 100, 100, 100, 100], [100, 100, 100, 100, 100]]\n assert candidate(image = [[255, 254, 253, 252, 251, 250, 249, 248, 247], [254, 253, 252, 251, 250, 249, 248, 247, 246], [253, 252, 251, 250, 249, 248, 247, 246, 245], [252, 251, 250, 249, 248, 247, 246, 245, 244], [251, 250, 249, 248, 247, 246, 245, 244, 243], [250, 249, 248, 247, 246, 245, 244, 243, 242], [249, 248, 247, 246, 245, 244, 243, 242, 241], [248, 247, 246, 245, 244, 243, 242, 241, 240], [247, 246, 245, 244, 243, 242, 241, 240, 239]],threshold = 2) == [[253, 252, 252, 251, 250, 249, 248, 247, 247], [252, 252, 251, 250, 249, 248, 247, 247, 246], [252, 251, 251, 250, 249, 248, 247, 246, 246], [251, 250, 250, 249, 248, 247, 246, 245, 245], [250, 249, 249, 248, 247, 246, 245, 244, 244], [249, 248, 248, 247, 246, 245, 244, 243, 243], [248, 247, 247, 246, 245, 244, 243, 242, 242], [247, 247, 246, 245, 244, 243, 242, 242, 241], [247, 246, 246, 245, 244, 243, 242, 241, 241]]\n assert candidate(image = [[5, 10, 15, 20, 25], [10, 15, 20, 25, 30], [15, 20, 25, 30, 35], [20, 25, 30, 35, 40], [25, 30, 35, 40, 45]],threshold = 10) == [[15, 17, 20, 22, 25], [17, 20, 22, 25, 27], [20, 22, 25, 27, 30], [22, 25, 27, 30, 32], [25, 27, 30, 32, 35]]\n assert candidate(image = [[10, 10, 10, 10, 10], [10, 10, 10, 10, 10], [10, 10, 10, 10, 10], [10, 10, 10, 10, 10], [10, 10, 10, 10, 10]],threshold = 0) == [[10, 10, 10, 10, 10], [10, 10, 10, 10, 10], [10, 10, 10, 10, 10], [10, 10, 10, 10, 10], [10, 10, 10, 10, 10]]\n assert candidate(image = [[50, 50, 50, 50, 50], [50, 55, 60, 65, 70], [50, 60, 70, 80, 90], [50, 65, 80, 95, 110], [50, 70, 90, 110, 130]],threshold = 10) == [[55, 55, 55, 50, 50], [55, 55, 55, 65, 70], [55, 55, 55, 80, 90], [50, 65, 80, 95, 110], [50, 70, 90, 110, 130]]\n assert candidate(image = [[5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5]],threshold = 1) == [[5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5]]\n assert candidate(image = [[10, 20, 30, 40], [20, 30, 40, 50], [30, 40, 50, 60], [40, 50, 60, 70]],threshold = 10) == [[30, 35, 35, 40], [35, 40, 40, 45], [35, 40, 40, 45], [40, 45, 45, 50]]\n assert candidate(image = [[10, 11, 12, 13, 14, 15], [11, 12, 13, 14, 15, 16], [12, 13, 14, 15, 16, 17], [13, 14, 15, 16, 17, 18], [14, 15, 16, 17, 18, 19], [15, 16, 17, 18, 19, 20]],threshold = 3) == [[12, 12, 13, 14, 14, 15], [12, 13, 13, 14, 15, 15], [13, 13, 14, 15, 15, 16], [14, 14, 15, 16, 16, 17], [14, 15, 15, 16, 17, 17], [15, 15, 16, 17, 17, 18]]\n assert candidate(image = [[200, 205, 210, 215, 220], [205, 210, 215, 220, 225], [210, 215, 220, 225, 230], [215, 220, 225, 230, 235], [220, 225, 230, 235, 240]],threshold = 5) == [[210, 212, 215, 217, 220], [212, 215, 217, 220, 222], [215, 217, 220, 222, 225], [217, 220, 222, 225, 227], [220, 222, 225, 227, 230]]\n assert candidate(image = [[10, 10, 10], [10, 10, 10], [10, 10, 10], [10, 10, 10]],threshold = 0) == [[10, 10, 10], [10, 10, 10], [10, 10, 10], [10, 10, 10]]\n assert candidate(image = [[5, 10, 15, 20, 25, 30], [10, 15, 20, 25, 30, 35], [15, 20, 25, 30, 35, 40], [20, 25, 30, 35, 40, 45], [25, 30, 35, 40, 45, 50], [30, 35, 40, 45, 50, 55]],threshold = 5) == [[15, 17, 20, 25, 27, 30], [17, 20, 22, 27, 30, 32], [20, 22, 25, 30, 32, 35], [25, 27, 30, 35, 37, 40], [27, 30, 32, 37, 40, 42], [30, 32, 35, 40, 42, 45]]\n assert candidate(image = [[5, 10, 15, 20, 25], [10, 15, 20, 25, 30], [15, 20, 25, 30, 35], [20, 25, 30, 35, 40], [25, 30, 35, 40, 45]],threshold = 5) == [[15, 17, 20, 22, 25], [17, 20, 22, 25, 27], [20, 22, 25, 27, 30], [22, 25, 27, 30, 32], [25, 27, 30, 32, 35]]\n assert candidate(image = [[0, 0, 0, 0, 0], [0, 1, 1, 1, 0], [0, 1, 2, 1, 0], [0, 1, 1, 1, 0], [0, 0, 0, 0, 0]],threshold = 1) == [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]\n assert candidate(image = [[1, 2, 3, 4, 5, 6], [2, 3, 4, 5, 6, 7], [3, 4, 5, 6, 7, 8], [4, 5, 6, 7, 8, 9], [5, 6, 7, 8, 9, 10], [6, 7, 8, 9, 10, 11]],threshold = 2) == [[3, 3, 4, 5, 5, 6], [3, 4, 4, 5, 6, 6], [4, 4, 5, 6, 6, 7], [5, 5, 6, 7, 7, 8], [5, 6, 6, 7, 8, 8], [6, 6, 7, 8, 8, 9]]\n"}, "metadata": {"canonical_parameter_names": ["image", "threshold"], "leetcode_dataset_entry_point": "Solution().resultGrid", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector> resultGrid(vector>& image, int threshold) {", "container": "Solution", "callable": "resultGrid", "parameters": [{"name": "image", "type": "vector>&"}, {"name": "threshold", "type": "int"}], "return_type": "vector>", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3031, "task_id": "minimum-time-to-revert-word-to-initial-state-ii", "difficulty": "Hard", "problem_description": "You are given a 0-indexed string word and an integer k.\nAt every second, you must perform the following operations:\n\nRemove the first k characters of word.\nAdd any k characters to the end of word.\n\nNote that you do not necessarily need to add the same characters that you removed. However, you must perform both operations at every second.\nReturn the minimum time greater than zero required for word to revert to its initial state.\n \nExample 1:\n\nInput: word = \"abacaba\", k = 3\nOutput: 2\nExplanation: At the 1st second, we remove characters \"aba\" from the prefix of word, and add characters \"bac\" to the end of word. Thus, word becomes equal to \"cababac\".\nAt the 2nd second, we remove characters \"cab\" from the prefix of word, and add \"aba\" to the end of word. Thus, word becomes equal to \"abacaba\" and reverts to its initial state.\nIt can be shown that 2 seconds is the minimum time greater than zero required for word to revert to its initial state.\n\nExample 2:\n\nInput: word = \"abacaba\", k = 4\nOutput: 1\nExplanation: At the 1st second, we remove characters \"abac\" from the prefix of word, and add characters \"caba\" to the end of word. Thus, word becomes equal to \"abacaba\" and reverts to its initial state.\nIt can be shown that 1 second is the minimum time greater than zero required for word to revert to its initial state.\n\nExample 3:\n\nInput: word = \"abcbabcd\", k = 2\nOutput: 4\nExplanation: At every second, we will remove the first 2 characters of word, and add the same characters to the end of word.\nAfter 4 seconds, word becomes equal to \"abcbabcd\" and reverts to its initial state.\nIt can be shown that 4 seconds is the minimum time greater than zero required for word to revert to its initial state.\n\n \nConstraints:\n\n1 <= word.length <= 106\n1 <= k <= word.length\nword consists only of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word = \"abcdefgh\",k = 2) == 4\n assert candidate(word = \"xyz\",k = 1) == 3\n assert candidate(word = \"zzzzzz\",k = 2) == 1\n assert candidate(word = \"abcdabcd\",k = 4) == 1\n assert candidate(word = \"abacaba\",k = 3) == 2\n assert candidate(word = \"abcabcabc\",k = 1) == 3\n assert candidate(word = \"abcdefg\",k = 7) == 1\n assert candidate(word = \"abacaba\",k = 4) == 1\n assert candidate(word = \"aabbccddeeff\",k = 2) == 6\n assert candidate(word = \"zzzzzzzzzzzz\",k = 5) == 1\n assert candidate(word = \"a\",k = 1) == 1\n assert candidate(word = \"repeatrepeat\",k = 6) == 1\n assert candidate(word = \"abcabcabcabc\",k = 3) == 1\n assert candidate(word = \"abcabcabc\",k = 3) == 1\n assert candidate(word = \"abcdabcd\",k = 2) == 2\n assert candidate(word = \"hellohello\",k = 5) == 1\n assert candidate(word = \"aaaa\",k = 1) == 1\n assert candidate(word = \"abcdabcdabcd\",k = 4) == 1\n assert candidate(word = \"aaaa\",k = 2) == 1\n assert candidate(word = \"abcbabcd\",k = 2) == 4\n assert candidate(word = \"abcdef\",k = 6) == 1\n assert candidate(word = \"aaaaabbbbbccccddddaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 15) == 5\n assert candidate(word = \"abcabcabcabcabcabcabcabc\",k = 7) == 3\n assert candidate(word = \"abcdefgabcdefg\",k = 7) == 1\n assert candidate(word = \"aaaabbbbccccddddeeeeffff\",k = 4) == 6\n assert candidate(word = \"qwertyuiopqwertyuiopqwertyuiopqwerty\",k = 11) == 4\n assert candidate(word = \"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\",k = 10) == 1\n assert candidate(word = \"abacabadabacabadabacabad\",k = 5) == 5\n assert candidate(word = \"abacabadabacabad\",k = 3) == 6\n assert candidate(word = \"abcdeabcdeabcdeabcdeabcde\",k = 6) == 5\n assert candidate(word = \"ababababababababababababababababababababababababab\",k = 3) == 2\n assert candidate(word = \"ababababababab\",k = 4) == 1\n assert candidate(word = \"abcdefgabcdefgabcdefg\",k = 7) == 1\n assert candidate(word = \"samepatterneverywhereeverywhereeverywhere\",k = 11) == 4\n assert candidate(word = \"hellohellohellohellohellohello\",k = 6) == 5\n assert candidate(word = \"abababababababababababababab\",k = 10) == 1\n assert candidate(word = \"abababababababab\",k = 4) == 1\n assert candidate(word = \"aaaaaabaaaaa\",k = 3) == 3\n assert candidate(word = \"abacabadabacabad\",k = 6) == 3\n assert candidate(word = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\",k = 13) == 4\n assert candidate(word = \"zzzzzzzzzzzzzzzzzz\",k = 7) == 1\n assert candidate(word = \"hellohellohellohellohello\",k = 7) == 4\n assert candidate(word = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabad\",k = 9) == 8\n assert candidate(word = \"abcabcabcabcabcabcabcabcabcabc\",k = 10) == 3\n assert candidate(word = \"abcdabcdabcdabcdabcdabcdabcdabcd\",k = 8) == 1\n assert candidate(word = \"xyzxyzxyzxyz\",k = 5) == 3\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",k = 26) == 1\n assert candidate(word = \"hellohellohellohellohello\",k = 5) == 1\n assert candidate(word = \"aaaaaabbbbbbcccccc\",k = 3) == 6\n assert candidate(word = \"aaaaabbbbbcccc\",k = 5) == 3\n assert candidate(word = \"abacabadabacabadabacabadabacabadaba\",k = 7) == 5\n assert candidate(word = \"xyzxyzxyzxyzxyzxyzxyzxyz\",k = 7) == 3\n assert candidate(word = \"abcabcabcabcabcabc\",k = 5) == 3\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzz\",k = 2) == 1\n assert candidate(word = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",k = 2) == 1\n assert candidate(word = \"abababababab\",k = 4) == 1\n assert candidate(word = \"abcdefgabcdefgabcdefgabcdefgabcdefg\",k = 9) == 4\n assert candidate(word = \"ababababababababababab\",k = 5) == 2\n assert candidate(word = \"abcabcabcabcabcabcabcabcabcabcabcabc\",k = 7) == 3\n assert candidate(word = \"qwertyuiopqwertyuiopqwertyuiop\",k = 9) == 4\n assert candidate(word = \"zyxzyxzyxzyxzyxzyxzyxzyx\",k = 6) == 1\n assert candidate(word = \"xyzxyzxyzxyzxyzxyz\",k = 6) == 1\n assert candidate(word = \"abcdefabcdefabcdef\",k = 6) == 1\n assert candidate(word = \"ababababababababababababababababababa\",k = 1) == 2\n assert candidate(word = \"abcdefabcdefabcdefabcdefabcdefabcdef\",k = 3) == 2\n assert candidate(word = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 10) == 6\n assert candidate(word = \"abcabcabcabcabc\",k = 6) == 1\n assert candidate(word = \"abcabcabcabcabcabcabcabcabcabcabcabc\",k = 9) == 1\n assert candidate(word = \"banana\",k = 2) == 3\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",k = 13) == 2\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyz\",k = 13) == 2\n assert candidate(word = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\",k = 12) == 1\n assert candidate(word = \"abcdefgabcdefgabcdefgabcdefg\",k = 5) == 6\n assert candidate(word = \"xyzxyzxyzxyz\",k = 2) == 3\n assert candidate(word = \"zzzzzzzzzzzzzzzzzz\",k = 9) == 1\n assert candidate(word = \"abacabadabacabadabacabadabacabadaba\",k = 8) == 1\n assert candidate(word = \"ababababababababababababababababababa\",k = 6) == 1\n assert candidate(word = \"abacabadabacabadabacabadabacabadabacabadabacabad\",k = 6) == 4\n assert candidate(word = \"aaaaaaa\",k = 2) == 1\n assert candidate(word = \"xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz\",k = 4) == 3\n assert candidate(word = \"aabbaabbaabbaabbaabbaabb\",k = 3) == 4\n assert candidate(word = \"abcdefghijabcdefghijabcdefghij\",k = 10) == 1\n assert candidate(word = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 26) == 2\n assert candidate(word = \"abcdefghijabcdefghijabcdefghijabcdefghij\",k = 10) == 1\n assert candidate(word = \"abacabadabacabadabacabad\",k = 4) == 2\n assert candidate(word = \"xyzxyzxyzxyzxyzxyz\",k = 5) == 3\n assert candidate(word = \"repeatrepeatrepeatrepeatrepeat\",k = 3) == 2\n assert candidate(word = \"abababababab\",k = 1) == 2\n assert candidate(word = \"abcabcabcabcabcabcabcabcabcabcabcabc\",k = 5) == 3\n assert candidate(word = \"abracadabraabracadabraabracadabra\",k = 7) == 5\n assert candidate(word = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\",k = 12) == 1\n assert candidate(word = \"repeatedrepeatedrepeated\",k = 7) == 4\n assert candidate(word = \"abcdabcdabcdabcdabcd\",k = 8) == 1\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyz\",k = 25) == 2\n assert candidate(word = \"abababababababab\",k = 5) == 2\n assert candidate(word = \"aabbccddeeffgghhiijjkkll\",k = 11) == 3\n assert candidate(word = \"mississippimississippimississippi\",k = 4) == 9\n assert candidate(word = \"abacabadabacaba\",k = 3) == 4\n assert candidate(word = \"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\",k = 13) == 6\n assert candidate(word = \"abcdabcdabcdabcd\",k = 5) == 4\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 15) == 1\n assert candidate(word = \"mississippi\",k = 4) == 3\n assert candidate(word = \"abacabadabacabadabacabadabacabadaba\",k = 10) == 4\n assert candidate(word = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\",k = 15) == 4\n assert candidate(word = \"abcabcabcabcabcabcabcabc\",k = 8) == 3\n assert candidate(word = \"abcabcabcabcabcabcabcabc\",k = 9) == 1\n assert candidate(word = \"abababababab\",k = 2) == 1\n assert candidate(word = \"abcabcabcabcabcabcabcabc\",k = 4) == 3\n"}, "metadata": {"canonical_parameter_names": ["word", "k"], "leetcode_dataset_entry_point": "Solution().minimumTimeToInitialState", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumTimeToInitialState(string word, int k) {", "container": "Solution", "callable": "minimumTimeToInitialState", "parameters": [{"name": "word", "type": "string"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3033, "task_id": "modify-the-matrix", "difficulty": "Easy", "problem_description": "Given a 0-indexed m x n integer matrix matrix, create a new 0-indexed matrix called answer. Make answer equal to matrix, then replace each element with the value -1 with the maximum element in its respective column.\nReturn the matrix answer.\n \nExample 1:\n\n\nInput: matrix = [[1,2,-1],[4,-1,6],[7,8,9]]\nOutput: [[1,2,9],[4,8,6],[7,8,9]]\nExplanation: The diagram above shows the elements that are changed (in blue).\n- We replace the value in the cell [1][1] with the maximum value in the column 1, that is 8.\n- We replace the value in the cell [0][2] with the maximum value in the column 2, that is 9.\n\nExample 2:\n\n\nInput: matrix = [[3,-1],[5,2]]\nOutput: [[3,2],[5,2]]\nExplanation: The diagram above shows the elements that are changed (in blue).\n\n \nConstraints:\n\nm == matrix.length\nn == matrix[i].length\n2 <= m, n <= 50\n-1 <= matrix[i][j] <= 100\nThe input is generated such that each column contains at least one non-negative integer.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(matrix = [[3, -1], [5, 2]]) == [[3, 2], [5, 2]]\n assert candidate(matrix = [[1, 2, -1], [4, -1, 6], [7, 8, 9]]) == [[1, 2, 9], [4, 8, 6], [7, 8, 9]]\n assert candidate(matrix = [[-1, -1], [-1, -1], [-1, -1], [2, 2]]) == [[2, 2], [2, 2], [2, 2], [2, 2]]\n assert candidate(matrix = [[10, -1, 10], [-1, -1, -1], [10, 10, 10]]) == [[10, 10, 10], [10, 10, 10], [10, 10, 10]]\n assert candidate(matrix = [[10, 20, -1], [30, -1, 40], [50, 60, 70]]) == [[10, 20, 70], [30, 60, 40], [50, 60, 70]]\n assert candidate(matrix = [[100, -1, -1], [-1, -1, -1], [-1, -1, -1]]) == [[100, -1, -1], [100, -1, -1], [100, -1, -1]]\n assert candidate(matrix = [[-1, 4, 5], [-1, 6, 7], [8, 9, -1]]) == [[8, 4, 5], [8, 6, 7], [8, 9, 7]]\n assert candidate(matrix = [[-1, 0, -1], [2, 3, -1], [4, -1, 5]]) == [[4, 0, 5], [2, 3, 5], [4, 3, 5]]\n assert candidate(matrix = [[5, 6, 7], [8, 9, -1], [-1, -1, -1]]) == [[5, 6, 7], [8, 9, 7], [8, 9, 7]]\n assert candidate(matrix = [[-1, 2, 3], [-4, -5, -6], [7, 8, 9]]) == [[7, 2, 3], [-4, -5, -6], [7, 8, 9]]\n assert candidate(matrix = [[1, 2, 3], [4, 5, 6], [-1, -1, -1]]) == [[1, 2, 3], [4, 5, 6], [4, 5, 6]]\n assert candidate(matrix = [[-1, 2, 3], [-4, -1, 6], [-7, 8, -1]]) == [[-1, 2, 3], [-4, 8, 6], [-7, 8, 6]]\n assert candidate(matrix = [[0, -1, 2], [-1, 1, -1], [3, -1, 4]]) == [[0, 1, 2], [3, 1, 4], [3, 1, 4]]\n assert candidate(matrix = [[-1, 1], [-1, 2], [-1, 3]]) == [[-1, 1], [-1, 2], [-1, 3]]\n assert candidate(matrix = [[0, -1, -1], [-1, -1, 0], [-1, 0, -1]]) == [[0, 0, 0], [0, 0, 0], [0, 0, 0]]\n assert candidate(matrix = [[0, -1, 0], [-1, -1, -1], [0, -1, 0]]) == [[0, -1, 0], [0, -1, 0], [0, -1, 0]]\n assert candidate(matrix = [[1, -1, -1], [2, -1, 3], [-1, 4, -1]]) == [[1, 4, 3], [2, 4, 3], [2, 4, 3]]\n assert candidate(matrix = [[-1, -1, -1], [1, 2, 3], [4, 5, 6]]) == [[4, 5, 6], [1, 2, 3], [4, 5, 6]]\n assert candidate(matrix = [[-1, 1, 2, 3, 4, 5, 6, 7, 8, 9], [10, -1, 2, 3, 4, 5, 6, 7, 8, 9], [10, 11, -1, 3, 4, 5, 6, 7, 8, 9], [10, 11, 12, -1, 4, 5, 6, 7, 8, 9], [10, 11, 12, 13, -1, 5, 6, 7, 8, 9], [10, 11, 12, 13, 14, -1, 6, 7, 8, 9], [10, 11, 12, 13, 14, 15, -1, 7, 8, 9]]) == [[10, 1, 2, 3, 4, 5, 6, 7, 8, 9], [10, 11, 2, 3, 4, 5, 6, 7, 8, 9], [10, 11, 12, 3, 4, 5, 6, 7, 8, 9], [10, 11, 12, 13, 4, 5, 6, 7, 8, 9], [10, 11, 12, 13, 14, 5, 6, 7, 8, 9], [10, 11, 12, 13, 14, 15, 6, 7, 8, 9], [10, 11, 12, 13, 14, 15, 6, 7, 8, 9]]\n assert candidate(matrix = [[-1, -1, -1, -1, -1], [1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [9, 8, 7, 6, 5]]) == [[9, 8, 7, 6, 5], [1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [9, 8, 7, 6, 5]]\n assert candidate(matrix = [[-1, 3, -1, 4], [-1, -1, -1, 8], [7, 6, -1, 9]]) == [[7, 3, -1, 4], [7, 6, -1, 8], [7, 6, -1, 9]]\n assert candidate(matrix = [[-1, 10, -1, -1], [12, -1, 14, -1], [-1, 16, -1, 18], [20, -1, -1, -1]]) == [[20, 10, 14, 18], [12, 16, 14, 18], [20, 16, 14, 18], [20, 16, 14, 18]]\n assert candidate(matrix = [[1, 2, 3, 4], [5, 6, 7, 8], [9, -1, -1, -1]]) == [[1, 2, 3, 4], [5, 6, 7, 8], [9, 6, 7, 8]]\n assert candidate(matrix = [[-1, -1, -1, -1], [-1, -1, -1, -1], [1, 2, 3, 4], [5, 6, 7, 8]]) == [[5, 6, 7, 8], [5, 6, 7, 8], [1, 2, 3, 4], [5, 6, 7, 8]]\n assert candidate(matrix = [[-1, 3, -1, 5, -1, 7, -1, 9], [-1, 11, -1, 13, -1, 15, -1, 17], [19, -1, 21, -1, 23, -1, 25, -1], [27, -1, 29, -1, 31, -1, 33, -1]]) == [[27, 3, 29, 5, 31, 7, 33, 9], [27, 11, 29, 13, 31, 15, 33, 17], [19, 11, 21, 13, 23, 15, 25, 17], [27, 11, 29, 13, 31, 15, 33, 17]]\n assert candidate(matrix = [[-1, 3, -1, 7], [2, -1, 6, -1], [1, 5, -1, 8], [4, -1, -1, 9]]) == [[4, 3, 6, 7], [2, 5, 6, 9], [1, 5, 6, 8], [4, 5, 6, 9]]\n assert candidate(matrix = [[-1, -1, 3, -1], [-1, -1, -1, -1], [1, 2, -1, 4]]) == [[1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]]\n assert candidate(matrix = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]]) == [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]\n assert candidate(matrix = [[-1, -1, 100, -1, -1], [-1, 50, -1, -1, -1], [-1, -1, -1, 90, -1], [20, -1, -1, -1, -1]]) == [[20, 50, 100, 90, -1], [20, 50, 100, 90, -1], [20, 50, 100, 90, -1], [20, 50, 100, 90, -1]]\n assert candidate(matrix = [[-1, 10, 20], [30, 40, -1], [50, -1, 60], [-1, 70, 80]]) == [[50, 10, 20], [30, 40, 80], [50, 70, 60], [50, 70, 80]]\n assert candidate(matrix = [[10, -1, 20, -1, 30], [-1, 40, -1, 50, -1], [60, -1, 70, -1, 80], [-1, 90, -1, 100, -1]]) == [[10, 90, 20, 100, 30], [60, 40, 70, 50, 80], [60, 90, 70, 100, 80], [60, 90, 70, 100, 80]]\n assert candidate(matrix = [[-1, 5, 3, -1, 7], [-1, -1, 6, 8, 2], [0, 9, 1, -1, 4]]) == [[0, 5, 3, 8, 7], [0, 9, 6, 8, 2], [0, 9, 1, 8, 4]]\n assert candidate(matrix = [[-1, 0, 0, 0, 0], [0, -1, 0, 0, 0], [0, 0, -1, 0, 0], [0, 0, 0, -1, 0], [0, 0, 0, 0, -1]]) == [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]\n assert candidate(matrix = [[10, 15, -1], [20, -1, 25], [30, -1, 35]]) == [[10, 15, 35], [20, 15, 25], [30, 15, 35]]\n assert candidate(matrix = [[1, 2, 3, 4, 5], [-1, -1, -1, -1, -1], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]]) == [[1, 2, 3, 4, 5], [16, 17, 18, 19, 20], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]]\n assert candidate(matrix = [[-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1], [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]]) == [[11, 12, 13, 14, 15], [11, 12, 13, 14, 15], [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]]\n assert candidate(matrix = [[0, 1, -1, -1], [10, 11, -1, -1], [-1, -1, 12, 13], [20, 21, 22, 23]]) == [[0, 1, 22, 23], [10, 11, 22, 23], [20, 21, 12, 13], [20, 21, 22, 23]]\n assert candidate(matrix = [[-1, -1, -1, -1, 5], [-1, 0, -1, 0, 5], [-1, 2, -1, 2, 5], [-1, 3, -1, 3, 5]]) == [[-1, 3, -1, 3, 5], [-1, 0, -1, 0, 5], [-1, 2, -1, 2, 5], [-1, 3, -1, 3, 5]]\n assert candidate(matrix = [[1, 2, 3], [4, -1, 6], [7, 8, -1], [-1, -1, 9], [10, 11, 12]]) == [[1, 2, 3], [4, 11, 6], [7, 8, 12], [10, 11, 9], [10, 11, 12]]\n assert candidate(matrix = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [-1, -1, -1, -1, -1]]) == [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [11, 12, 13, 14, 15]]\n assert candidate(matrix = [[10, -1, 20, -1, 30], [20, -1, 30, -1, 40], [30, -1, 40, -1, 50], [40, -1, 50, -1, 60]]) == [[10, -1, 20, -1, 30], [20, -1, 30, -1, 40], [30, -1, 40, -1, 50], [40, -1, 50, -1, 60]]\n assert candidate(matrix = [[-1, 2, -1, 4, -1, 6], [-1, 8, -1, 10, -1, 12], [14, -1, 16, -1, 18, -1], [20, -1, 22, -1, 24, -1]]) == [[20, 2, 22, 4, 24, 6], [20, 8, 22, 10, 24, 12], [14, 8, 16, 10, 18, 12], [20, 8, 22, 10, 24, 12]]\n assert candidate(matrix = [[-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1], [15, 16, 17, 18, 19], [20, 21, 22, 23, 24]]) == [[20, 21, 22, 23, 24], [20, 21, 22, 23, 24], [15, 16, 17, 18, 19], [20, 21, 22, 23, 24]]\n assert candidate(matrix = [[5, 6, 7, -1, -1], [8, 9, 10, -1, -1], [-1, -1, -1, 12, 13], [-1, 15, 16, -1, -1]]) == [[5, 6, 7, 12, 13], [8, 9, 10, 12, 13], [8, 15, 16, 12, 13], [8, 15, 16, 12, 13]]\n assert candidate(matrix = [[15, -1, 13, -1, 11], [-1, 14, -1, 12, -1], [17, 16, 18, -1, 19], [-1, -1, -1, 20, -1]]) == [[15, 16, 13, 20, 11], [17, 14, 18, 12, 19], [17, 16, 18, 20, 19], [17, 16, 18, 20, 19]]\n assert candidate(matrix = [[-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1], [1, 2, 3, 4, 5], [6, 7, 8, 9, 10]]) == [[6, 7, 8, 9, 10], [6, 7, 8, 9, 10], [1, 2, 3, 4, 5], [6, 7, 8, 9, 10]]\n assert candidate(matrix = [[-1, 100, -1], [-1, -1, -1], [-1, 100, 100], [50, -1, -1]]) == [[50, 100, 100], [50, 100, 100], [50, 100, 100], [50, 100, 100]]\n assert candidate(matrix = [[15, -1, 17, -1], [20, -1, -1, 23], [-1, 26, 27, -1], [29, -1, 31, -1]]) == [[15, 26, 17, 23], [20, 26, 31, 23], [29, 26, 27, 23], [29, 26, 31, 23]]\n assert candidate(matrix = [[1, -1, 3, -1], [5, 6, 7, 8], [-1, -1, -1, 9], [10, 11, 12, -1]]) == [[1, 11, 3, 9], [5, 6, 7, 8], [10, 11, 12, 9], [10, 11, 12, 9]]\n assert candidate(matrix = [[-1, 0, 1], [-1, 2, 3], [-1, 4, 5], [-1, 6, 7], [-1, 8, 9]]) == [[-1, 0, 1], [-1, 2, 3], [-1, 4, 5], [-1, 6, 7], [-1, 8, 9]]\n assert candidate(matrix = [[-1, -1, -1, 0, 1], [2, -1, 4, 5, 6], [7, 8, 9, -1, 10], [-1, 11, -1, 12, -1]]) == [[7, 11, 9, 0, 1], [2, 11, 4, 5, 6], [7, 8, 9, 12, 10], [7, 11, 9, 12, 10]]\n assert candidate(matrix = [[-1, 3, -1, 2, 5], [-1, 4, 6, 3, 1], [7, 2, -1, -1, 8], [5, 6, 0, 1, 3]]) == [[7, 3, 6, 2, 5], [7, 4, 6, 3, 1], [7, 2, 6, 3, 8], [5, 6, 0, 1, 3]]\n assert candidate(matrix = [[1, 2, -1, 4, 5], [-1, -1, -1, -1, 6], [-1, 3, 7, -1, -1]]) == [[1, 2, 7, 4, 5], [1, 3, 7, 4, 6], [1, 3, 7, 4, 6]]\n assert candidate(matrix = [[1, -1, 3, 4], [5, 6, 7, 8], [-1, 10, 11, 12], [13, 14, 15, -1]]) == [[1, 14, 3, 4], [5, 6, 7, 8], [13, 10, 11, 12], [13, 14, 15, 12]]\n assert candidate(matrix = [[-1, -1, 9], [-1, 8, -1], [-1, -1, 7]]) == [[-1, 8, 9], [-1, 8, 9], [-1, 8, 7]]\n assert candidate(matrix = [[-1, 1, 2, 3, 4], [1, -1, 2, 3, 4], [1, 2, -1, 3, 4], [1, 2, 3, -1, 4], [1, 2, 3, 4, -1]]) == [[1, 1, 2, 3, 4], [1, 2, 2, 3, 4], [1, 2, 3, 3, 4], [1, 2, 3, 4, 4], [1, 2, 3, 4, 4]]\n assert candidate(matrix = [[-1, -1, -1, -1], [-1, 0, 1, -1], [2, -1, -1, 3], [4, -1, 5, -1]]) == [[4, 0, 5, 3], [4, 0, 1, 3], [2, 0, 5, 3], [4, 0, 5, 3]]\n assert candidate(matrix = [[10, 20, -1, 40], [50, 60, 70, 80], [90, -1, -1, -1]]) == [[10, 20, 70, 40], [50, 60, 70, 80], [90, 60, 70, 80]]\n assert candidate(matrix = [[-1, 8, 10, -1, 12], [-1, 7, 14, -1, 13], [-1, 6, 15, -1, 11], [9, 5, 16, -1, 14], [10, 4, 17, -1, 15]]) == [[10, 8, 10, -1, 12], [10, 7, 14, -1, 13], [10, 6, 15, -1, 11], [9, 5, 16, -1, 14], [10, 4, 17, -1, 15]]\n assert candidate(matrix = [[-1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1], [25, 26, 27, 28, 29, 30]]) == [[25, 26, 27, 28, 29, 30], [25, 26, 27, 28, 29, 30], [25, 26, 27, 28, 29, 30], [25, 26, 27, 28, 29, 30]]\n assert candidate(matrix = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]) == [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]\n assert candidate(matrix = [[-1, -1, -1, 40], [-1, 25, -1, 50], [-1, -1, 35, -1], [-1, 45, -1, 60]]) == [[-1, 45, 35, 40], [-1, 25, 35, 50], [-1, 45, 35, 60], [-1, 45, 35, 60]]\n assert candidate(matrix = [[1, -1, 1, -1, 1], [-1, 2, -1, 2, -1], [3, -1, 3, -1, 3], [4, -1, 4, -1, 4]]) == [[1, 2, 1, 2, 1], [4, 2, 4, 2, 4], [3, 2, 3, 2, 3], [4, 2, 4, 2, 4]]\n assert candidate(matrix = [[-1, 2, 3, -1], [4, 5, 6, 7], [8, 9, 10, -1], [11, 12, -1, 14]]) == [[11, 2, 3, 14], [4, 5, 6, 7], [8, 9, 10, 14], [11, 12, 10, 14]]\n assert candidate(matrix = [[-1, 3, -1, -1], [2, -1, 6, -1], [3, 8, 9, 4], [5, -1, -1, 7]]) == [[5, 3, 9, 7], [2, 8, 6, 7], [3, 8, 9, 4], [5, 8, 9, 7]]\n assert candidate(matrix = [[-1, -1, -1, 10, 20], [1, 2, 3, -1, 25], [4, 5, 6, 7, 30], [-1, -1, 8, -1, -1]]) == [[4, 5, 8, 10, 20], [1, 2, 3, 10, 25], [4, 5, 6, 7, 30], [4, 5, 8, 10, 30]]\n assert candidate(matrix = [[10, 20, 30], [40, 50, 60], [70, -1, -1], [-1, 80, 90]]) == [[10, 20, 30], [40, 50, 60], [70, 80, 90], [70, 80, 90]]\n assert candidate(matrix = [[10, -1, 20, -1, 30], [-1, 50, -1, 70, -1], [60, -1, 80, -1, 90], [100, 110, -1, 130, -1]]) == [[10, 110, 20, 130, 30], [100, 50, 80, 70, 90], [60, 110, 80, 130, 90], [100, 110, 80, 130, 90]]\n assert candidate(matrix = [[-1, 3, -1, 5], [-1, -1, -1, 9], [2, 6, -1, 4]]) == [[2, 3, -1, 5], [2, 6, -1, 9], [2, 6, -1, 4]]\n assert candidate(matrix = [[-1, -1, -1, -1], [0, -1, -1, 10], [1, -1, 2, -1], [-1, 3, -1, 4], [5, -1, 6, -1]]) == [[5, 3, 6, 10], [0, 3, 6, 10], [1, 3, 2, 10], [5, 3, 6, 4], [5, 3, 6, 10]]\n assert candidate(matrix = [[1, 2, 3, 4], [-1, -1, -1, -1], [7, 8, 9, 10], [11, 12, 13, 14]]) == [[1, 2, 3, 4], [11, 12, 13, 14], [7, 8, 9, 10], [11, 12, 13, 14]]\n assert candidate(matrix = [[-1, -1, -1, -1], [-1, -1, -1, -1], [1, 2, 3, 4]]) == [[1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]]\n assert candidate(matrix = [[-1, 2, -1, 4, -1], [5, -1, 7, -1, 9], [10, -1, 12, -1, 14], [15, 16, -1, 18, 19]]) == [[15, 2, 12, 4, 19], [5, 16, 7, 18, 9], [10, 16, 12, 18, 14], [15, 16, 12, 18, 19]]\n assert candidate(matrix = [[-1, -1, -1], [-1, -1, -1], [1, 2, 3], [4, 5, 6]]) == [[4, 5, 6], [4, 5, 6], [1, 2, 3], [4, 5, 6]]\n assert candidate(matrix = [[-1, 10, -1, 20], [-1, 15, -1, 25], [30, 5, -1, 35]]) == [[30, 10, -1, 20], [30, 15, -1, 25], [30, 5, -1, 35]]\n assert candidate(matrix = [[1, -1, 3, 4], [-1, -1, 6, 7], [8, 9, -1, -1], [-1, -1, -1, 13]]) == [[1, 9, 3, 4], [8, 9, 6, 7], [8, 9, 6, 13], [8, 9, 6, 13]]\n assert candidate(matrix = [[-1, -1, -1, 0, -1], [1, -1, -1, 2, -1], [3, -1, -1, 4, -1], [5, -1, -1, 6, -1], [7, -1, -1, 8, -1]]) == [[7, -1, -1, 0, -1], [1, -1, -1, 2, -1], [3, -1, -1, 4, -1], [5, -1, -1, 6, -1], [7, -1, -1, 8, -1]]\n assert candidate(matrix = [[1, 2, -1, 4, 5], [6, 7, -1, 8, 9], [10, 11, 12, 13, 14], [-1, 16, 17, 18, 19]]) == [[1, 2, 17, 4, 5], [6, 7, 17, 8, 9], [10, 11, 12, 13, 14], [10, 16, 17, 18, 19]]\n assert candidate(matrix = [[-1, -1, 3], [-1, -1, 4], [-1, 5, -1], [6, -1, -1]]) == [[6, 5, 3], [6, 5, 4], [6, 5, 4], [6, 5, 4]]\n assert candidate(matrix = [[-1, -1, -1, -1], [0, 1, 2, 3], [4, 5, 6, 7]]) == [[4, 5, 6, 7], [0, 1, 2, 3], [4, 5, 6, 7]]\n assert candidate(matrix = [[50, -1, -1, 50, -1], [50, -1, -1, 50, -1], [50, -1, -1, 50, -1], [50, -1, -1, 50, -1], [50, -1, -1, 50, -1]]) == [[50, -1, -1, 50, -1], [50, -1, -1, 50, -1], [50, -1, -1, 50, -1], [50, -1, -1, 50, -1], [50, -1, -1, 50, -1]]\n assert candidate(matrix = [[-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1], [1, 2, 3, 4, 5]]) == [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5]]\n assert candidate(matrix = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [-1, -1, -1, -1, -1], [6, 7, 8, 9, 10]]) == [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [6, 7, 8, 9, 10], [6, 7, 8, 9, 10]]\n assert candidate(matrix = [[-1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [2, -1, 2, -1, 2, -1, 2, -1, 2, -1], [3, -1, 3, -1, 3, -1, 3, -1, 3, -1], [4, -1, 4, -1, 4, -1, 4, -1, 4, -1]]) == [[4, 1, 4, 1, 4, 1, 4, 1, 4, 1], [2, 1, 2, 1, 2, 1, 2, 1, 2, 1], [3, 1, 3, 1, 3, 1, 3, 1, 3, 1], [4, 1, 4, 1, 4, 1, 4, 1, 4, 1]]\n assert candidate(matrix = [[-1, 0, 1], [-1, -1, 2], [3, 4, -1]]) == [[3, 0, 1], [3, 4, 2], [3, 4, 2]]\n"}, "metadata": {"canonical_parameter_names": ["matrix"], "leetcode_dataset_entry_point": "Solution().modifiedMatrix", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector> modifiedMatrix(vector>& matrix) {", "container": "Solution", "callable": "modifiedMatrix", "parameters": [{"name": "matrix", "type": "vector>&"}], "return_type": "vector>", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3034, "task_id": "number-of-subarrays-that-match-a-pattern-i", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums of size n, and a 0-indexed integer array pattern of size m consisting of integers -1, 0, and 1.\nA subarray nums[i..j] of size m + 1 is said to match the pattern if the following conditions hold for each element pattern[k]:\n\nnums[i + k + 1] > nums[i + k] if pattern[k] == 1.\nnums[i + k + 1] == nums[i + k] if pattern[k] == 0.\nnums[i + k + 1] < nums[i + k] if pattern[k] == -1.\n\nReturn the count of subarrays in nums that match the pattern.\n \nExample 1:\n\nInput: nums = [1,2,3,4,5,6], pattern = [1,1]\nOutput: 4\nExplanation: The pattern [1,1] indicates that we are looking for strictly increasing subarrays of size 3. In the array nums, the subarrays [1,2,3], [2,3,4], [3,4,5], and [4,5,6] match this pattern.\nHence, there are 4 subarrays in nums that match the pattern.\n\nExample 2:\n\nInput: nums = [1,4,4,1,3,5,5,3], pattern = [1,0,-1]\nOutput: 2\nExplanation: Here, the pattern [1,0,-1] indicates that we are looking for a sequence where the first number is smaller than the second, the second is equal to the third, and the third is greater than the fourth. In the array nums, the subarrays [1,4,4,1], and [3,5,5,3] match this pattern.\nHence, there are 2 subarrays in nums that match the pattern.\n\n \nConstraints:\n\n2 <= n == nums.length <= 100\n1 <= nums[i] <= 109\n1 <= m == pattern.length < n\n-1 <= pattern[i] <= 1\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 4, 4, 1, 3, 5, 5, 3],pattern = [1, 0, -1]) == 2\n assert candidate(nums = [1, 3, 2, 3, 1, 2],pattern = [1, -1, 1, -1]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6],pattern = [1, 1]) == 4\n assert candidate(nums = [1, 1, 1, 1, 1],pattern = [0, 0, 0]) == 2\n assert candidate(nums = [5, 4, 3, 2, 1],pattern = [-1, -1, -1]) == 2\n assert candidate(nums = [1, 2, 2, 3, 4, 3, 5],pattern = [1, 0, -1, 1]) == 0\n assert candidate(nums = [1, 2, 3, 2, 3, 4],pattern = [1, -1, 1]) == 1\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5],pattern = [1, 0, 1, 0]) == 0\n assert candidate(nums = [3, 5, 2, 8, 6, 4, 7],pattern = [1, -1, 1, -1, 1]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17],pattern = [1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1],pattern = [1, -1, 1, -1, 1, -1, 1]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1],pattern = [1, 1, 1, 1, 1, -1, -1, -1, -1]) == 1\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5],pattern = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 4\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5],pattern = [-1, -1, -1, -1, 1, 1, 1]) == 1\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],pattern = [-1, -1, -1, -1, -1, -1, -1, -1]) == 1\n assert candidate(nums = [2, 1, 3, 1, 4, 1, 5, 1, 6],pattern = [-1, 1, -1, 1, -1, 1]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6],pattern = [1, 1, -1, -1, 1, 1]) == 0\n assert candidate(nums = [100, 200, 150, 150, 200, 250, 300, 200, 100, 100, 200, 300, 400, 500, 600],pattern = [1, -1, 0, 1, 1, -1, 1, 0, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7],pattern = [1, -1, 1, -1, 1, -1, 1]) == 2\n assert candidate(nums = [1, 3, 5, 3, 1, 3, 5, 3, 1],pattern = [1, -1, 1, -1, 1, -1, 1, -1]) == 0\n assert candidate(nums = [10, 20, 15, 15, 20, 25, 30, 20, 10],pattern = [1, -1, 0, 1, 1, -1]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5],pattern = [0, 0, 0, 0, 0, 0, 0]) == 2\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4],pattern = [0, 0, 1, 0, 0, 1, 0, 0, 1]) == 1\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],pattern = [0, 1, 0, 1, 0]) == 3\n assert candidate(nums = [1, 3, 2, 2, 4, 3, 3, 5, 4, 4],pattern = [1, -1, 0, 1, -1, 0, 1, -1]) == 1\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3],pattern = [1, -1, 1, -1, 1, -1, 1, -1, 1]) == 0\n assert candidate(nums = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1],pattern = [-1, -1, -1, -1, -1, -1, -1, -1]) == 0\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1],pattern = [1, -1, 1, -1, 1, -1, 1, -1, 1]) == 0\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10],pattern = [0, 0, 0, 0, 0, 0]) == 2\n assert candidate(nums = [10, 10, 10, 10, 10, 10],pattern = [0, 0, 0]) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],pattern = [0, 0, 0, 0, 0, 0, 0]) == 7\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],pattern = [0, 1, 0, 1, 0, 1, 0]) == 2\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 6, 7, 8],pattern = [1, -1, 1, 1, -1]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],pattern = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5],pattern = [1, -1, 1, -1, 1, 1]) == 0\n assert candidate(nums = [2, 1, 3, 4, 3, 5, 6, 5, 7, 8],pattern = [-1, 1, 1, -1, 1, 1, -1, 1]) == 1\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 6, 7, 8],pattern = [1, -1, 1, 1, 0]) == 0\n assert candidate(nums = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],pattern = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 0\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],pattern = [0, 0, 0, 0, 0, 0, 0]) == 3\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 6, 4, 3, 5, 7],pattern = [1, -1, 1, 1, -1, 1]) == 0\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],pattern = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],pattern = [1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1]) == 0\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 6, 4, 3, 2, 1, 2, 3, 4],pattern = [1, -1, 1, 0, -1, 1]) == 0\n assert candidate(nums = [1, 2, 3, 4, 3, 4, 5, 6, 5, 4],pattern = [1, 1, -1, 1, 1, -1, 1]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],pattern = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(nums = [1, 3, 2, 4, 5, 3, 6, 7],pattern = [1, -1, 1, 0, 1]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pattern = [1, 1, 1, 1, 1, 1, 1]) == 3\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1],pattern = [1, -1, 1, 1, -1, 1, -1, 1]) == 0\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 5, 5, 6, 6],pattern = [1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(nums = [10, 10, 10, 10, 10],pattern = [0, 0, 0]) == 2\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2],pattern = [1, -1, 1, -1, 1, -1]) == 2\n assert candidate(nums = [10, 20, 15, 10, 15, 25, 30, 20],pattern = [1, -1, 1, 1, -1]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],pattern = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 3\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],pattern = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 2\n assert candidate(nums = [1, 2, 2, 1, 1, 2, 2, 1, 1],pattern = [1, 0, -1, 0, 1, 0, -1]) == 1\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5],pattern = [0, 1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(nums = [10, 20, 15, 15, 25, 30, 20, 10, 5],pattern = [1, -1, 0, 1, -1, -1]) == 0\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 6, 5, 4, 3, 2, 1],pattern = [1, -1, 1, 1, -1, 1, -1, -1]) == 0\n assert candidate(nums = [10, 20, 30, 20, 10, 5, 15, 25, 35, 25, 15],pattern = [1, 1, -1, -1, 1, 1, 1, -1]) == 0\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],pattern = [1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0]) == 0\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7],pattern = [1, -1, 1, -1, 1, -1]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],pattern = [1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7],pattern = [1, 0, 1, 0, 1, 0, 1, 0, 1]) == 2\n assert candidate(nums = [5, 3, 8, 6, 7, 4, 9, 10, 11, 10, 9],pattern = [-1, 1, 1, -1, 1, 1, -1, -1]) == 0\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1],pattern = [1, -1, 1, -1, 1, -1, 1]) == 1\n assert candidate(nums = [100, 200, 150, 100, 50, 100, 150, 200, 250, 300],pattern = [1, -1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pattern = [1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],pattern = [0, 0, 0, 0, 0]) == 5\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9],pattern = [-1, -1, -1, -1, -1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],pattern = [-1, -1, -1, -1, -1, -1, -1]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],pattern = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 4\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 6],pattern = [1, 1, -1, -1, 1, 1, 1]) == 0\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14],pattern = [1, 1, 1, 1, 1, 1, 1]) == 3\n assert candidate(nums = [7, 8, 9, 10, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],pattern = [1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 1\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],pattern = [0, 1, 0, 1, 0, 1, 0, 1]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pattern = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [1, 3, 2, 3, 4, 5, 4, 3, 2],pattern = [1, -1, 1, 1, -1, -1, 1]) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],pattern = [-1, -1, -1, -1, -1, -1, -1]) == 3\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],pattern = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 1\n assert candidate(nums = [1, 1, 2, 2, 1, 1, 2, 2, 1, 1],pattern = [0, 1, 0, -1, 0, 1, 0, -1]) == 1\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],pattern = [0, 1, 0, 1, 0, 1, 0]) == 2\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8],pattern = [1, -1, 1, -1, 1, -1, 1, -1]) == 2\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],pattern = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 2\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],pattern = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 2\n assert candidate(nums = [1, 2, 3, 4, 3, 4, 5, 6, 5, 6],pattern = [1, 1, -1, 1, 1, -1, 1]) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5],pattern = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 4\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5],pattern = [1, 1, 1, -1, -1, -1, -1, -1, -1]) == 0\n assert candidate(nums = [1, 3, 2, 4, 5, 3, 6, 7, 8],pattern = [1, -1, 1, 1, 0]) == 0\n assert candidate(nums = [9, 8, 7, 8, 7, 8, 7, 8, 7, 8],pattern = [-1, 1, -1, 1, -1]) == 2\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],pattern = [-1, -1, -1, -1, -1, -1, -1]) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],pattern = [0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1\n assert candidate(nums = [1, 3, 2, 4, 5, 3, 4, 5, 6, 7, 5, 6, 7, 8, 9, 7, 8, 9, 10, 11],pattern = [1, -1, 1, 1, 0, -1, 1, 1, 0, -1, 1, 1, 0, -1]) == 0\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 2, 2, 1, 1, 1, 2, 2, 3, 3],pattern = [1, 0, 1, 0, -1, 0, -1, 0, 1]) == 0\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 5, 6, 7, 8, 8, 9],pattern = [1, 0, 1, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],pattern = [-1, -1, -1, -1, -1, -1, -1, -1]) == 2\n assert candidate(nums = [10, 10, 10, 10, 10],pattern = [0, 0, 0, 0]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pattern = [1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4],pattern = [1, 1, -1, -1, 1, 1]) == 0\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 4, 5, 6, 7],pattern = [1, -1, 1, 1, 1, 1, 0]) == 0\n assert candidate(nums = [5, 3, 5, 3, 5, 3, 5, 3, 5, 3],pattern = [1, -1, 1, -1, 1, -1, 1, -1]) == 1\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 5],pattern = [1, 0, 1, 0, 1]) == 1\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7],pattern = [0, 0, 0, 0, 0, 0, 0]) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],pattern = [0, 0, 0, 0, 0, 0, 0, 0, 0]) == 2\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],pattern = [-1, -1, -1, -1, -1, -1, -1]) == 3\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],pattern = [-1, -1, -1, -1, -1, -1, -1]) == 3\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5],pattern = [1, -1, 1, 0, -1, 1, 0, 1]) == 0\n assert candidate(nums = [3, 3, 3, 2, 2, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1],pattern = [0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1, 1]) == 0\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5],pattern = [1, -1, 1, -1, 1, -1]) == 2\n assert candidate(nums = [10, 20, 10, 20, 10, 20, 10, 20],pattern = [1, -1, 1, -1, 1]) == 2\n assert candidate(nums = [1, 3, 1, 5, 1, 7, 1, 9, 1, 11, 1, 13, 1, 15, 1, 17, 1, 19],pattern = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 1\n assert candidate(nums = [1, 3, 2, 3, 1, 3, 2, 3, 1, 3, 2, 3],pattern = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 1\n assert candidate(nums = [1, 2, 3, 2, 3, 4, 5, 4],pattern = [1, -1, 1, 1]) == 1\n"}, "metadata": {"canonical_parameter_names": ["nums", "pattern"], "leetcode_dataset_entry_point": "Solution().countMatchingSubarrays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int countMatchingSubarrays(vector& nums, vector& pattern) {", "container": "Solution", "callable": "countMatchingSubarrays", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "pattern", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3035, "task_id": "maximum-palindromes-after-operations", "difficulty": "Medium", "problem_description": "You are given a 0-indexed string array words having length n and containing 0-indexed strings.\nYou are allowed to perform the following operation any number of times (including zero):\n\nChoose integers i, j, x, and y such that 0 <= i, j < n, 0 <= x < words[i].length, 0 <= y < words[j].length, and swap the characters words[i][x] and words[j][y].\n\nReturn an integer denoting the maximum number of palindromes words can contain, after performing some operations.\nNote: i and j may be equal during an operation.\n \nExample 1:\n\nInput: words = [\"abbb\",\"ba\",\"aa\"]\nOutput: 3\nExplanation: In this example, one way to get the maximum number of palindromes is:\nChoose i = 0, j = 1, x = 0, y = 0, so we swap words[0][0] and words[1][0]. words becomes [\"bbbb\",\"aa\",\"aa\"].\nAll strings in words are now palindromes.\nHence, the maximum number of palindromes achievable is 3.\nExample 2:\n\nInput: words = [\"abc\",\"ab\"]\nOutput: 2\nExplanation: In this example, one way to get the maximum number of palindromes is: \nChoose i = 0, j = 1, x = 1, y = 0, so we swap words[0][1] and words[1][0]. words becomes [\"aac\",\"bb\"].\nChoose i = 0, j = 0, x = 1, y = 2, so we swap words[0][1] and words[0][2]. words becomes [\"aca\",\"bb\"].\nBoth strings are now palindromes.\nHence, the maximum number of palindromes achievable is 2.\n\nExample 3:\n\nInput: words = [\"cd\",\"ef\",\"a\"]\nOutput: 1\nExplanation: In this example, there is no need to perform any operation.\nThere is one palindrome in words \"a\".\nIt can be shown that it is not possible to get more than one palindrome after any number of operations.\nHence, the answer is 1.\n \nConstraints:\n\n1 <= words.length <= 1000\n1 <= words[i].length <= 100\nwords[i] consists only of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(words = ['abac', 'deed', 'civic', 'rotor']) == 3\n assert candidate(words = ['aabbcc', 'ddeeff', 'gghhiijj', 'kklmmoopp']) == 4\n assert candidate(words = ['aa', 'bb', 'cc', 'dd', 'ee']) == 5\n assert candidate(words = ['noon', 'level', 'deified', 'civic', 'rotor']) == 5\n assert candidate(words = ['aaaa', 'bbbb', 'cccc']) == 3\n assert candidate(words = ['abac', 'decd', 'efef', 'ghgh']) == 3\n assert candidate(words = ['abcde', 'fghij', 'klmno']) == 0\n assert candidate(words = ['a', 'b', 'c', 'd', 'e']) == 5\n assert candidate(words = ['abbb', 'ba', 'aa']) == 3\n assert candidate(words = ['race', 'car', 'level']) == 3\n assert candidate(words = ['race', 'car', 'level', 'deified']) == 4\n assert candidate(words = ['abc', 'ab']) == 2\n assert candidate(words = ['aaa', 'bbb', 'ccc', 'ddd']) == 4\n assert candidate(words = ['hello', 'world', 'python', 'programming', 'code']) == 4\n assert candidate(words = ['abac', 'deed', 'racecar', 'refer', 'madam']) == 4\n assert candidate(words = ['abcde', 'fghij', 'klmno', 'pqrst']) == 0\n assert candidate(words = ['noon', 'civic', 'rotor', 'stats']) == 4\n assert candidate(words = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']) == 10\n assert candidate(words = ['deified', 'civic', 'rotor', 'redder']) == 4\n assert candidate(words = ['hello', 'world', 'python', 'programming']) == 3\n assert candidate(words = ['noon', 'civic', 'rotor', 'refer']) == 4\n assert candidate(words = ['aabbcc', 'bbaacc', 'ccabba', 'aabbbc', 'bbcaac']) == 4\n assert candidate(words = ['xyz', 'zyx', 'abc', 'cba', 'aaa', 'bbb']) == 6\n assert candidate(words = ['abcd', 'dcba', 'efgh', 'hgf', 'i', 'jklm', 'mlkj']) == 7\n assert candidate(words = ['ab', 'cd', 'ef', 'gh', 'ij']) == 0\n assert candidate(words = ['cd', 'ef', 'a']) == 1\n assert candidate(words = ['xxyyzz', 'yzyzyz', 'xzyzxz', 'zyzxzy', 'zzzyyy', 'yyzzzy', 'zzzzyy', 'xxxyyy', 'yyxxzz', 'zzxyyx']) == 9\n assert candidate(words = ['aabbccddeeff', 'abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yz', 'abcdefgh', 'ijklmnop', 'qrstuv', 'wxyz']) == 10\n assert candidate(words = ['xyz', 'zyx', 'yzx', 'zxy', 'yxz', 'xzy', 'abc', 'cba', 'bac', 'bca', 'cab', 'acb']) == 12\n assert candidate(words = ['abcdefghijk', 'zyxwvutsrqp', 'mnopqrstuvw', 'abcdefghij', 'zyxwvutsr', 'mnopqrstu', 'abcdefgh', 'zyxwvuts', 'mnopqrs', 'abcdefg', 'zyxwvut', 'mnopqr', 'abcdef', 'zyxwvu', 'mnopq', 'abcde', 'zyxwv', 'mnop', 'abcd', 'zyxw', 'mno', 'abc', 'zyx', 'mn', 'ab', 'zy', 'm', 'a', 'z', 'y', 'x', 'w', 'v', 'u', 't', 's', 'r', 'q', 'p', 'o', 'n', 'l', 'k', 'j', 'i', 'h', 'g', 'f', 'e', 'd', 'c', 'b']) == 52\n assert candidate(words = ['racecar', 'madam', 'refer', 'level', 'deified', 'rotor', 'reviled', 'deed', 'civic', 'rotor', 'redder', 'repaper', 'rotor', 'deed', 'civic', 'level']) == 16\n assert candidate(words = ['noon', 'civic', 'rotor', 'stats', 'level', 'deified', 'reviled', 'refer', 'abcba', 'babcb', 'ababa', 'abacaba']) == 12\n assert candidate(words = ['aabbaa', 'bbaabb', 'ababab', 'bababa', 'aabbba', 'bbaabb', 'ababab', 'bababa', 'aabbaa', 'bbaabb']) == 9\n assert candidate(words = ['abcdefghij', 'jihgfedcba', 'abcdefgh', 'hgfedcba', 'abcdef', 'fedcba', 'abc', 'cba', 'ab', 'ba', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']) == 20\n assert candidate(words = ['aabbcc', 'ddeeff', 'gghhii', 'jklmno', 'pqrsut', 'vwxyzv']) == 3\n assert candidate(words = ['abacaxa', 'banana', 'civic', 'rotor', 'stats', 'level']) == 6\n assert candidate(words = ['abcdefgh', 'hgfedcba', 'abcdefg', 'gfedcba', 'abcde', 'edcba', 'abcd', 'dcba', 'abc', 'cba', 'ab', 'ba', 'a', 'b']) == 14\n assert candidate(words = ['aaabbbccc', 'dddeeefff', 'ggghhhiii', 'jjjkkklll', 'mmmnnnooo', 'pppqqqrrr', 'ssstttuuu', 'vvvwwwxxx', 'yyyzzzwww', 'xxxyyyzzz']) == 8\n assert candidate(words = ['aaa', 'bbb', 'ccc', 'ddd', 'eee', 'fff', 'ggg', 'hhh', 'iii', 'jjj', 'kkk', 'lll', 'mmm', 'nnn', 'ooo', 'ppp', 'qqq', 'rrr', 'sss', 'ttt', 'uuu', 'vvv', 'www', 'xxx', 'yyy', 'zzz']) == 26\n assert candidate(words = ['aabbcc', 'bbaacc', 'cabbac', 'abcabc', 'acbacb', 'bababc']) == 5\n assert candidate(words = ['abcdefg', 'hijklmn', 'opqrstu', 'vwxyz', 'abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba', 'mnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba', 'mnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba']) == 11\n assert candidate(words = ['abcabcabc', 'bcabcabc', 'cabcabcab', 'abcabcbca', 'bcabcabcb', 'cabcabcbc', 'abcabcabc', 'bcabcabc', 'cabcabcab', 'abcabcbca', 'bcabcabcb', 'cabcabcbc', 'abcabcabc', 'bcabcabc', 'cabcabcab', 'abcabcbca', 'bcabcabcb', 'cabcabcbc']) == 18\n assert candidate(words = ['aabbcc', 'abcabc', 'defdef', 'xyzxyz', 'mnopqr', 'qrstuv']) == 4\n assert candidate(words = ['abcdabcd', 'efefef', 'ghighi', 'jkjkjk', 'lmnmln', 'opopop', 'qrstqr', 'stuvst', 'wxyxw', 'zyzzyz']) == 8\n assert candidate(words = ['racecar', 'madam', 'level', 'refer', 'deed']) == 5\n assert candidate(words = ['racecar', 'madam', 'refer', 'deed', 'level', 'noon', 'civic', 'rotor', 'stats', 'reviled', 'repaid', 'drawer', 'civic', 'rotor', 'redder', 'deed', 'peep', 'noon', 'kayak', 'reviled', 'repaid', 'civic', 'rotor', 'redder', 'deed', 'peep', 'noon', 'kayak', 'madam', 'refer', 'deed', 'level', 'noon', 'civic', 'rotor', 'stats']) == 36\n assert candidate(words = ['aabbcc', 'abcabc', 'bbaacc', 'ccbb', 'aabb', 'abc', 'aab', 'aaa', 'bbb', 'ccc']) == 10\n assert candidate(words = ['abcd', 'dcba', 'efgh', 'hgfe', 'ijkl', 'lkji', 'mnop', 'ponm']) == 8\n assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba', 'mnopqrstuvwxyzabcdefghijkl', 'abcdefghijlmnopqrstuvwxyz', 'qrstuvwxyzabcdefghij', 'klmnopqrstuvwxyzabcdefghi', 'jklmnopqrstuvwxyzabcdefgh', 'ijklmnopqrstuvwxyzabcdefg', 'hijklmnopqrstuvwxyzabcdef', 'ghijklmnopqrstuvwxyzabcde', 'fghijklmnopqrstuvwxyzabcd', 'efghijklmnopqrstuvwxyzabc', 'defghijklmnopqrstuvwxyzab', 'cdefghijklmnopqrstuvwxyza', 'bcdefghijklmnopqrstuvwxyzab', 'abcdefghijklmnopqrstuvwxyz']) == 15\n assert candidate(words = ['aabb', 'bbaa', 'ccdd', 'ddcc', 'eeff', 'ffee', 'gghh', 'higg', 'iijj', 'jjii', 'kkll', 'llkk', 'mmnn', 'nnaa', 'aabb', 'bbcc', 'ccdd', 'ddeeff', 'ffgghh', 'hhiijj', 'kkeeff', 'gghh', 'iijj', 'aabb', 'bbcc', 'ccdd', 'ddeeff', 'ffgghh', 'hhiijj', 'kkeeff', 'gghh', 'iijj', 'aabb', 'bbcc', 'ccdd', 'ddeeff', 'ffgghh', 'hhiijj', 'kkeeff', 'gghh', 'iijj', 'aabb', 'bbcc', 'ccdd', 'ddeeff', 'ffgghh', 'hhiijj', 'kkeeff', 'gghh', 'iijj', 'aabb', 'bbcc', 'ccdd', 'ddeeff', 'ffgghh', 'hhiijj', 'kkeeff']) == 56\n assert candidate(words = ['aabbaa', 'bbccbb', 'cccddd', 'ddeecc', 'effe', 'ggh', 'hi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz', 'abcde', 'fghij', 'klmno', 'pqrst', 'uvwxy', 'z']) == 19\n assert candidate(words = ['aaaaaaaaab', 'bbbbbbbbbb', 'cccccccccc', 'dddddddddd', 'eeeeeeeee', 'fffffffff', 'gggggggg', 'hhhhhhh', 'iiiiii', 'jjjjj', 'kkkk', 'lll', 'mm', 'n', 'o']) == 14\n assert candidate(words = ['aaabbbccc', 'bbbaaaccc', 'cccbbbaaa', 'aabbcc', 'bbaacc', 'ccaabb', 'aabbbc', 'bbcaac', 'ccaabb', 'abcabc', 'ababab', 'bababa', 'aaaaaa', 'bbbbbb', 'cccccc', 'dddddd']) == 16\n assert candidate(words = ['aaaaaa', 'bbbbbb', 'cccccc', 'dddddd', 'eeeeee', 'ffffff', 'gggggg', 'hhhhhh', 'iiiiii', 'jjjjjj', 'kkkkkk', 'llllll', 'mmmmmm', 'nnnnnn', 'oooooo', 'pppppp', 'qqqqqq', 'rrrrrr', 'ssssss', 'tttttt', 'uuuuuu', 'vvvvvv', 'wwwwww', 'xxxxxx', 'yyyyyy', 'zzzzzz']) == 26\n assert candidate(words = ['aabbaa', 'bbaaab', 'ababab', 'bababa', 'aabbba', 'baaabb', 'aababb', 'abbaab', 'ababba', 'babaab', 'abbaba', 'babbaa', 'baabba', 'aababb', 'abbaab']) == 15\n assert candidate(words = ['racecar', 'level', 'deified', 'civic', 'rotor', 'stats', 'refer', 'rotor', 'reviled', 'deed', 'peep', 'noon', 'racecar', 'refer', 'civic', 'level']) == 16\n assert candidate(words = ['abcba', 'babcb', 'ababa', 'abacaba', 'racecar', 'madam']) == 6\n assert candidate(words = ['aaaaaaaaaa', 'bbbbbbbbbb', 'cccccccccc', 'dddddddddd', 'eeeeeeeeee', 'ffffffffff', 'gggggggggg', 'hhhhhhhhhh', 'iiiiiiiiii', 'jjjjjjjjjj']) == 10\n assert candidate(words = ['aab', 'aac', 'abb', 'abc', 'aba', 'aca', 'aaa', 'bbb', 'aab', 'aac', 'aba', 'aca', 'aaa', 'bbb']) == 14\n assert candidate(words = ['abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yzabcd', 'efghij', 'klmnop', 'qrstuv', 'wxyzab', 'cdefgh']) == 8\n assert candidate(words = ['zzzz', 'yyyy', 'xxxx', 'wwww', 'vvvv', 'uuuu', 'tttt', 'ssss', 'rrrr', 'qqqq', 'pppp', 'oooo', 'nnnn', 'mmmm', 'llll', 'kkkk', 'jjjj', 'iiii', 'hhhh', 'gggg', 'ffffff']) == 21\n assert candidate(words = ['abcde', 'edcba', 'fedcb', 'bcdef', 'cdefg', 'bcdea', 'gfedc', 'abcdf', 'bcadf', 'bcade', 'bcdefg', 'bcdefgh', 'bcdefghi', 'bcdefghij', 'bcdefghijk']) == 15\n assert candidate(words = ['abcd', 'dcba', 'efgh', 'hgf', 'ijkl', 'lkj', 'mnop', 'ponm', 'qrst', 'tsrq', 'uvw', 'wvu', 'xyz', 'zyx', 'abcd', 'dcba', 'efgh', 'hgf', 'ijkl', 'lkj', 'mnop', 'ponm', 'qrst', 'tsrq', 'uvw', 'wvu', 'xyz', 'zyx']) == 28\n assert candidate(words = ['ab', 'ba', 'cd', 'dc', 'ef', 'fe', 'gh', 'hg', 'ij', 'ji', 'kl', 'lk', 'mn', 'nm', 'op', 'po', 'qr', 'rq', 'st', 'ts', 'uv', 'vu', 'wx', 'xw', 'yz', 'zy', 'abcdefgh', 'hgfedcba', 'ijklmnop', 'ponmlkji', 'qrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba']) == 31\n assert candidate(words = ['abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yzabcd', 'efghij', 'klmnop', 'qrstuv', 'wxyzab']) == 8\n assert candidate(words = ['abacax', 'bxdxcy', 'cydxdz', 'zxdxzy', 'yxzxyw', 'wxwxyv', 'vwxyvu', 'uvwxut', 'tuvwus', 'suvwtv', 'rvtwus', 'qtwvur', 'ptwvus', 'otwvur', 'ntwvus', 'mtwvur', 'ltwvus', 'kwtvur', 'jwtvus', 'itwvur', 'htwvur', 'gtwvur', 'ftwvur', 'etwvur', 'dtwvur', 'ctwvur', 'btwvur', 'atwvur']) == 24\n assert candidate(words = ['racecar', 'level', 'deified', 'rotor', 'redder', 'repaper', 'reviled', 'kayak']) == 7\n assert candidate(words = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']) == 52\n assert candidate(words = ['abcdefg', 'ghijklm', 'nopqrstu', 'vwxyzabc', 'defghijk', 'lmnopqrs', 'tuvwxyz', 'abcdefghi', 'jklmnopqr', 'stuvwxyzabc']) == 8\n assert candidate(words = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'aa', 'bb', 'cc', 'dd', 'ee', 'ff', 'gg', 'hh', 'ii', 'jj', 'kk', 'll', 'mm', 'nn', 'oo', 'pp', 'qq', 'rr', 'ss', 'tt', 'uu', 'vv', 'ww', 'xx', 'yy', 'zz']) == 52\n assert candidate(words = ['abacax', 'banana', 'anana', 'civic', 'racecar', 'madam', 'level', 'deified']) == 8\n assert candidate(words = ['abababab', 'babababa', 'acacacac', 'bacbacba', 'cdcddcdc', 'dddddddd', 'eeeeeeee', 'ffffffff', 'gggggggg', 'hhhhhhhh']) == 9\n assert candidate(words = ['racecar', 'madam', 'level', 'rotor', 'deified']) == 5\n assert candidate(words = ['ab', 'ba', 'ac', 'ca', 'ad', 'da', 'ae', 'ea', 'af', 'fa', 'ag', 'ga', 'ah', 'ha', 'ai', 'ia', 'aj', 'ja', 'ak', 'ka', 'al', 'la', 'am', 'ma', 'an', 'na', 'ao', 'oa', 'ap', 'pa', 'aq', 'qa', 'ar', 'ra', 'as', 'sa', 'at', 'ta', 'au', 'ua', 'av', 'va', 'aw', 'wa', 'ax', 'xa', 'ay', 'ya', 'az', 'za']) == 50\n assert candidate(words = ['abacaba', 'bcbcbcb', 'bababab', 'cacacac', 'dcdcdcd', 'efefefe', 'gigigig', 'huhuhuh', 'ijijiij', 'kjkjkjk', 'lmnlmnl', 'ponponp', 'qrqrqrq', 'stststs', 'xvxvxvx', 'wywywyw', 'uzuzuzu', 'vavavav', 'bbabbab', 'abbabba']) == 20\n assert candidate(words = ['aabbccddeeff', 'bbccddeeffgg', 'ccddeeffgghh', 'ddeeffgghhiijj', 'eeffgghhiijjkkll', 'ffgghhiijjkkllmmnn', 'gghhiijjkkllmmnnoopp', 'hhiijjkkllmmnnooppqqrr', 'iijjkkllmmnnooppqqrrssttuuvv', 'jjkkllmmnnooppqqrrssttuuvvwxyz']) == 9\n assert candidate(words = ['aabb', 'bbaa', 'abab', 'baba', 'aaaa', 'bbbb', 'abcd', 'dcba', 'efgh', 'ghfe', 'ijkl', 'lkji', 'mnop', 'ponm', 'qrst', 'tsrq', 'uvwx', 'xwvu', 'yzxy', 'yxzy', 'abcdef', 'fedcba', 'ghijkl', 'lkjihg', 'mnopqr', 'rqponm', 'stuvwx', 'xwvuts', 'yzabcd', 'dcba']) == 29\n assert candidate(words = ['racecar', 'madam', 'refer', 'deified', 'rotor', 'kayak', 'reviled', 'repaper', 'redder', 'deed', 'peep', 'noon', 'civic', 'rotor', 'stats', 'level']) == 16\n assert candidate(words = ['abcdabcd', 'bcadbcad', 'cdabcdab', 'dabcadcb', 'abcdabcd', 'bcadbcad', 'cdabcdab', 'dabcadcb']) == 8\n assert candidate(words = ['abacaxa', 'xyz', 'mnopqr', 'uvw', 'stuv', 'lmno', 'ijkl', 'hgf', 'edc', 'bac']) == 8\n assert candidate(words = ['abacax', 'zyzyzy', 'noonnoon', 'levellevel', 'rotorrotor', 'statsstats', 'civiccivic', 'deifieddeified']) == 7\n assert candidate(words = ['abcabcabc', 'bcabcbacb', 'cabacabac', 'aabbcc', 'bbaacc', 'ccaabb', 'abcabcabc', 'bcabcbacb', 'cabacabac', 'aabbcc', 'bbaacc', 'ccaabb', 'abcabcabc', 'bcabcbacb', 'cabacabac', 'aabbcc', 'bbaacc', 'ccaabb', 'abcabcabc', 'bcabcbacb', 'cabacabac', 'aabbcc', 'bbaacc', 'ccaabb', 'abcabcabc', 'bcabcbacb', 'cabacabac', 'aabbcc', 'bbaacc', 'ccaabb']) == 30\n assert candidate(words = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']) == 26\n assert candidate(words = ['aabbcc', 'abcdef', 'zyxwvut', 'mnopqr', 'lkjihg', 'fedcba', 'utsrqponmlkjihgfedcba', 'abcdefghijklnmopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba', 'abcdefghijklnmopqrstuvwxyz']) == 9\n assert candidate(words = ['aabbcc', 'abcabc', 'abcdabcd', 'abcdeabcde', 'abcdefabcdef']) == 5\n assert candidate(words = ['racecar', 'level', 'deified', 'rotor', 'repaper', 'deed', 'civic', 'rotor', 'refer', 'redder']) == 10\n assert candidate(words = ['abacax', 'xaba', 'aa', 'bb', 'cccc', 'dddd', 'eeff', 'fffe', 'gg', 'hh', 'ii', 'jj', 'kk', 'll', 'mm', 'nn', 'oo', 'pp', 'qq', 'rr', 'ss', 'tt', 'uu', 'vv', 'ww', 'xx', 'yy', 'zz']) == 27\n assert candidate(words = ['abccba', 'abcba', 'abba', 'aba', 'a', 'b', 'c', 'd', 'e']) == 9\n assert candidate(words = ['xyz', 'zyx', 'yzx', 'zyx', 'zyx', 'zyx', 'zyx', 'zyx', 'zyx', 'zyx', 'zyx', 'zyx', 'zyx', 'zyx', 'zyx', 'zyx', 'zyx', 'zyx', 'zyx', 'zyx']) == 20\n assert candidate(words = ['ab', 'ba', 'cd', 'dc', 'ef', 'fe', 'gh', 'hg', 'ij', 'ji', 'kl', 'lk', 'mn', 'nm', 'op', 'po', 'qr', 'rq', 'st', 'ts', 'uv', 'vu', 'wx', 'xw', 'yz', 'zy', 'ab', 'ba', 'cd', 'dc', 'ef', 'fe']) == 32\n assert candidate(words = ['aaaa', 'bbbb', 'cccc', 'dddd', 'eeee', 'ffff', 'gggg', 'hhhh', 'iiii', 'jjjj', 'kkkk', 'llll', 'mmmm', 'nnnn', 'oooo', 'pppp', 'qqqq', 'rrrr', 'ssss', 'tttt', 'uuuu', 'vvvv', 'wwww', 'xxxx', 'yyyy', 'zzzz']) == 26\n assert candidate(words = ['z', 'y', 'x', 'w', 'v', 'u', 't', 's', 'r', 'q', 'p', 'o', 'n', 'm', 'l', 'k', 'j', 'i', 'h', 'g', 'f', 'e', 'd', 'c', 'b', 'a', 'z', 'y', 'x', 'w', 'v', 'u', 't', 's', 'r', 'q', 'p', 'o', 'n', 'm', 'l', 'k', 'j', 'i', 'h', 'g', 'f', 'e', 'd', 'c', 'b', 'a']) == 52\n assert candidate(words = ['abcde', 'edcba', 'fghij', 'jihgf', 'klmno', 'onmlk', 'pqrst', 'tsrqp', 'uvwxy', 'yxwvu', 'zabcd', 'dcbae']) == 12\n assert candidate(words = ['aabbcc', 'abcabc', 'abacab', 'aabbccddeeff', 'bbccddeeffgg', 'ccddeeffgghh', 'ddeeffgghhiijj', 'eeffgghhiijjkkll', 'ffgghhiijjkkllmmnn', 'gghhiijjkkllmmnnoopp', 'hhiijjkkllmmnnooppqqrr', 'iijjkkllmmnnooppqqrrssttuuvv', 'jjkkllmmnnooppqqrrssttuuvvwxyz']) == 12\n assert candidate(words = ['racecar', 'madam', 'refer', 'level', 'deified', 'reviled']) == 6\n"}, "metadata": {"canonical_parameter_names": ["words"], "leetcode_dataset_entry_point": "Solution().maxPalindromesAfterOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxPalindromesAfterOperations(vector& words) {", "container": "Solution", "callable": "maxPalindromesAfterOperations", "parameters": [{"name": "words", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3036, "task_id": "number-of-subarrays-that-match-a-pattern-ii", "difficulty": "Hard", "problem_description": "You are given a 0-indexed integer array nums of size n, and a 0-indexed integer array pattern of size m consisting of integers -1, 0, and 1.\nA subarray nums[i..j] of size m + 1 is said to match the pattern if the following conditions hold for each element pattern[k]:\n\nnums[i + k + 1] > nums[i + k] if pattern[k] == 1.\nnums[i + k + 1] == nums[i + k] if pattern[k] == 0.\nnums[i + k + 1] < nums[i + k] if pattern[k] == -1.\n\nReturn the count of subarrays in nums that match the pattern.\n \nExample 1:\n\nInput: nums = [1,2,3,4,5,6], pattern = [1,1]\nOutput: 4\nExplanation: The pattern [1,1] indicates that we are looking for strictly increasing subarrays of size 3. In the array nums, the subarrays [1,2,3], [2,3,4], [3,4,5], and [4,5,6] match this pattern.\nHence, there are 4 subarrays in nums that match the pattern.\n\nExample 2:\n\nInput: nums = [1,4,4,1,3,5,5,3], pattern = [1,0,-1]\nOutput: 2\nExplanation: Here, the pattern [1,0,-1] indicates that we are looking for a sequence where the first number is smaller than the second, the second is equal to the third, and the third is greater than the fourth. In the array nums, the subarrays [1,4,4,1], and [3,5,5,3] match this pattern.\nHence, there are 2 subarrays in nums that match the pattern.\n\n \nConstraints:\n\n2 <= n == nums.length <= 106\n1 <= nums[i] <= 109\n1 <= m == pattern.length < n\n-1 <= pattern[i] <= 1\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 3, 2, 3, 1, 4, 3, 2],pattern = [1, -1, 1, -1]) == 2\n assert candidate(nums = [1, 2, 2, 3, 4, 5],pattern = [1, 0, 1]) == 1\n assert candidate(nums = [1, 4, 4, 1, 3, 5, 5, 3],pattern = [1, 0, -1]) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 5],pattern = [0, 0, 0]) == 3\n assert candidate(nums = [1, 2, 2, 3, 4],pattern = [1, 0, 1]) == 1\n assert candidate(nums = [1, 2, 2, 3, 3, 4],pattern = [1, 0, 1, 0]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6],pattern = [1, 1]) == 4\n assert candidate(nums = [1, 1, 1, 1, 1],pattern = [0, 0, 0]) == 2\n assert candidate(nums = [5, 4, 3, 2, 1],pattern = [-1, -1, -1]) == 2\n assert candidate(nums = [1, 3, 2, 3, 4, 5],pattern = [1, -1, 1]) == 1\n assert candidate(nums = [1, 1, 1, 1, 1],pattern = [0, 0]) == 3\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5],pattern = [1, 0, 0, 1, 0, 0]) == 0\n assert candidate(nums = [1, 3, 2, 4, 3, 5],pattern = [1, -1, 1]) == 2\n assert candidate(nums = [10, 10, 10, 10],pattern = [0, 0]) == 2\n assert candidate(nums = [10, 9, 8, 7, 6, 5],pattern = [-1, -1, -1]) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],pattern = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 2\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2],pattern = [1, -1, 1, -1, 1]) == 0\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1],pattern = [1, -1, 1, 1, 1, -1, -1]) == 0\n assert candidate(nums = [7, 10, 10, 8, 10, 5, 6, 7, 8, 9],pattern = [1, 0, -1, 1, 1, -1, 1, 1]) == 0\n assert candidate(nums = [10, 9, 8, 9, 10, 11, 10, 9, 8, 9, 10],pattern = [-1, -1, 1, 1, -1, -1, 1]) == 0\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 5, 5, 6],pattern = [1, 0, 1, 0, 1, 0, 1]) == 0\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6],pattern = [1, 0, 0, 1, 0, 0, 1]) == 0\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6],pattern = [1, -1, 1, -1, 1, -1]) == 2\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 2, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1],pattern = [0, 1, 0, 1, 0, 1, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, 1, 0, 1, 0, 1, 0, 1, -1, 0, -1, 0, -1, 0, -1, 0]) == 0\n assert candidate(nums = [1, 2, 1, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1],pattern = [1, -1, 1, -1, 1]) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],pattern = [-1, -1, -1, -1, -1]) == 5\n assert candidate(nums = [1, 2, 3, 3, 3, 2, 1, 1, 1, 2, 3],pattern = [1, 0, 0, -1, -1, 0, 0, 1, 1]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 5, 6, 7, 8],pattern = [1, 1, -1, 1, 1, -1, 1, 1]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],pattern = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],pattern = [0, 0, 0, 0, 0, 0, 0]) == 3\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 7, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9],pattern = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == 0\n assert candidate(nums = [10, 9, 8, 8, 7, 6, 5, 4, 3, 2, 1],pattern = [-1, -1, 0, -1, -1, -1, -1, -1, -1]) == 1\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7],pattern = [1, -1, 1, -1, 1, -1, 1]) == 2\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1],pattern = [1, -1, 1, -1, 1, -1]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1],pattern = [1, 1, 1, -1, -1, -1]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pattern = [1, 1, 1, 1, 1]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1],pattern = [1, 1, 1, 1, 1, -1, -1, -1, -1, -1]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pattern = [1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1],pattern = [1, 1, -1, -1, 1, 1]) == 0\n assert candidate(nums = [100, 200, 150, 250, 200, 300, 250, 350, 300, 400],pattern = [1, -1, 1, -1, 1, -1, 1]) == 2\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 3, 2, 2, 2, 1, 1, 1, 2, 2, 2, 3, 3, 3],pattern = [1, 0, 0, 1, 0, 0, -1, 0, 0, -1, 0, 0, 1, 0, 0]) == 1\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1],pattern = [1, -1, 1, -1, 1, -1, 1]) == 1\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 1, 1, 1],pattern = [0, 1, 0, -1, 0]) == 0\n assert candidate(nums = [1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6],pattern = [1, -1, 1, 1, -1, 1, -1, 1]) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],pattern = [-1, -1, -1, -1, -1, -1, -1, -1, -1]) == 1\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 3, 2, 2, 2, 1, 1, 1, 1],pattern = [1, 0, 1, 0, -1, 0, -1]) == 0\n assert candidate(nums = [1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1],pattern = [0, 1, 0, -1, 0, 1, 0, -1, 0, 1]) == 1\n assert candidate(nums = [1, 1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8],pattern = [0, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],pattern = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 3\n assert candidate(nums = [10, 20, 10, 30, 20, 40, 30, 50],pattern = [1, -1, 1, -1, 1]) == 2\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2],pattern = [1, -1, 1, -1, 1, -1, 1, -1]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],pattern = [1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 6, 7, 8, 9, 10],pattern = [-1, -1, -1, -1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1]) == 1\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3],pattern = [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0]) == 1\n assert candidate(nums = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5],pattern = [-1, -1, -1, -1, 0, 1, 1, 1, 1, 0, -1, -1, -1, -1, 0, 1, 1, 1, 1]) == 1\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],pattern = [-1, -1, -1, -1, -1, -1]) == 4\n assert candidate(nums = [1, 2, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1],pattern = [1, -1, 0, 1, -1, 1, -1, 1, -1]) == 1\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4],pattern = [1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1]) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],pattern = [-1, -1, -1, -1, -1, -1]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],pattern = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3],pattern = [0, 0, 0, 1, 0, 0, 0]) == 1\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7],pattern = [1, -1, 1, -1, 1]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2],pattern = [1, 1, 1, -1, -1, -1, 1]) == 0\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 4, 3, 2, 1],pattern = [1, -1, 1, -1, 1]) == 0\n assert candidate(nums = [10, 10, 11, 12, 13, 13, 12, 11, 12, 13, 13, 12, 10],pattern = [0, 1, 1, 1, 0, -1, -1, 1, 1, 0, -1, -1]) == 1\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],pattern = [0, 1, 0, 1, 0]) == 3\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],pattern = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 1\n assert candidate(nums = [1, 2, 2, 1, 2, 2, 1, 2, 2, 1],pattern = [1, 0, -1, 1, 0, -1, 1, 0]) == 1\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],pattern = [0, 1, 0, 1, 0, 1]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5],pattern = [1, 1, 1, -1, -1, -1, 1, 1, 1]) == 0\n assert candidate(nums = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1],pattern = [-1, -1, -1, -1, 0, 1, 1, 1, 1, 0, -1, -1, -1, -1]) == 1\n assert candidate(nums = [5, 1, 5, 2, 5, 3, 5, 4, 5, 5, 5, 6, 7, 8],pattern = [1, -1, 1, -1, 1, 0, 1, 0, 0, 1, 1]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pattern = [0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],pattern = [0, 0, 0, 0, 0]) == 5\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3],pattern = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 0\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10],pattern = [0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1]) == 0\n assert candidate(nums = [1, 3, 5, 4, 6, 5, 7, 8, 7, 9, 10, 9, 11, 12],pattern = [1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == 0\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6],pattern = [1, 0, 1, 0, 1, 0, 1]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],pattern = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [9, 8, 7, 8, 9, 10, 9, 8, 7, 8, 9, 10],pattern = [-1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],pattern = [0, 1, 0, 1, 0, 1, 0, 1]) == 4\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],pattern = [0, 1, 0, 1, 0, 1, 0]) == 2\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 6, 6, 7, 8],pattern = [1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(nums = [1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pattern = [0, 0, 0, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [3, 1, 2, 4, 3, 5, 6, 5, 7, 8, 7, 9, 10, 11, 10, 12, 13, 14, 13, 15, 16],pattern = [1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1]) == 0\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 6, 5, 7, 8, 7, 9, 10, 11, 10, 12, 13, 14, 13, 15, 16, 15, 17, 18, 17, 19, 20, 19, 21, 22],pattern = [1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1]) == 0\n assert candidate(nums = [3, 2, 3, 2, 3, 2, 3, 2, 3, 2],pattern = [-1, 1, -1, 1, -1, 1, -1]) == 2\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 5, 6, 7, 8, 9, 10],pattern = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],pattern = [1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1]) == 1\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],pattern = [-1, -1, -1, -1, -1, -1]) == 3\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],pattern = [-1, -1, -1, -1, -1]) == 5\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9],pattern = [1, 0, 1, 1, 1, 1]) == 1\n assert candidate(nums = [5, 6, 5, 6, 5, 6, 5, 6, 5, 6],pattern = [1, -1, 1, -1, 1, -1, 1]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6],pattern = [1, 1, 1, -1, -1, -1, 1, 1, 1]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],pattern = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1\n assert candidate(nums = [1, 3, 2, 1, 2, 3, 2, 1, 3, 2, 1],pattern = [1, -1, 1, -1, 1, -1]) == 0\n assert candidate(nums = [1, 2, 2, 3, 3, 2, 2, 1, 1, 2, 2, 3, 3, 2, 2, 1, 1, 2, 2, 3, 3, 2, 2, 1, 1],pattern = [1, 0, 0, 1, 0, 0, -1, -1, 0, 0, 1, 0, 0, -1, -1, 0, 0, 1, 0, 0, -1, -1, 0, 0]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1],pattern = [1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1]) == 1\n assert candidate(nums = [1, 3, 5, 4, 6, 7, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1],pattern = [1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1]) == 0\n assert candidate(nums = [1, 2, 3, 2, 3, 4, 5, 4, 5, 6],pattern = [1, -1, 1, 1, -1, 1]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pattern = [1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1],pattern = [1, -1, 1, -1, 1, -1, 1, -1]) == 0\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2],pattern = [1, -1, 1, -1, 1, -1, 1]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pattern = [1, 1, 1, 1, 1, 1, 1]) == 3\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5],pattern = [-1, -1, -1, -1, -1, -1, 1, 1, 1]) == 0\n assert candidate(nums = [5, 6, 7, 8, 7, 6, 7, 8, 9, 10],pattern = [1, 1, -1, -1, 1, 1, 1]) == 1\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],pattern = [-1, -1, -1, -1, -1, -1, -1]) == 3\n assert candidate(nums = [3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6],pattern = [0, 1, 0, 1, 0, 1, 0, 1]) == 0\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1],pattern = [1, -1, 1, -1, 1, -1, 1]) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 2, 2, 1, 1, 2, 2, 3, 3],pattern = [0, 1, 0, -1, 0, 1, 0, -1]) == 0\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2],pattern = [1, -1, 1, -1, 1]) == 3\n"}, "metadata": {"canonical_parameter_names": ["nums", "pattern"], "leetcode_dataset_entry_point": "Solution().countMatchingSubarrays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int countMatchingSubarrays(vector& nums, vector& pattern) {", "container": "Solution", "callable": "countMatchingSubarrays", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "pattern", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3038, "task_id": "maximum-number-of-operations-with-the-same-score-i", "difficulty": "Easy", "problem_description": "You are given an array of integers nums. Consider the following operation:\n\nDelete the first two elements nums and define the score of the operation as the sum of these two elements.\n\nYou can perform this operation until nums contains fewer than two elements. Additionally, the same score must be achieved in all operations.\nReturn the maximum number of operations you can perform.\n \nExample 1:\n\nInput: nums = [3,2,1,4,5]\nOutput: 2\nExplanation:\n\nWe can perform the first operation with the score 3 + 2 = 5. After this operation, nums = [1,4,5].\nWe can perform the second operation as its score is 4 + 1 = 5, the same as the previous operation. After this operation, nums = [5].\nAs there are fewer than two elements, we can't perform more operations.\n\n\nExample 2:\n\nInput: nums = [1,5,3,3,4,1,3,2,2,3]\nOutput: 2\nExplanation:\n\nWe can perform the first operation with the score 1 + 5 = 6. After this operation, nums = [3,3,4,1,3,2,2,3].\nWe can perform the second operation as its score is 3 + 3 = 6, the same as the previous operation. After this operation, nums = [4,1,3,2,2,3].\nWe cannot perform the next operation as its score is 4 + 1 = 5, which is different from the previous scores.\n\n\nExample 3:\n\nInput: nums = [5,3]\nOutput: 1\n\n \nConstraints:\n\n2 <= nums.length <= 100\n1 <= nums[i] <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 20, 30, 40, 50, 60]) == 1\n assert candidate(nums = [1, 100, 1, 100, 1, 100]) == 3\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5]) == 4\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 5\n assert candidate(nums = [1000, 1, 999, 2, 998, 3]) == 3\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 5\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(nums = [1, 5, 3, 3, 4, 1, 3, 2, 2, 3]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 5\n assert candidate(nums = [1000, 1, 1000, 1, 1000, 1]) == 3\n assert candidate(nums = [100, 200, 100, 200, 100, 200]) == 3\n assert candidate(nums = [3, 2, 1, 4, 5]) == 2\n assert candidate(nums = [100, 200, 100, 200, 100]) == 2\n assert candidate(nums = [2, 2, 2, 2, 2, 1, 1, 1, 1, 1]) == 2\n assert candidate(nums = [5, 3]) == 1\n assert candidate(nums = [99, 1, 98, 2, 97, 3]) == 3\n assert candidate(nums = [10, 10, 10, 10, 10, 10]) == 3\n assert candidate(nums = [10, 10, 20, 20, 30, 30]) == 1\n assert candidate(nums = [2, 3, 2, 3, 2, 3, 2, 3]) == 4\n assert candidate(nums = [7, 7, 8, 8, 9, 9, 10, 10]) == 1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1]) == 3\n assert candidate(nums = [2, 2, 3, 3, 4, 4, 5, 5]) == 1\n assert candidate(nums = [10, 20, 10, 20, 30, 40]) == 2\n assert candidate(nums = [7, 13, 13, 7, 10, 10, 10, 10, 15, 15]) == 4\n assert candidate(nums = [42, 42, 84, 0, 84, 0, 168, -42, 42, 84, 168, -84, 84, 168, -168, 42]) == 3\n assert candidate(nums = [10, 10, 20, 20, 10, 10, 20, 20, 10, 10, 20, 20, 10, 10]) == 1\n assert candidate(nums = [250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250]) == 11\n assert candidate(nums = [50, 50, 25, 75, 25, 75, 100, 0, 0, 100, 10, 90, 20, 80, 30, 70]) == 8\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(nums = [100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1]) == 7\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 10\n assert candidate(nums = [5, 5, 10, 10, 20, 20, 40, 40, 80, 80, 160, 160, 320, 320, 640, 640, 1280, 1280, 2560, 2560]) == 1\n assert candidate(nums = [33, 67, 33, 67, 33, 67, 33, 67, 33, 67, 33, 67, 33, 67, 33, 67, 33, 67, 33, 67, 33, 67]) == 11\n assert candidate(nums = [45, 55, 45, 55, 45, 55, 45, 55, 45, 55, 45, 55, 45, 55, 45, 55, 45, 55, 45, 55]) == 10\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 15\n assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(nums = [100, 100, 1, 1, 100, 100, 2, 2, 100, 100, 3, 3, 100, 100, 4, 4]) == 1\n assert candidate(nums = [6, 6, 12, 12, 18, 18, 24, 24, 30, 30, 36, 36, 42, 42, 48, 48, 54, 54, 60, 60]) == 1\n assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50, 60, 60]) == 1\n assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50, 60, 60, 70, 70, 80, 80, 90, 90, 100, 100]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 1\n assert candidate(nums = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20]) == 6\n assert candidate(nums = [1, 2, 3, 4, 3, 4, 5, 6, 5, 6, 7, 8, 7, 8]) == 1\n assert candidate(nums = [10, 10, 5, 5, 2, 8, 6, 4, 3, 7, 1, 9]) == 1\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 30\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 8\n assert candidate(nums = [500, 500, 250, 250, 125, 125, 625, 625, 312, 312]) == 1\n assert candidate(nums = [9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1]) == 16\n assert candidate(nums = [1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1]) == 8\n assert candidate(nums = [3, 1, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2]) == 1\n assert candidate(nums = [100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100]) == 5\n assert candidate(nums = [7, 3, 3, 7, 5, 5, 2, 2, 8, 8, 1, 1, 9, 9, 4, 4, 6, 6]) == 3\n assert candidate(nums = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100]) == 9\n assert candidate(nums = [5, 5, 10, 10, 15, 15, 20, 20, 25, 25, 30, 30, 35, 35, 40, 40]) == 1\n assert candidate(nums = [1, 2, 3, 3, 2, 1, 4, 5, 5, 4, 6, 7, 7, 6]) == 1\n assert candidate(nums = [7, 3, 3, 7, 7, 3, 3, 7, 7, 3, 3, 7, 7, 3, 3, 7]) == 8\n assert candidate(nums = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1, 12, 1, 13, 1, 14, 1, 15, 1, 16, 1, 17, 1, 18, 1, 19, 1, 20]) == 1\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 1\n assert candidate(nums = [42, 42, 84, 0, 42, 42, 84, 0, 42, 42]) == 5\n assert candidate(nums = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]) == 1\n assert candidate(nums = [50, 50, 50, 49, 49, 50, 49, 50, 49, 48, 48, 48]) == 1\n assert candidate(nums = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20]) == 5\n assert candidate(nums = [100, 1, 99, 2, 98, 3, 97, 4, 96, 5, 95, 6, 94, 7, 93, 8, 92, 9]) == 9\n assert candidate(nums = [10, 20, 10, 20, 30, 30, 40, 40, 50, 50]) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 15\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1\n assert candidate(nums = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100]) == 10\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 19\n assert candidate(nums = [5, 5, 10, 5, 5, 10, 5, 5, 10, 5, 5, 10, 5, 5, 10, 5, 5, 10, 5, 5, 10, 5, 5, 10, 5, 5, 10, 5, 5, 10]) == 1\n assert candidate(nums = [10, 10, 5, 5, 10, 10, 5, 5, 10, 10, 5, 5, 10, 10]) == 1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 11\n assert candidate(nums = [500, 500, 250, 250, 750, 250, 500, 250, 500, 250, 750, 250, 500, 250, 750, 250, 500, 250]) == 1\n assert candidate(nums = [999, 1, 998, 2, 997, 3, 996, 4, 995, 5]) == 5\n assert candidate(nums = [100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1]) == 6\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14]) == 1\n assert candidate(nums = [1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000]) == 6\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums = [7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3]) == 12\n assert candidate(nums = [50, 50, 25, 25, 75, 75, 25, 25, 75, 75]) == 1\n assert candidate(nums = [5, 5, 10, 10, 15, 15, 20, 20, 25, 25, 30, 30, 35, 35, 40, 40, 45, 45, 50, 50]) == 1\n assert candidate(nums = [100, 1, 2, 98, 3, 97, 4, 96, 5, 95, 6, 94, 7, 93]) == 1\n assert candidate(nums = [8, 1, 1, 8, 2, 7, 3, 6, 4, 5, 1, 8, 1, 8, 2, 7, 3, 6, 4, 5]) == 10\n assert candidate(nums = [99, 1, 98, 2, 97, 3, 96, 4, 95, 5, 94, 6, 93, 7, 92, 8, 91, 9]) == 9\n assert candidate(nums = [7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3]) == 15\n assert candidate(nums = [8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1]) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums = [100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200]) == 6\n assert candidate(nums = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1]) == 8\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 13\n assert candidate(nums = [100, 1, 100, 1, 100, 1, 100, 1, 100, 1]) == 5\n assert candidate(nums = [1, 999, 998, 1, 499, 500, 249, 751, 374, 626, 187, 813, 93, 907, 46, 954]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums = [1, 999, 1, 999, 1, 999, 1, 999, 1, 999, 1, 999, 1, 999, 1, 999, 1, 999]) == 9\n assert candidate(nums = [7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3]) == 10\n assert candidate(nums = [7, 7, 14, 0, 14, 0, 21, -7, 7, 14, 28, -14, 14, 28, -21, 7]) == 4\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(nums = [10, 10, 15, 5, 20, 0, 15, 5]) == 4\n assert candidate(nums = [1, 99, 2, 98, 3, 97, 4, 96, 5, 95, 6, 94, 7, 93, 8, 92]) == 8\n assert candidate(nums = [1, 999, 1, 999, 1, 999, 1, 999, 1, 999]) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 5\n assert candidate(nums = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50]) == 1\n assert candidate(nums = [10, 20, 10, 20, 30, 30, 40, 40, 50, 50, 60, 60]) == 2\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maxOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxOperations(vector& nums) {", "container": "Solution", "callable": "maxOperations", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3039, "task_id": "apply-operations-to-make-string-empty", "difficulty": "Medium", "problem_description": "You are given a string s.\nConsider performing the following operation until s becomes empty:\n\nFor every alphabet character from 'a' to 'z', remove the first occurrence of that character in s (if it exists).\n\nFor example, let initially s = \"aabcbbca\". We do the following operations:\n\nRemove the underlined characters s = \"aabcbbca\". The resulting string is s = \"abbca\".\nRemove the underlined characters s = \"abbca\". The resulting string is s = \"ba\".\nRemove the underlined characters s = \"ba\". The resulting string is s = \"\".\n\nReturn the value of the string s right before applying the last operation. In the example above, answer is \"ba\".\n \nExample 1:\n\nInput: s = \"aabcbbca\"\nOutput: \"ba\"\nExplanation: Explained in the statement.\n\nExample 2:\n\nInput: s = \"abcd\"\nOutput: \"abcd\"\nExplanation: We do the following operation:\n- Remove the underlined characters s = \"abcd\". The resulting string is s = \"\".\nThe string just before the last operation is \"abcd\".\n\n \nConstraints:\n\n1 <= s.length <= 5 * 105\ns consists only of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"zzzzzzzzzz\") == \"z\"\n assert candidate(s = \"aabbccddeeaabbccddeeaabbccddeeaabbccddeeaabbccddeeaabbccddeeaabbccddeeaabbccddeeaabbccddeeaabbccddeeaabbccdd\") == \"abcd\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\") == \"abc\"\n assert candidate(s = \"ababababababababababababababababababababababababab\") == \"ab\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"aaabbbcccdddeeefffggghhhiiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyyzzzz\") == \"iyz\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"abcabcabcabcabc\") == \"abc\"\n assert candidate(s = \"aabcbbca\") == \"ba\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"z\"\n assert candidate(s = \"abcd\") == \"abcd\"\n assert candidate(s = \"aaabbbcccdddeeefffggghhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxyyyyzzzz\") == \"ijklmnopqrstuvwyz\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\") == \"zyxwvutsrqponmlkjihgfedcba\"\n assert candidate(s = \"bbaaccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == \"bacdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"mnlmlnlmlnlmlnlmlnlmlnlmlnlmlnlmlnlmlnlmlnlmlnlmlnlmlnlmlnlmlnlmlnlmlnlmlnlmlnlmlnlmlnlmlnlmlnlmlnlmlnlmlnlmlnl\") == \"l\"\n assert candidate(s = \"uniquecharacterswithoutrepeats\") == \"et\"\n assert candidate(s = \"xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz\") == \"xyz\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"z\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"z\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == \"zyxwvutsrqponmlkjihgfedcba\"\n assert candidate(s = \"aaaaaaaaabbbbbbbbccccccccddddddddeeeeeeeeeffffffffggggggggghhhhhhhhhhiiiiiiiiiijjjjjjjjjjkkkkkkkkkkllllllllllmmmmmmmmmmmnnnnnnnnnnnooooooooooooppppppppppppqqqqqqqqqqqqrrrrrrrrrrrrsssssssssssstttttttttttttuuuuuuuuuuuuuvvvvvvvvvvvvvwwwwwwwwwwwwwxxxxxxxxxxxxxyyyyyyyyyyyyyyzzzzzzzzzzzzzz\") == \"yz\"\n assert candidate(s = \"qwertqwertqwertqwertqwertqwertqwertqwertqwertqwertqwertqwertqwertqwertqwertqwertqwertqwertqwertqwert\") == \"qwert\"\n assert candidate(s = \"zzzzzyyyyxxxwwvvvuuutttssrrqqppoonnmmmlllkkkjjjiiiighhhgggfffeeedddccccbbbaaaa\") == \"z\"\n assert candidate(s = \"zzzzzyyyyxxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaaa\") == \"z\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzyxwvutsrqponmlkjihgfedcba\") == \"zyxwvutsrqponmlkjihgfedcba\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzyyyyxxxwwvvvuuutttssrrqqppoonnmmmlllkkkjjjiiiighhhgggfffeeedddccccbbbaaaa\") == \"yigca\"\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbccccccccddddddddddeeeeeeeeefffffffffggggggggghhhhhhhhhhiiiiiiiiijjjjjjjjkkkkkkkkklllllllllmmmmmmmmmnnnnnnnnnooooooooooppppppppppqqqqqqqqqrrrrrrrrrssssssssstttttttttuuuuuuuuuvvvvvvvvvwwwwwwwwwxxxxxxxxxyyyyyyyyyzzzzzzzzz\") == \"adhop\"\n assert candidate(s = \"aaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbccccccccccccccccdddddddddddddd\") == \"a\"\n assert candidate(s = \"zzyyxxwwvvttuusssrrrqqqpppoonnnmmmllllkkkkjjjjiiiidddddhhhgggeeeefffccccba\") == \"d\"\n assert candidate(s = \"thisisaverylongstringwithmanycharactersrepeatingoverandoveragainoverandoveragain\") == \"a\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == \"abc\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzyyyyxxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaaa\") == \"y\"\n assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabad\") == \"a\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == \"abc\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\") == \"zyxwvutsrqponmlkjihgfedcba\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"z\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\") == \"zyxwvutsrqponmlkjihgfedcba\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == \"zyxwvutsrqponmlkjihgfedcba\"\n assert candidate(s = \"repeatedrepeatedrepeatedrepeatedrepeatedrepeatedrepeatedrepeatedrepeatedrepeatedrepeatedrepeatedrepeatedrepeatedrepeatedrepeatedrepeated\") == \"e\"\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().lastNonEmptyString", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string lastNonEmptyString(string s) {", "container": "Solution", "callable": "lastNonEmptyString", "parameters": [{"name": "s", "type": "string"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3040, "task_id": "maximum-number-of-operations-with-the-same-score-ii", "difficulty": "Medium", "problem_description": "Given an array of integers called nums, you can perform any of the following operation while nums contains at least 2 elements:\n\nChoose the first two elements of nums and delete them.\nChoose the last two elements of nums and delete them.\nChoose the first and the last elements of nums and delete them.\n\nThe score of the operation is the sum of the deleted elements.\nYour task is to find the maximum number of operations that can be performed, such that all operations have the same score.\nReturn the maximum number of operations possible that satisfy the condition mentioned above.\n \nExample 1:\n\nInput: nums = [3,2,1,2,3,4]\nOutput: 3\nExplanation: We perform the following operations:\n- Delete the first two elements, with score 3 + 2 = 5, nums = [1,2,3,4].\n- Delete the first and the last elements, with score 1 + 4 = 5, nums = [2,3].\n- Delete the first and the last elements, with score 2 + 3 = 5, nums = [].\nWe are unable to perform any more operations as nums is empty.\n\nExample 2:\n\nInput: nums = [3,2,6,1,4]\nOutput: 2\nExplanation: We perform the following operations:\n- Delete the first two elements, with score 3 + 2 = 5, nums = [6,1,4].\n- Delete the last two elements, with score 1 + 4 = 5, nums = [6].\nIt can be proven that we can perform at most 2 operations.\n\n \nConstraints:\n\n2 <= nums.length <= 2000\n1 <= nums[i] <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 20, 30, 40, 50, 60]) == 3\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2]) == 4\n assert candidate(nums = [1, 3, 2, 2, 3, 1]) == 3\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 5\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4]) == 4\n assert candidate(nums = [5, 8, 8, 5, 8, 8, 5]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 5\n assert candidate(nums = [1000, 1, 1000, 1, 1000, 1]) == 3\n assert candidate(nums = [1, 3, 2, 3, 1]) == 2\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7]) == 3\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10]) == 4\n assert candidate(nums = [3, 2, 6, 1, 4]) == 2\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1]) == 2\n assert candidate(nums = [3, 2, 1, 2, 3, 4]) == 3\n assert candidate(nums = [5, 8, 9, 1, 2, 3, 4, 8, 5]) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1]) == 4\n assert candidate(nums = [10, 10, 10, 10, 10, 10]) == 3\n assert candidate(nums = [1000, 1, 1, 1000]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8]) == 4\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2]) == 4\n assert candidate(nums = [1, 2, 3, 2, 1]) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 10\n assert candidate(nums = [10, 10, 10, 10, 10]) == 2\n assert candidate(nums = [1, 3, 2, 3, 1, 2, 3, 1]) == 4\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 8\n assert candidate(nums = [9, 8, 7, 6, 5, 6, 7, 8, 9, 10, 11, 12, 13, 12, 11, 10, 9, 8, 7, 6, 5, 6, 7, 8, 9]) == 2\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 10\n assert candidate(nums = [5, 1, 5, 1, 5, 1, 5, 1, 5]) == 4\n assert candidate(nums = [8, 5, 8, 5, 8, 5, 8, 5, 8, 5, 8, 5, 8, 5, 8, 5]) == 8\n assert candidate(nums = [1000, 999, 1000, 999, 1000, 999, 1000, 999, 1000, 999, 1000]) == 5\n assert candidate(nums = [1, 2, 3, 4, 3, 4, 3, 2, 1, 2, 3, 2, 3, 2, 1, 2, 3, 4, 3, 2, 1]) == 2\n assert candidate(nums = [1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1]) == 5\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 500, 400, 300, 200, 100]) == 2\n assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 10\n assert candidate(nums = [10, 20, 30, 40, 50, 40, 30, 20, 10, 20, 30, 40, 50, 40, 30, 20, 10]) == 2\n assert candidate(nums = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10, 9, 7, 5, 3, 1, 2, 4, 6, 8, 10]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 15\n assert candidate(nums = [5, 10, 15, 10, 5, 10, 15, 10, 5]) == 2\n assert candidate(nums = [1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2]) == 16\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 9\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 10\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 5\n assert candidate(nums = [3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4]) == 6\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 16\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 4, 5, 6, 5, 4, 3, 2, 1, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [1, 1, 2, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 3\n assert candidate(nums = [1, 3, 2, 4, 3, 2, 1, 3, 2, 4, 3, 2, 1, 3, 2, 4, 3, 2, 1, 3, 2, 4, 3, 2, 1, 3, 2, 4, 3, 2, 1, 3, 2, 4, 3, 2, 1]) == 1\n assert candidate(nums = [3, 2, 1, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 3\n assert candidate(nums = [9, 3, 9, 3, 9, 3, 9, 3, 9, 3]) == 5\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2]) == 1\n assert candidate(nums = [1, 3, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9]) == 1\n assert candidate(nums = [5, 10, 15, 10, 5, 10, 15, 10, 5]) == 2\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 14\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112]) == 8\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 13\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9]) == 2\n assert candidate(nums = [5, 8, 5, 8, 5, 8, 5, 8]) == 4\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 21\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [8, 1, 4, 3, 2, 1, 8, 1, 4, 3, 2, 1]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 40, 30, 20, 10, 20, 30, 40, 50, 40, 30, 20, 10, 20, 30, 40]) == 5\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 2\n assert candidate(nums = [1000, 1, 1000, 2, 1000, 3, 1000, 4, 1000, 5, 1000, 6, 1000, 7, 1000, 8, 1000, 9, 1000, 10]) == 1\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 10\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 2\n assert candidate(nums = [100, 200, 100, 300, 200, 100, 300, 200, 100]) == 2\n assert candidate(nums = [100, 200, 100, 300, 200, 100, 400, 300]) == 1\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 27, 24, 21, 18, 15, 12, 9, 6, 3]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [10, 20, 30, 40, 50, 40, 30, 20, 10, 10, 20, 30, 40, 50, 40, 30, 20, 10, 10, 20, 30, 40, 50, 40, 30, 20, 10]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 12\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2]) == 2\n assert candidate(nums = [100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700]) == 6\n assert candidate(nums = [5, 5, 5, 5, 10, 10, 15, 15, 20, 20, 25, 25, 30, 30, 35, 35]) == 2\n assert candidate(nums = [1, 3, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 20\n assert candidate(nums = [100, 200, 300, 400, 500, 400, 300, 200, 100, 100, 200, 300, 400, 500, 400, 300, 200, 100]) == 2\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 15\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140, 147, 154, 161, 168, 175, 182, 189, 196, 203, 210]) == 15\n assert candidate(nums = [10, 15, 10, 15, 10, 15, 10, 15, 10, 15, 10, 15, 10, 15, 10, 15, 10, 15, 10, 15]) == 10\n assert candidate(nums = [20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20]) == 10\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 10\n assert candidate(nums = [10, 20, 10, 30, 10, 40, 10, 50, 10, 60, 10, 70, 10, 80, 10, 90, 10, 100]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 10\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 6\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 95, 85, 75, 65, 55, 45, 35, 25, 15, 5]) == 2\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 10\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 2\n assert candidate(nums = [5, 9, 5, 9, 5, 9, 5, 9, 5, 9]) == 5\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2\n assert candidate(nums = [15, 25, 15, 25, 15, 25, 15, 25, 15, 25, 15, 25, 15, 25, 15, 25, 15, 25, 15, 25]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1]) == 1\n assert candidate(nums = [100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200]) == 10\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8]) == 16\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 2\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300]) == 15\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 23\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80]) == 8\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 9\n assert candidate(nums = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]) == 15\n assert candidate(nums = [3, 1, 3, 2, 3, 1, 3, 2, 3, 1, 3, 2, 3, 1]) == 2\n assert candidate(nums = [1, 2, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4]) == 17\n assert candidate(nums = [5, 9, 1, 9, 5, 9, 1, 9, 5, 9]) == 2\n assert candidate(nums = [100, 200, 300, 400, 500, 500, 400, 300, 200, 100]) == 2\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maxOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxOperations(vector& nums) {", "container": "Solution", "callable": "maxOperations", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3041, "task_id": "maximize-consecutive-elements-in-an-array-after-modification", "difficulty": "Hard", "problem_description": "You are given a 0-indexed array nums consisting of positive integers.\nInitially, you can increase the value of any element in the array by at most 1.\nAfter that, you need to select one or more elements from the final array such that those elements are consecutive when sorted in increasing order. For example, the elements [3, 4, 5] are consecutive while [3, 4, 6] and [1, 1, 2, 3] are not.\nReturn the maximum number of elements that you can select.\n \nExample 1:\n\nInput: nums = [2,1,5,1,1]\nOutput: 3\nExplanation: We can increase the elements at indices 0 and 3. The resulting array is nums = [3,1,5,2,1].\nWe select the elements [3,1,5,2,1] and we sort them to obtain [1,2,3], which are consecutive.\nIt can be shown that we cannot select more than 3 consecutive elements.\nExample 2:\n\nInput: nums = [1,4,7,10]\nOutput: 1\nExplanation: The maximum consecutive elements that we can select is 1.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 1000000]) == 1\n assert candidate(nums = [2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == 5\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(nums = [1, 3, 5, 7, 9]) == 2\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996]) == 5\n assert candidate(nums = [1000000, 999999, 999998, 1, 2]) == 3\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 6\n assert candidate(nums = [5, 5, 5, 5, 5]) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 2\n assert candidate(nums = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5]) == 6\n assert candidate(nums = [1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [10, 9, 8, 7, 6]) == 5\n assert candidate(nums = [1, 4, 7, 10]) == 1\n assert candidate(nums = [1, 2, 3, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [1, 3, 5, 4, 7, 9, 8, 11, 13, 12]) == 6\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5]) == 6\n assert candidate(nums = [1, 1, 1, 1, 1]) == 2\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 5, 6]) == 7\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996]) == 5\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [2, 1, 5, 1, 1]) == 3\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 2\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 5]) == 6\n assert candidate(nums = [1, 2, 4, 6, 8, 10, 12, 14, 16, 18]) == 3\n assert candidate(nums = [1000000]) == 1\n assert candidate(nums = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41]) == 2\n assert candidate(nums = [1, 2, 2, 2, 2, 3, 4, 5, 5, 5, 6, 7, 8, 9, 9, 9, 10, 11, 12, 12, 12, 12, 13, 14, 15, 16, 16, 16, 17, 18, 19, 20, 20, 20, 20, 21, 22, 23, 24, 25, 25, 25, 25, 26, 27, 28, 29, 30]) == 31\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393, 196418]) == 4\n assert candidate(nums = [1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 3\n assert candidate(nums = [1, 2, 3, 6, 7, 8, 10, 11, 12, 15, 16, 17, 20, 21, 22, 23, 24, 25, 26]) == 7\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 1\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000]) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 2\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 2\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 26\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [1, 1000000, 2, 999999, 3, 999998, 4, 999997, 5, 999996, 6, 999995, 7, 999994, 8, 999993, 9, 999992, 10, 999991]) == 10\n assert candidate(nums = [100, 101, 102, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == 13\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == 100\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14]) == 15\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 2\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 6\n assert candidate(nums = [100000, 99999, 99998, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 9\n assert candidate(nums = [1000000, 1000000, 1000000, 999999, 999999, 999999, 999998, 999998, 999998, 999997, 999997, 999997]) == 5\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7]) == 8\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59]) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 2\n assert candidate(nums = [1, 10, 11, 12, 20, 21, 22, 30, 31, 32, 40, 41, 42, 50, 51, 52, 60, 61, 62, 70, 71, 72, 80, 81, 82, 90, 91, 92]) == 3\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81]) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 30\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60]) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59]) == 2\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 5, 5, 6, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 11\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 3\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == 11\n assert candidate(nums = [10, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 12\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == 2\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7]) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 15\n assert candidate(nums = [1, 2, 3, 5, 6, 8, 9, 11, 12, 14, 15, 17, 18, 20, 21, 23, 24, 26, 27, 29, 30, 32, 33, 35, 36, 38, 39, 41, 42, 44, 45, 47, 48, 50, 51, 53, 54, 56, 57, 59, 60, 62, 63, 65, 66, 68, 69, 71, 72, 74, 75, 77, 78, 80, 81, 83, 84, 86, 87, 89, 90]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 40\n assert candidate(nums = [1, 2, 3, 5, 6, 8, 9, 11, 12, 14, 15, 17, 18, 20, 21, 23, 24, 26, 27, 29]) == 5\n assert candidate(nums = [3, 1, 2, 4, 6, 5, 7, 9, 8, 10, 12, 11, 13, 15, 14, 16, 18, 17, 19, 20]) == 20\n assert candidate(nums = [5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11]) == 8\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 22\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4]) == 5\n assert candidate(nums = [1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20, 22, 23]) == 4\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 11\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 11\n assert candidate(nums = [2, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37]) == 4\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(nums = [1, 1, 2, 3, 3, 3, 4, 4, 5, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 10]) == 11\n assert candidate(nums = [5, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7]) == 4\n assert candidate(nums = [100, 200, 101, 201, 102, 202, 103, 203, 104, 204, 105, 205]) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 17, 18, 19, 20, 22, 23, 24, 25]) == 14\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 40\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31]) == 20\n assert candidate(nums = [1, 2, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8]) == 9\n assert candidate(nums = [1, 10, 19, 28, 37, 46, 55, 64, 73, 82, 91, 100, 109, 118, 127, 136, 145, 154, 163, 172, 181, 190, 199]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 11\n assert candidate(nums = [1, 2, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60]) == 11\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10]) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 11\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == 1\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 30\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 5, 6, 7, 8, 8, 9, 10, 10, 11, 12, 12, 13, 14, 14]) == 15\n assert candidate(nums = [10, 2, 10, 10, 2, 3, 4, 5, 6, 7, 8, 9]) == 10\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12, 11, 13, 12, 14, 13, 15, 14, 16]) == 17\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55]) == 2\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 2\n assert candidate(nums = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000]) == 2\n assert candidate(nums = [100, 101, 102, 200, 201, 202, 300, 301, 302, 400, 401, 402, 500, 501, 502]) == 3\n assert candidate(nums = [1, 2, 3, 10, 11, 12, 20, 21, 22, 30, 31, 32, 40, 41, 42, 50, 51, 52, 60, 61, 62, 70, 71, 72, 80, 81, 82, 90, 91, 92, 93, 94, 95]) == 6\n assert candidate(nums = [1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 31\n assert candidate(nums = [2, 1, 5, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 31\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 41\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]) == 21\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 10\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, 2600, 2700, 2800, 2900, 3000, 3100, 3200, 3300, 3400, 3500, 3600, 3700, 3800, 3900, 4000, 4100, 4200, 4300, 4400, 4500, 4600, 4700, 4800, 4900, 5000]) == 1\n assert candidate(nums = [1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20, 22, 23]) == 4\n assert candidate(nums = [500000, 500001, 500002, 500003, 500004, 500005, 500006, 500007, 500008, 500009, 500010]) == 11\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 5, 5, 6, 7, 8, 9, 9, 10, 10, 10, 10, 11, 12, 13]) == 14\n assert candidate(nums = [5, 1, 3, 2, 4, 6, 8, 7, 9, 10, 12, 11, 14, 13, 15, 17, 16, 18, 20, 19, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 30\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 21, 20, 23, 22, 25, 24, 27, 26, 29, 28]) == 29\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == 20\n assert candidate(nums = [5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9]) == 6\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8]) == 9\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4]) == 5\n assert candidate(nums = [1, 2, 3, 3, 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 6, 6, 7, 8, 9, 10]) == 11\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 2\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 1\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996, 1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210, 231, 253, 276, 300, 325, 351, 378, 406, 435, 465, 496, 528, 561, 595, 630, 666, 703, 741, 780, 820, 861, 903, 946, 990]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 11, 11, 12, 12, 12, 13, 13, 14, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20]) == 21\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990, 999989, 999988, 999987, 999986, 999985, 999984, 999983, 999982, 999981]) == 20\n assert candidate(nums = [1, 3, 2, 4, 6, 5, 7, 8, 10, 9, 11, 12, 14, 13, 15, 16, 18, 17, 19, 20]) == 20\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(nums = [1, 2, 3, 5, 6, 7, 9, 10, 11, 13, 14, 15, 17, 18, 19, 21, 22, 23]) == 6\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991]) == 10\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 2\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 16\n assert candidate(nums = [1, 1, 1, 2, 3, 4, 5, 5, 5, 6, 7, 8, 8, 8, 9, 10, 11, 11, 11, 12, 13, 14, 14, 14, 15, 16, 17, 17, 17]) == 18\n assert candidate(nums = [5, 3, 1, 4, 2, 6, 8, 7, 9, 10, 12, 11]) == 12\n assert candidate(nums = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]) == 20\n assert candidate(nums = [1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38]) == 3\n assert candidate(nums = [10, 21, 32, 43, 54, 65, 76, 87, 98, 109]) == 1\n assert candidate(nums = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80]) == 31\n assert candidate(nums = [1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20]) == 4\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maxSelectedElements", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxSelectedElements(vector& nums) {", "container": "Solution", "callable": "maxSelectedElements", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3042, "task_id": "count-prefix-and-suffix-pairs-i", "difficulty": "Easy", "problem_description": "You are given a 0-indexed string array words.\nLet's define a boolean function isPrefixAndSuffix that takes two strings, str1 and str2:\n\nisPrefixAndSuffix(str1, str2) returns true if str1 is both a prefix and a suffix of str2, and false otherwise.\n\nFor example, isPrefixAndSuffix(\"aba\", \"ababa\") is true because \"aba\" is a prefix of \"ababa\" and also a suffix, but isPrefixAndSuffix(\"abc\", \"abcd\") is false.\nReturn an integer denoting the number of index pairs (i, j) such that i < j, and isPrefixAndSuffix(words[i], words[j]) is true.\n \nExample 1:\n\nInput: words = [\"a\",\"aba\",\"ababa\",\"aa\"]\nOutput: 4\nExplanation: In this example, the counted index pairs are:\ni = 0 and j = 1 because isPrefixAndSuffix(\"a\", \"aba\") is true.\ni = 0 and j = 2 because isPrefixAndSuffix(\"a\", \"ababa\") is true.\ni = 0 and j = 3 because isPrefixAndSuffix(\"a\", \"aa\") is true.\ni = 1 and j = 2 because isPrefixAndSuffix(\"aba\", \"ababa\") is true.\nTherefore, the answer is 4.\nExample 2:\n\nInput: words = [\"pa\",\"papa\",\"ma\",\"mama\"]\nOutput: 2\nExplanation: In this example, the counted index pairs are:\ni = 0 and j = 1 because isPrefixAndSuffix(\"pa\", \"papa\") is true.\ni = 2 and j = 3 because isPrefixAndSuffix(\"ma\", \"mama\") is true.\nTherefore, the answer is 2. \nExample 3:\n\nInput: words = [\"abab\",\"ab\"]\nOutput: 0\nExplanation: In this example, the only valid index pair is i = 0 and j = 1, and isPrefixAndSuffix(\"abab\", \"ab\") is false.\nTherefore, the answer is 0.\n \nConstraints:\n\n1 <= words.length <= 50\n1 <= words[i].length <= 10\nwords[i] consists only of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(words = ['abc', 'abcabc', 'bc', 'abcabcabc']) == 3\n assert candidate(words = ['xyz', 'xyzxyz', 'zyx', 'z', 'x']) == 1\n assert candidate(words = ['hello', 'hellohello', 'hellohellohello']) == 3\n assert candidate(words = ['z', 'zaz', 'zzz', 'zazaz']) == 4\n assert candidate(words = ['aaa', 'aaaa', 'aaaaa', 'aa', 'a']) == 3\n assert candidate(words = ['cat', 'tac', 'catcat', 'tacatc']) == 1\n assert candidate(words = ['prefix', 'prefixprefix', 'fixpre', 'refixpre']) == 1\n assert candidate(words = ['repeat', 'repeattorepeat', 'eat', 'eateateat']) == 2\n assert candidate(words = ['suffix', 'suffixsuffix', 'fixsuf', 'ffixsuf']) == 1\n assert candidate(words = ['pa', 'papa', 'ma', 'mama']) == 2\n assert candidate(words = ['m', 'mnm', 'nmn', 'mnmnm']) == 3\n assert candidate(words = ['test', 'testing', 'testtest', 'sett']) == 1\n assert candidate(words = ['y', 'yxy', 'xyx', 'yxyxy']) == 3\n assert candidate(words = ['hello', 'hellohello', 'world', 'worldworld']) == 2\n assert candidate(words = ['x', 'xx', 'xxx', 'xxxx']) == 6\n assert candidate(words = ['z', 'zzz', 'zzzzz', 'zzzzzzz']) == 6\n assert candidate(words = ['dog', 'dogcat', 'dogcatdog']) == 1\n assert candidate(words = ['a', 'aba', 'ababa', 'aa']) == 4\n assert candidate(words = ['t', 'tt', 'ttt', 'tttt', 'ttttt', 'tttttt']) == 15\n assert candidate(words = ['aabb', 'aabbcc', 'aabbccaabb']) == 1\n assert candidate(words = ['abc', 'abcabc', 'ab', 'a']) == 1\n assert candidate(words = ['z', 'zzz', 'zzzz', 'zzzzz']) == 6\n assert candidate(words = ['abab', 'ab']) == 0\n assert candidate(words = ['x', 'xx', 'xxx', 'xxxx']) == 6\n assert candidate(words = ['s', 'ss', 'sss', 'ssss', 'sssss']) == 10\n assert candidate(words = ['a', 'b', 'c', 'd']) == 0\n assert candidate(words = ['hello', 'hellohello', 'lohel', 'ohelloh']) == 1\n assert candidate(words = ['test', 'testtest', 'sttes', 'ttest']) == 1\n assert candidate(words = ['abc', 'abcabc', 'abcabcabc']) == 3\n assert candidate(words = ['abc', 'abcabc', 'bcb', 'bcbcbcb']) == 2\n assert candidate(words = ['xy', 'xyxy', 'yxyx', 'xyxyxy', 'yxyxyx', 'xyxyxyxy', 'yxyxyxyx', 'xyxyxyxyxy']) == 13\n assert candidate(words = ['abc', 'cab', 'bac', 'abcabc', 'abcabcabc', 'cababcabc', 'bacbacbac']) == 4\n assert candidate(words = ['abab', 'baba', 'ab', 'ba', 'aba', 'bab', 'ababab', 'bababa', 'abababa', 'bababab', 'abababab', 'babababa']) == 12\n assert candidate(words = ['ab', 'baba', 'abab', 'bababa', 'ababab', 'babababa', 'abababab', 'bababababa']) == 12\n assert candidate(words = ['abab', 'baba', 'ababa', 'babab', 'ababab', 'bababa', 'abababa', 'bababab', 'abababab', 'babababa']) == 8\n assert candidate(words = ['noon', 'noonnoon', 'noonnoonnoon', 'noonoonoonnoon', 'noonnoonnoonnoon']) == 7\n assert candidate(words = ['aabb', 'bbaa', 'aabbcc', 'ccaabb', 'aabbccaabb', 'bbaaabbbaa', 'ccaabbaacc']) == 2\n assert candidate(words = ['aaaaa', 'baaaaa', 'caaaaa', 'daaaaa', 'eaaaaa', 'faaaaa', 'baaaaaa', 'caaaaaa']) == 0\n assert candidate(words = ['z', 'zz', 'zzz', 'zzzz', 'zzzzz', 'zzzzzz', 'zzzzzzz']) == 21\n assert candidate(words = ['aabb', 'aabbcc', 'aabbccaabb', 'aabbccaabbcc', 'aabbccaabbccaabb', 'aabbccaabbccaabbcc']) == 6\n assert candidate(words = ['abcde', 'abcdeabcde', 'bcdeabcde', 'cdeabcde', 'deabcde', 'eabcde', 'abcdeabcdeabcde']) == 3\n assert candidate(words = ['ababab', 'bababa', 'abab', 'baba', 'aba', 'ba', 'a', 'b', 'ab', 'ba', 'aba', 'bab', 'abb', 'bba']) == 4\n assert candidate(words = ['ab', 'abc', 'abcd', 'abcde', 'abcdef', 'abcdefg']) == 0\n assert candidate(words = ['abc', 'cab', 'bac', 'abcabc', 'bcabc', 'abcabcabc']) == 3\n assert candidate(words = ['aaaa', 'aaa', 'aa', 'a', 'abcabcabc', 'abcabc', 'abc', 'ab', 'a', 'abcabcabcabc', 'abcabcabcabcabcabcabc', 'abcabcabcabcabc', 'abcabcabcabcabcabcabcabcabc', 'abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc', 'abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc']) == 33\n assert candidate(words = ['pqr', 'pqrpqr', 'qrpqrpqr', 'rpqrpqrpqr', 'pqrpqrpqr', 'qrpqrpqr', 'rpqrpqrpqr', 'pqrpqrpqr']) == 8\n assert candidate(words = ['aba', 'abacaba', 'cabacabac', 'abcabcabc']) == 1\n assert candidate(words = ['abcabc', 'abc', 'abcabcabc', 'abca', 'abcb', 'abcab', 'abcabcab', 'a', 'aa', 'aaa']) == 6\n assert candidate(words = ['racecar', 'racecaracecar', 'car', 'racecaracecaracecar']) == 3\n assert candidate(words = ['xyz', 'xyzxyz', 'xyzxyzxyz', 'xyxzyx', 'xyzzyx']) == 3\n assert candidate(words = ['zzz', 'zzzz', 'zzzzz', 'zzzzzz', 'zzzzzzz', 'zzzzzzzz']) == 15\n assert candidate(words = ['aaaa', 'aaa', 'aa', 'a', 'aaaaaa', 'aaaaaaa', 'aaaaaaaa', 'aaaaaaaaa', 'aaaaaaaaaa', 'aaaaaab', 'aaaaaaab', 'aaaaaaaab']) == 30\n assert candidate(words = ['mama', 'mamama', 'mamamama', 'ma', 'm', 'mam', 'mamam', 'mamama', 'mamamam', 'mamamama']) == 17\n assert candidate(words = ['aaa', 'aaaa', 'aaaaa', 'aa', 'a', 'aaaaaa', 'aaaaaaa']) == 14\n assert candidate(words = ['test', 'testtest', 'tset', 'sett', 'sttest', 'testset']) == 1\n assert candidate(words = ['ababab', 'bababa', 'ab', 'aba', 'baba', 'bababab', 'bababa', 'abab', 'bab']) == 3\n assert candidate(words = ['repeat', 'peatre', 'eatrep', 'atrep', 'trepeat', 'peatpeatpeat']) == 0\n assert candidate(words = ['xyzzyx', 'zyxzyxzyx', 'xyzzyxzyxzyx', 'zyxzyxzyxzyxzyx', 'xyzzyxzyxzyxzyxzyx']) == 1\n assert candidate(words = ['abcd', 'dcba', 'cdab', 'abcdabcd', 'cdabcdcd', 'dcabcd', 'abcdabdc', 'abcdabcdabcd']) == 3\n assert candidate(words = ['mnop', 'mnopm', 'nopmnop', 'mnopm', 'mnopm', 'mnopmnopm', 'nopmnopm', 'mnopmnopm', 'mnopmnopmnop', 'mnopmnopmnopm', 'nopmnopmnopm']) == 17\n assert candidate(words = ['xyz', 'xyzyx', 'zyxzyxzyx', 'zxzyx', 'xyzxyzxyz', 'xyzzyxzyxzyx']) == 1\n assert candidate(words = ['hello', 'hellohello', 'hell', 'hellohellohello', 'lohel']) == 3\n assert candidate(words = ['mnop', 'opmnop', 'nopmnop', 'mnopmnop', 'opmnopmnop', 'nopmnopnop', 'mnopmnopmnop']) == 4\n assert candidate(words = ['abcabc', 'abc', 'bcabc', 'abcabcabc', 'abcabca']) == 2\n assert candidate(words = ['pqr', 'pqrpqr', 'pqrpqrpqr', 'pqrpqrpqrpqr', 'pqrpqrpqrpqrpqr', 'pqrpqrpqrpqrpqrpqr', 'pqrpqrpqrpqrpqrpqrpqr']) == 21\n assert candidate(words = ['abcabcabc', 'bcabcabcab', 'cabcabcab', 'abcabc', 'bcabc', 'cabc', 'abc', 'bc', 'c']) == 0\n assert candidate(words = ['aaa', 'aaabaaa', 'baaabaaa', 'aaabaaba', 'abaabaaa', 'aaabaaba', 'baaabaaa']) == 3\n assert candidate(words = ['abcdabcd', 'abcd', 'abcde', 'abcdeabcd', 'abcdeabcde']) == 2\n assert candidate(words = ['hello', 'hellohello', 'hellohellohello', 'world', 'worldworld', 'worldworldworld']) == 6\n assert candidate(words = ['aaaa', 'aa', 'a', 'aaaaaa', 'aaa']) == 5\n assert candidate(words = ['abcd', 'abcdabcd', 'abcdabcdabcd', 'abcdabcdabcdabcd', 'abcdabcdabcdabcdabcd']) == 10\n assert candidate(words = ['xyz', 'xyzxyz', 'xyzxyzxyz', 'xy']) == 3\n assert candidate(words = ['a', 'aa', 'aaa', 'aaaa', 'aaaaa']) == 10\n assert candidate(words = ['same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same']) == 45\n assert candidate(words = ['aaa', 'aaaa', 'aaaaa', 'aaaaaa', 'aaaaaaa', 'aaaaaaaa', 'aaaaaaaaa']) == 21\n assert candidate(words = ['aaaa', 'aa', 'a', 'aaaaaa', 'aaa', 'aaaaaaa']) == 10\n assert candidate(words = ['xyz', 'xyzxyz', 'xyzxyzxyz', 'xy', 'xyxy', 'xyxyxy']) == 6\n assert candidate(words = ['abcd', 'cdabcd', 'abcdabcd', 'abcdabcdabcd', 'dabcdabcd']) == 3\n assert candidate(words = ['zzz', 'zzzz', 'zzzzz', 'zzzzzz', 'zzzzzzz', 'zzzzzzzz', 'zzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzzzz', 'zzzzzzzzzzzz', 'zzzzzzzzzzzzz']) == 55\n assert candidate(words = ['aabbcc', 'aabb', 'cc', 'aabbccaabbcc', 'aabbccaa', 'bbccaa']) == 1\n assert candidate(words = ['ab', 'abcba', 'abcabcba', 'a', 'aba', 'abababa']) == 3\n assert candidate(words = ['abacaba', 'aba', 'abacababa', 'a']) == 1\n assert candidate(words = ['xyz', 'xyzyx', 'xyzxyz', 'xyzxyzyx', 'xyzxyzyxyz']) == 2\n assert candidate(words = ['level', 'levellevel', 'levellevellevel', 'llevevllevevllevell']) == 3\n assert candidate(words = ['xyxy', 'yxyx', 'xyxyxy', 'yxyxyx', 'xyxyxyxy', 'yxyxyxyx', 'xyxyxyxyxy', 'yxyxyxyxyx']) == 12\n assert candidate(words = ['ab', 'aba', 'abab', 'ababa', 'abababa', 'ababababa', 'abababababa', 'ababababababa', 'abababababababa', 'ababababababababa', 'abababababababababa']) == 37\n assert candidate(words = ['xyz', 'xyzxyz', 'zyxzyx', 'xyzzyxxyz', 'xyz']) == 3\n assert candidate(words = ['aaa', 'aaaa', 'aaaaa', 'aaaaaa']) == 6\n assert candidate(words = ['abc', 'cab', 'bac', 'abcabc', 'abcabcabc', 'abcabcabcabc']) == 6\n assert candidate(words = ['abcabc', 'abc', 'abcabcabc', 'a', 'aa', 'aaa', 'aaaa']) == 8\n assert candidate(words = ['aaa', 'aa', 'a', 'aaaa', 'aaaaa']) == 7\n assert candidate(words = ['ab', 'abc', 'ababc', 'abcababc']) == 1\n assert candidate(words = ['p', 'pp', 'ppp', 'pppp', 'ppppp', 'pppppp', 'ppppppp']) == 21\n assert candidate(words = ['xyz', 'xyzyx', 'xyzxyz', 'zyxzyxzyx']) == 1\n assert candidate(words = ['zzz', 'zzzz', 'zz', 'z', 'zzzzz', 'zzzzzz', 'zzzzzzz', 'zzzzzzzz', 'zzzzzzzzz', 'zzzzzzzzzz']) == 40\n assert candidate(words = ['ab', 'aba', 'abab', 'ababa', 'ababab', 'abababa']) == 6\n assert candidate(words = ['deified', 'deifieddeified', 'deifieddeifieddeified', 'deifieddeifieddeifieddeified', 'deifieddeifieddeifieddeifieddeified']) == 10\n assert candidate(words = ['abcdabcd', 'abcdeabcde', 'abcdefabcdef', 'abcd', 'abcde', 'abcdef', 'abc', 'ab', 'a', 'ababab', 'abcabcabc']) == 2\n assert candidate(words = ['xyz', 'xyzxyz', 'xyzxyzxyz', 'xyx']) == 3\n assert candidate(words = ['pqr', 'pqrpqr', 'rpqrpqr', 'pqrpqrpqr', 'qpqrpqrpqr', 'pqrqpqrpqrpqr', 'pqrpqrpqrpqr', 'rpqrpqrpqrpqr', 'pqrpqrpqrpqrpqr', 'qpqrpqrpqrpqrpqr']) == 12\n assert candidate(words = ['abcd', 'abcdabcd', 'abcde', 'abcdeabcde', 'ab', 'abab', 'abc', 'abcabc', 'a', 'aaaa']) == 5\n assert candidate(words = ['xyz', 'xyzxyz', 'xyzxyzxyz', 'xyzxyzxyzxyz']) == 6\n assert candidate(words = ['abcd', 'abcdabcd', 'bcdabcde', 'cdabcde', 'dabcde', 'abcde']) == 1\n assert candidate(words = ['mnop', 'nopm', 'opmn', 'pqrs', 'rspq', 'srpq', 'qpsr', 'mnopmnop', 'nopmnopm', 'opmnopno']) == 2\n assert candidate(words = ['x', 'xx', 'xxx', 'xxxx', 'xxxxx', 'xxxxxx', 'xxxxxxx', 'xxxxxxxx', 'xxxxxxxxx', 'xxxxxxxxxx']) == 45\n assert candidate(words = ['hello', 'hellohello', 'hellohellohello', 'hellohellohellohello', 'hellohellohellohellohello']) == 10\n assert candidate(words = ['radar', 'radarradar', 'radarradarradar', 'radarradarradarradar', 'radarradarradarradarradar']) == 10\n assert candidate(words = ['pqr', 'pqrpqr', 'pq', 'pqpq', 'prq', 'prqprq', 'pr', 'prpr', 'qpr', 'qprqpr']) == 5\n assert candidate(words = ['a', 'aa', 'aaa', 'aaaa', 'aaaaa', 'aaaaaa', 'aaaaaaa', 'aaaaaaaa']) == 28\n assert candidate(words = ['abc', 'bac', 'cab', 'abcabc', 'bacbac', 'cabcab', 'abcabca', 'bcabcabc', 'cababcab', 'abcabcabca']) == 5\n assert candidate(words = ['abc', 'abca', 'abcabc', 'cabcabc']) == 1\n assert candidate(words = ['abcabc', 'abc', 'abcabcabcabc', 'abcabcabc', 'abcabcabcabcabcabc']) == 8\n assert candidate(words = ['rotor', 'rotorrotor', 'rotorrotorrotor', 'torotorotor']) == 3\n assert candidate(words = ['abcd', 'bcde', 'cdef', 'defg', 'efgh', 'fghi', 'ghij', 'hijk', 'ijkl', 'jklm', 'klmn', 'lmno', 'mnop']) == 0\n assert candidate(words = ['aabb', 'bbaa', 'aabbcc', 'ccbaab', 'aabbccbaab']) == 0\n assert candidate(words = ['a', 'aa', 'aaa', 'aaaa', 'aaaaa', 'aaaaaa']) == 15\n assert candidate(words = ['ababab', 'ab', 'abab', 'abababab', 'baba', 'abababa']) == 4\n assert candidate(words = ['xy', 'xyxy', 'xyxyxy', 'xyxyxyxy', 'xyxyxyxyxy']) == 10\n assert candidate(words = ['banana', 'ban', 'banana', 'nan', 'banananan', 'ananan']) == 1\n"}, "metadata": {"canonical_parameter_names": ["words"], "leetcode_dataset_entry_point": "Solution().countPrefixSuffixPairs", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int countPrefixSuffixPairs(vector& words) {", "container": "Solution", "callable": "countPrefixSuffixPairs", "parameters": [{"name": "words", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3043, "task_id": "find-the-length-of-the-longest-common-prefix", "difficulty": "Medium", "problem_description": "You are given two arrays with positive integers arr1 and arr2.\nA prefix of a positive integer is an integer formed by one or more of its digits, starting from its leftmost digit. For example, 123 is a prefix of the integer 12345, while 234 is not.\nA common prefix of two integers a and b is an integer c, such that c is a prefix of both a and b. For example, 5655359 and 56554 have common prefixes 565 and 5655 while 1223 and 43456 do not have a common prefix.\nYou need to find the length of the longest common prefix between all pairs of integers (x, y) such that x belongs to arr1 and y belongs to arr2.\nReturn the length of the longest common prefix among all pairs. If no common prefix exists among them, return 0.\n \nExample 1:\n\nInput: arr1 = [1,10,100], arr2 = [1000]\nOutput: 3\nExplanation: There are 3 pairs (arr1[i], arr2[j]):\n- The longest common prefix of (1, 1000) is 1.\n- The longest common prefix of (10, 1000) is 10.\n- The longest common prefix of (100, 1000) is 100.\nThe longest common prefix is 100 with a length of 3.\n\nExample 2:\n\nInput: arr1 = [1,2,3], arr2 = [4,4,4]\nOutput: 0\nExplanation: There exists no common prefix for any pair (arr1[i], arr2[j]), hence we return 0.\nNote that common prefixes between elements of the same array do not count.\n\n \nConstraints:\n\n1 <= arr1.length, arr2.length <= 5 * 104\n1 <= arr1[i], arr2[i] <= 108\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr1 = [100000, 99999, 88888],arr2 = [10000, 9999, 8888]) == 5\n assert candidate(arr1 = [1, 10, 100, 1000],arr2 = [1000, 10000, 100000]) == 4\n assert candidate(arr1 = [1, 1, 1],arr2 = [1, 1, 1]) == 1\n assert candidate(arr1 = [100000000],arr2 = [10000000, 1000000, 100000]) == 8\n assert candidate(arr1 = [123, 456, 789],arr2 = [12345, 45678, 78901]) == 3\n assert candidate(arr1 = [1, 2, 3],arr2 = [4, 4, 4]) == 0\n assert candidate(arr1 = [1],arr2 = [2]) == 0\n assert candidate(arr1 = [10, 20, 30],arr2 = [100, 200, 300]) == 2\n assert candidate(arr1 = [5, 55, 555],arr2 = [5, 50, 55]) == 2\n assert candidate(arr1 = [987654321],arr2 = [987654321, 98765432, 987654]) == 9\n assert candidate(arr1 = [5678, 567, 56],arr2 = [56789, 56780, 5670]) == 4\n assert candidate(arr1 = [1],arr2 = [10, 100, 1000]) == 1\n assert candidate(arr1 = [5655359, 56554],arr2 = [565, 5655]) == 4\n assert candidate(arr1 = [1, 11, 111],arr2 = [111, 11, 1]) == 3\n assert candidate(arr1 = [123, 12, 1],arr2 = [1234, 12, 123]) == 3\n assert candidate(arr1 = [111, 222, 333],arr2 = [1111, 2222, 3333]) == 3\n assert candidate(arr1 = [123456789],arr2 = [987654321]) == 0\n assert candidate(arr1 = [123, 456, 789],arr2 = [1234, 4567, 7890]) == 3\n assert candidate(arr1 = [987654321],arr2 = [9876543210]) == 9\n assert candidate(arr1 = [1234, 123, 12],arr2 = [12345, 1230, 120]) == 4\n assert candidate(arr1 = [12345, 67890, 1234],arr2 = [123456, 1234, 112233]) == 5\n assert candidate(arr1 = [1, 10, 100],arr2 = [1000]) == 3\n assert candidate(arr1 = [100, 200, 300],arr2 = [100, 200, 300]) == 3\n assert candidate(arr1 = [123456789, 987654321],arr2 = [1234567890, 9876543210, 123456789, 987654321]) == 9\n assert candidate(arr1 = [101010101, 202020202, 303030303],arr2 = [1010101010, 2020202020, 3030303030]) == 9\n assert candidate(arr1 = [1234567, 123456, 12345, 1234, 123],arr2 = [12345678, 1234567, 123456, 12345, 1234]) == 7\n assert candidate(arr1 = [111111, 222222, 333333],arr2 = [1111111, 2222222, 3333333, 111111, 222222, 333333]) == 6\n assert candidate(arr1 = [56789012, 98765432, 12345678, 87654321],arr2 = [567890123, 987654321, 123456789, 876543210]) == 8\n assert candidate(arr1 = [1, 101, 1001, 10001],arr2 = [10, 100, 1000, 10000]) == 4\n assert candidate(arr1 = [888888, 777777, 666666, 555555],arr2 = [8888888, 7777777, 6666666, 5555555, 8888880, 7777770, 6666660, 5555550]) == 6\n assert candidate(arr1 = [12345678, 87654321, 11223344],arr2 = [123456789, 876543210, 112233445, 12345678, 87654321, 11223344]) == 8\n assert candidate(arr1 = [12345678, 87654321, 135792468, 246813579],arr2 = [123456789, 876543210, 1357924680, 2468135790]) == 9\n assert candidate(arr1 = [111, 222, 333, 444, 555],arr2 = [111111111, 222222222, 333333333, 444444444, 555555555]) == 3\n assert candidate(arr1 = [12345, 54321, 67890, 98765],arr2 = [123456, 654321, 678901, 567890]) == 5\n assert candidate(arr1 = [123456789, 987654321, 1122334455],arr2 = [1234567890, 9876543210, 112233445566]) == 10\n assert candidate(arr1 = [99999999, 88888888, 77777777],arr2 = [999999999, 888888888, 777777777]) == 8\n assert candidate(arr1 = [100000000, 200000000, 300000000],arr2 = [1000000000, 2000000000, 3000000000]) == 9\n assert candidate(arr1 = [1, 10, 100, 1000, 10000],arr2 = [1, 10, 100, 1000, 10000, 100000]) == 5\n assert candidate(arr1 = [987654, 876543, 765432, 654321],arr2 = [987654321, 876543210, 765432109, 654321098]) == 6\n assert candidate(arr1 = [111111111, 222222222, 333333333],arr2 = [1111111111, 2222222222, 3333333333]) == 9\n assert candidate(arr1 = [123456789, 987654321],arr2 = [1234567890, 9876543210]) == 9\n assert candidate(arr1 = [12345, 54321, 13579],arr2 = [123456, 543210, 135790]) == 5\n assert candidate(arr1 = [1, 10, 100, 1000, 10000],arr2 = [10000, 1000, 100, 10, 1]) == 5\n assert candidate(arr1 = [101010, 202020, 303030, 404040],arr2 = [101010101, 202020202, 303030303, 404040404]) == 6\n assert candidate(arr1 = [1001, 2002, 3003, 4004],arr2 = [10010, 20020, 30030, 40040]) == 4\n assert candidate(arr1 = [5, 55, 555, 5555, 55555],arr2 = [555555, 555550, 55550, 5550, 550]) == 5\n assert candidate(arr1 = [123456, 654321, 234567],arr2 = [1234567, 6543217, 2345678]) == 6\n assert candidate(arr1 = [11111111, 22222222, 33333333],arr2 = [111111111, 222222222, 333333333]) == 8\n assert candidate(arr1 = [987654321, 987654, 9876],arr2 = [9876543210, 9876540, 98760]) == 9\n assert candidate(arr1 = [1010, 10101, 101010, 1010101],arr2 = [10101010, 101010101, 1010101010, 10101010101]) == 7\n assert candidate(arr1 = [55555, 66666, 77777],arr2 = [555555, 666666, 777777]) == 5\n assert candidate(arr1 = [987654321, 123456789, 101010101],arr2 = [9876543210, 1234567890, 1010101010]) == 9\n assert candidate(arr1 = [123456, 654321, 111111, 222222],arr2 = [1234560, 6543210, 1111110, 2222220]) == 6\n assert candidate(arr1 = [1, 10, 100, 1000, 10000],arr2 = [10, 100, 1000, 10000, 100000]) == 5\n assert candidate(arr1 = [100000, 200000, 300000, 400000],arr2 = [1000001, 2000002, 3000003, 4000004]) == 6\n assert candidate(arr1 = [111111111, 222222222, 333333333],arr2 = [1111111110, 2222222220, 3333333330]) == 9\n assert candidate(arr1 = [1234, 4321, 1111, 2222],arr2 = [12345, 43210, 11111, 22222]) == 4\n assert candidate(arr1 = [987654321, 876543219, 765432198, 654321987],arr2 = [9876543210, 8765432190, 7654321980, 6543219870]) == 9\n assert candidate(arr1 = [12345, 23456, 34567],arr2 = [54321, 65432, 76543]) == 0\n assert candidate(arr1 = [123456789, 987654321, 1122334455],arr2 = [1234567890, 9876543210, 11223344550]) == 10\n assert candidate(arr1 = [99999, 888888, 7777777],arr2 = [999999, 8888888, 77777777]) == 7\n assert candidate(arr1 = [99999, 88888, 77777, 66666],arr2 = [999999, 888888, 777777, 666666]) == 5\n assert candidate(arr1 = [123456789, 987654321, 111222333],arr2 = [1234567890, 1112223334, 9876543210]) == 9\n assert candidate(arr1 = [987654321, 876543210, 765432109, 654321098],arr2 = [987654321, 876543210, 765432109, 654321098]) == 9\n assert candidate(arr1 = [100100100, 200200200, 300300300],arr2 = [1001001001, 2002002002, 3003003003]) == 9\n assert candidate(arr1 = [1, 10, 100, 1000],arr2 = [10000, 100000, 1000000]) == 4\n assert candidate(arr1 = [123123, 234234, 345345, 456456],arr2 = [123123123, 234234234, 345345345, 456456456]) == 6\n assert candidate(arr1 = [123456789, 987654321],arr2 = [123456789, 987654321]) == 9\n assert candidate(arr1 = [10101010, 20202020, 30303030],arr2 = [101010101, 202020202, 303030303]) == 8\n assert candidate(arr1 = [112233, 223344, 334455],arr2 = [11223311, 22334422, 33445533]) == 6\n assert candidate(arr1 = [1001001, 2002002, 3003003],arr2 = [10010010, 20020020, 30030030]) == 7\n assert candidate(arr1 = [1, 10, 100, 1000],arr2 = [10000, 1000, 100, 10]) == 4\n assert candidate(arr1 = [123456789, 987654321, 111222333],arr2 = [1234567890, 9876543210, 1112223330]) == 9\n assert candidate(arr1 = [55555555, 66666666, 77777777, 88888888],arr2 = [555555555, 666666666, 777777777, 888888888, 55555555, 66666666, 77777777, 88888888]) == 8\n assert candidate(arr1 = [12345678, 123456, 123],arr2 = [123456789, 1234567, 12]) == 8\n assert candidate(arr1 = [1001001, 1010101, 1101101],arr2 = [10010010, 10101010, 11011010]) == 7\n assert candidate(arr1 = [123456, 234567, 345678, 456789],arr2 = [123456789, 234567890, 345678901, 456789012]) == 6\n assert candidate(arr1 = [112233, 223344, 334455, 445566],arr2 = [112233112233, 223344223344, 334455334455, 445566445566]) == 6\n assert candidate(arr1 = [10101010, 1010101, 101010, 10101, 1010, 101, 10, 1],arr2 = [101010101, 101010100, 10101010, 1010101, 101010, 10101, 1010, 101, 10, 1]) == 8\n assert candidate(arr1 = [1111111, 22222222, 333333333],arr2 = [11111111, 222222222, 3333333333]) == 9\n assert candidate(arr1 = [10101010, 11001100, 11100011],arr2 = [101010101, 110011001, 111000111]) == 8\n assert candidate(arr1 = [9, 99, 999, 9999],arr2 = [99999, 999999, 9999999]) == 4\n assert candidate(arr1 = [10101010, 101010, 1010],arr2 = [101010101, 1010101, 101]) == 8\n assert candidate(arr1 = [123, 456, 789, 101112],arr2 = [123456, 456789, 789101, 10111213]) == 6\n assert candidate(arr1 = [987654321, 876543210, 765432109],arr2 = [9876543210, 8765432109, 7654321098]) == 9\n assert candidate(arr1 = [101010, 202020, 303030],arr2 = [1010101, 2020202, 3030303]) == 6\n assert candidate(arr1 = [9999999, 8888888, 7777777],arr2 = [99999999, 88888888, 77777777]) == 7\n assert candidate(arr1 = [1, 22, 333, 4444, 55555],arr2 = [10, 220, 3330, 44440, 555550]) == 5\n assert candidate(arr1 = [1010101010, 2020202020, 3030303030],arr2 = [10101010101, 20202020202, 30303030303]) == 10\n assert candidate(arr1 = [123456789, 987654321, 112233445],arr2 = [1234567890, 9876543210, 1122334450]) == 9\n assert candidate(arr1 = [111111, 222222, 333333, 444444],arr2 = [111111111, 222222222, 333333333, 444444444]) == 6\n assert candidate(arr1 = [54321, 12345, 55555],arr2 = [543210, 123450, 555550]) == 5\n assert candidate(arr1 = [1, 11, 111, 1111],arr2 = [11111, 111111, 1111111, 11111111]) == 4\n assert candidate(arr1 = [101010, 1010, 10],arr2 = [1010101, 10101, 101]) == 6\n assert candidate(arr1 = [1, 11, 111, 1111, 11111, 111111],arr2 = [10, 110, 1110, 11110, 111110, 1111110]) == 6\n assert candidate(arr1 = [111222333, 444555666, 777888999],arr2 = [1112223330, 4445556660, 7778889990, 111222333, 444555666, 777888999]) == 9\n assert candidate(arr1 = [11, 22, 33, 44, 55],arr2 = [111, 222, 333, 444, 555]) == 2\n assert candidate(arr1 = [123, 456, 789, 101112, 131415],arr2 = [1234, 4567, 7890, 10111213, 13141516]) == 6\n assert candidate(arr1 = [123, 456, 789],arr2 = [123123, 456456, 789789]) == 3\n assert candidate(arr1 = [1111111, 2222222, 3333333],arr2 = [11111111, 22222222, 33333333]) == 7\n assert candidate(arr1 = [99999999, 8888888, 777777, 66666, 5555],arr2 = [999999999, 88888888, 7777777, 666666, 55555]) == 8\n assert candidate(arr1 = [100000000, 200000000, 300000000],arr2 = [1000000001, 2000000002, 3000000003]) == 9\n assert candidate(arr1 = [98765432, 87654321, 76543210, 65432109, 54321098],arr2 = [987654321, 876543210, 765432109, 654321098, 543210987]) == 8\n assert candidate(arr1 = [123456, 12345, 1234, 123, 12, 1],arr2 = [1234567, 1234560, 123450, 12340, 1230, 120]) == 6\n assert candidate(arr1 = [1122334455, 2233445566, 3344556677],arr2 = [112233445566, 223344556677, 334455667788, 1122334455, 2233445566, 3344556677]) == 10\n assert candidate(arr1 = [12121212, 21212121, 34343434],arr2 = [121212120, 212121210, 343434340]) == 8\n assert candidate(arr1 = [987654321, 98765432, 9876543, 987654, 98765, 9876, 987, 98, 9],arr2 = [9876543210, 987654320, 98765430, 9876540, 987650, 98760, 9870, 980, 90]) == 9\n assert candidate(arr1 = [999, 888, 777, 666, 555, 444, 333, 222, 111],arr2 = [9999, 8888, 7777, 6666, 5555, 4444, 3333, 2222, 1111]) == 3\n assert candidate(arr1 = [987654321, 876543210, 765432109],arr2 = [9876543210, 8765432100, 7654321090]) == 9\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [5, 4, 3, 2, 1]) == 1\n assert candidate(arr1 = [123456789, 12345, 12],arr2 = [1234567890, 123450, 120]) == 9\n assert candidate(arr1 = [111111111, 222222222, 333333333],arr2 = [111111112, 222222223, 333333334]) == 8\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [10, 20, 30, 40, 50, 12, 21, 32, 43, 54]) == 1\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9],arr2 = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 1\n assert candidate(arr1 = [111, 222, 333, 444, 555],arr2 = [1111, 2222, 3333, 4444, 5555]) == 3\n assert candidate(arr1 = [123123, 234234, 345345, 456456],arr2 = [1231231, 2342342, 3453453, 4564564]) == 6\n assert candidate(arr1 = [111111111, 222222222, 333333333],arr2 = [11111111, 22222222, 33333333]) == 8\n assert candidate(arr1 = [555555555, 666666666, 777777777],arr2 = [5555555555, 6666666666, 7777777777]) == 9\n assert candidate(arr1 = [111111111, 222222222, 333333333],arr2 = [111111111, 222222222, 333333333]) == 9\n assert candidate(arr1 = [1, 11, 111, 1111],arr2 = [1, 11, 111, 1111, 11111, 111111]) == 4\n assert candidate(arr1 = [123456789, 987654321, 1122334455],arr2 = [1234567890, 1234567, 1122334]) == 9\n"}, "metadata": {"canonical_parameter_names": ["arr1", "arr2"], "leetcode_dataset_entry_point": "Solution().longestCommonPrefix", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int longestCommonPrefix(vector& arr1, vector& arr2) {", "container": "Solution", "callable": "longestCommonPrefix", "parameters": [{"name": "arr1", "type": "vector&"}, {"name": "arr2", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3044, "task_id": "most-frequent-prime", "difficulty": "Medium", "problem_description": "You are given a m x n 0-indexed 2D matrix mat. From every cell, you can create numbers in the following way:\n\nThere could be at most 8 paths from the cells namely: east, south-east, south, south-west, west, north-west, north, and north-east.\nSelect a path from them and append digits in this path to the number being formed by traveling in this direction.\nNote that numbers are generated at every step, for example, if the digits along the path are 1, 9, 1, then there will be three numbers generated along the way: 1, 19, 191.\n\nReturn the most frequent prime number greater than 10 out of all the numbers created by traversing the matrix or -1 if no such prime number exists. If there are multiple prime numbers with the highest frequency, then return the largest among them.\nNote: It is invalid to change the direction during the move.\n \nExample 1:\n \n\n\nInput: mat = [[1,1],[9,9],[1,1]]\nOutput: 19\nExplanation: \nFrom cell (0,0) there are 3 possible directions and the numbers greater than 10 which can be created in those directions are:\nEast: [11], South-East: [19], South: [19,191].\nNumbers greater than 10 created from the cell (0,1) in all possible directions are: [19,191,19,11].\nNumbers greater than 10 created from the cell (1,0) in all possible directions are: [99,91,91,91,91].\nNumbers greater than 10 created from the cell (1,1) in all possible directions are: [91,91,99,91,91].\nNumbers greater than 10 created from the cell (2,0) in all possible directions are: [11,19,191,19].\nNumbers greater than 10 created from the cell (2,1) in all possible directions are: [11,19,19,191].\nThe most frequent prime number among all the created numbers is 19.\nExample 2:\n\nInput: mat = [[7]]\nOutput: -1\nExplanation: The only number which can be formed is 7. It is a prime number however it is not greater than 10, so return -1.\nExample 3:\n\nInput: mat = [[9,7,8],[4,6,5],[2,8,6]]\nOutput: 97\nExplanation: \nNumbers greater than 10 created from the cell (0,0) in all possible directions are: [97,978,96,966,94,942].\nNumbers greater than 10 created from the cell (0,1) in all possible directions are: [78,75,76,768,74,79].\nNumbers greater than 10 created from the cell (0,2) in all possible directions are: [85,856,86,862,87,879].\nNumbers greater than 10 created from the cell (1,0) in all possible directions are: [46,465,48,42,49,47].\nNumbers greater than 10 created from the cell (1,1) in all possible directions are: [65,66,68,62,64,69,67,68].\nNumbers greater than 10 created from the cell (1,2) in all possible directions are: [56,58,56,564,57,58].\nNumbers greater than 10 created from the cell (2,0) in all possible directions are: [28,286,24,249,26,268].\nNumbers greater than 10 created from the cell (2,1) in all possible directions are: [86,82,84,86,867,85].\nNumbers greater than 10 created from the cell (2,2) in all possible directions are: [68,682,66,669,65,658].\nThe most frequent prime number among all the created numbers is 97.\n\n \nConstraints:\n\nm == mat.length\nn == mat[i].length\n1 <= m, n <= 6\n1 <= mat[i][j] <= 9\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(mat = [[7]]) == -1\n assert candidate(mat = [[1, 1], [9, 9], [1, 1]]) == 19\n assert candidate(mat = [[2, 3, 5], [3, 5, 7], [5, 7, 1]]) == 53\n assert candidate(mat = [[9, 7, 8], [4, 6, 5], [2, 8, 6]]) == 97\n assert candidate(mat = [[3, 3, 3], [3, 3, 3], [3, 3, 3]]) == -1\n assert candidate(mat = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 11\n assert candidate(mat = [[2, 3, 5], [7, 1, 1], [6, 4, 9]]) == 41\n assert candidate(mat = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 8, 7, 6], [5, 4, 3, 2]]) == 67\n assert candidate(mat = [[2, 3, 5], [7, 1, 4], [6, 9, 8]]) == 97\n assert candidate(mat = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 1, 2, 3]]) == 83\n assert candidate(mat = [[8, 1, 6, 3], [3, 5, 7, 8], [4, 9, 2, 4], [9, 5, 1, 8]]) == 59\n assert candidate(mat = [[1, 3, 5, 7, 9, 11, 13], [3, 5, 7, 9, 11, 13, 15], [5, 7, 9, 11, 13, 15, 17], [7, 9, 11, 13, 15, 17, 19], [9, 11, 13, 15, 17, 19, 21], [11, 13, 15, 17, 19, 21, 23], [13, 15, 17, 19, 21, 23, 25]]) == 163\n assert candidate(mat = [[3, 5, 7, 2], [9, 4, 6, 8], [1, 3, 7, 5], [2, 8, 4, 9]]) == 47\n assert candidate(mat = [[5, 7, 9, 11, 13, 17, 19, 23], [11, 5, 7, 9, 11, 13, 17, 19], [17, 11, 5, 7, 9, 11, 13, 17], [19, 17, 11, 5, 7, 9, 11, 13], [23, 19, 17, 11, 5, 7, 9, 11], [19, 23, 19, 17, 11, 5, 7, 9], [17, 19, 23, 19, 17, 11, 5, 7], [13, 17, 19, 23, 19, 17, 11, 5]]) == 181\n assert candidate(mat = [[3, 1, 4, 1, 5, 9], [2, 6, 5, 3, 5, 8], [9, 7, 9, 3, 2, 3], [8, 4, 6, 2, 6, 4], [3, 3, 8, 3, 2, 7], [9, 5, 0, 2, 8, 8]]) == 53\n assert candidate(mat = [[3, 7, 2, 5, 9], [8, 6, 4, 3, 1], [7, 5, 3, 2, 9], [6, 4, 2, 1, 8], [5, 3, 1, 9, 7]]) == 23\n assert candidate(mat = [[9, 8, 7, 6, 5, 4, 3, 2, 1], [8, 7, 6, 5, 4, 3, 2, 1, 9], [7, 6, 5, 4, 3, 2, 1, 9, 8], [6, 5, 4, 3, 2, 1, 9, 8, 7], [5, 4, 3, 2, 1, 9, 8, 7, 6], [4, 3, 2, 1, 9, 8, 7, 6, 5], [3, 2, 1, 9, 8, 7, 6, 5, 4], [2, 1, 9, 8, 7, 6, 5, 4, 3], [1, 9, 8, 7, 6, 5, 4, 3, 2]]) == 89\n assert candidate(mat = [[1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4], [5, 5, 5, 5, 5, 5], [6, 6, 6, 6, 6, 6]]) == 43\n assert candidate(mat = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 1, 2, 3], [4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 5, 6], [7, 8, 9, 1, 2, 3], [4, 5, 6, 7, 8, 9]]) == 89\n assert candidate(mat = [[7, 7, 7, 7, 7, 7, 7], [7, 7, 7, 7, 7, 7, 7], [7, 7, 7, 7, 7, 7, 7], [7, 7, 7, 7, 7, 7, 7], [7, 7, 7, 7, 7, 7, 7], [7, 7, 7, 7, 7, 7, 7], [7, 7, 7, 7, 7, 7, 7]]) == -1\n assert candidate(mat = [[2, 3, 5, 7, 11], [13, 17, 19, 23, 29], [31, 37, 41, 43, 47], [53, 59, 61, 67, 71], [73, 79, 83, 89, 97]]) == 818287\n assert candidate(mat = [[5, 9, 3, 8, 2, 7], [6, 1, 4, 5, 9, 3], [8, 4, 2, 6, 1, 5], [7, 3, 5, 8, 4, 2], [9, 6, 8, 7, 3, 1], [4, 2, 3, 9, 6, 5]]) == 83\n assert candidate(mat = [[7, 7, 7, 7, 7, 7], [7, 7, 7, 7, 7, 7], [7, 7, 7, 7, 7, 7], [7, 7, 7, 7, 7, 7], [7, 7, 7, 7, 7, 7], [7, 7, 7, 7, 7, 7]]) == -1\n assert candidate(mat = [[5, 3, 7, 9, 1, 5], [3, 1, 5, 7, 9, 3], [7, 9, 3, 1, 5, 7], [9, 1, 5, 3, 7, 9], [1, 5, 7, 9, 3, 1], [5, 7, 9, 3, 1, 5]]) == 97\n assert candidate(mat = [[5, 9, 3, 4, 6], [8, 2, 1, 7, 0], [4, 6, 5, 3, 8], [9, 1, 2, 4, 5], [7, 3, 6, 1, 9]]) == 61\n assert candidate(mat = [[1, 9, 3, 5, 7, 2], [8, 6, 4, 3, 5, 7], [9, 8, 7, 6, 5, 4], [3, 5, 7, 9, 8, 7], [4, 6, 8, 9, 7, 3], [2, 4, 6, 8, 0, 9]]) == 89\n assert candidate(mat = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [3, 6, 9, 12, 15, 18, 21, 24, 27, 30], [4, 8, 12, 16, 20, 24, 28, 32, 36, 40], [5, 10, 15, 20, 25, 30, 35, 40, 45, 50], [6, 12, 18, 24, 30, 36, 42, 48, 54, 60], [7, 14, 21, 28, 35, 42, 49, 56, 63, 70], [8, 16, 24, 32, 40, 48, 56, 64, 72, 80], [9, 18, 27, 36, 45, 54, 63, 72, 81, 90], [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]]) == 89\n assert candidate(mat = [[7, 3, 1, 3], [5, 9, 2, 6], [5, 3, 5, 8], [9, 7, 9, 3], [2, 3, 8, 4], [6, 2, 6, 4], [3, 3, 8, 3]]) == 23\n assert candidate(mat = [[2, 7, 3, 5, 8, 6], [1, 9, 4, 7, 2, 5], [8, 3, 6, 1, 9, 4], [7, 2, 5, 8, 3, 6], [9, 4, 7, 2, 5, 8], [6, 1, 9, 4, 7, 2]]) == 47\n assert candidate(mat = [[9, 8, 7, 6, 5, 4], [8, 7, 6, 5, 4, 3], [7, 6, 5, 4, 3, 2], [6, 5, 4, 3, 2, 1], [5, 4, 3, 2, 1, 0], [4, 3, 2, 1, 0, 9]]) == 43\n assert candidate(mat = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == 11\n assert candidate(mat = [[2, 3, 5, 7], [3, 5, 7, 2], [5, 7, 2, 3], [7, 2, 3, 5]]) == 53\n assert candidate(mat = [[1, 3, 2, 1, 1], [1, 9, 2, 1, 9], [1, 1, 2, 9, 1], [1, 9, 2, 1, 9], [1, 1, 1, 1, 1]]) == 11\n assert candidate(mat = [[2, 3, 5, 7, 9, 11, 13], [13, 2, 3, 5, 7, 9, 11], [11, 13, 2, 3, 5, 7, 9], [9, 11, 13, 2, 3, 5, 7], [7, 9, 11, 13, 2, 3, 5], [5, 7, 9, 11, 13, 2, 3], [3, 5, 7, 9, 11, 13, 2]]) == 101\n assert candidate(mat = [[7, 3, 1, 6, 8, 2], [5, 9, 4, 7, 1, 3], [6, 2, 8, 5, 3, 9], [1, 4, 7, 2, 8, 5], [3, 6, 9, 1, 4, 7], [8, 5, 2, 9, 7, 3]]) == 73\n assert candidate(mat = [[2, 3, 5, 7], [11, 13, 17, 19], [23, 29, 31, 37], [41, 43, 47, 53]]) == 58171\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 2, 4, 6, 8], [8, 6, 4, 2, 1, 3, 5, 7, 9], [5, 7, 9, 2, 4, 6, 8, 1, 3]]) == 43\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [9, 8, 7], [6, 5, 4], [3, 2, 1]]) == 89\n assert candidate(mat = [[9, 3, 7, 2, 5, 8], [1, 6, 4, 9, 2, 3], [7, 8, 6, 5, 1, 9], [3, 4, 1, 2, 8, 7], [5, 6, 9, 8, 7, 3], [2, 4, 7, 8, 6, 5]]) == 73\n assert candidate(mat = [[5, 3, 2, 8, 9, 4], [7, 1, 6, 5, 3, 2], [9, 8, 7, 6, 5, 4], [3, 2, 1, 8, 9, 7], [1, 2, 3, 4, 5, 6], [7, 8, 9, 1, 2, 3]]) == 23\n assert candidate(mat = [[3, 7, 2, 5, 9, 1], [6, 1, 8, 3, 4, 7], [5, 9, 2, 6, 8, 3], [4, 7, 3, 1, 5, 6], [9, 8, 7, 6, 5, 4], [2, 3, 4, 5, 6, 7]]) == 83\n assert candidate(mat = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 2], [8, 6, 4, 2, 0, 9], [7, 5, 3, 1, 5, 7], [9, 7, 5, 3, 2, 4]]) == 53\n assert candidate(mat = [[7, 7, 7], [7, 7, 7], [7, 7, 7], [7, 7, 7], [7, 7, 7]]) == -1\n assert candidate(mat = [[2, 3, 5, 7, 11, 13, 17, 19], [19, 17, 13, 11, 7, 5, 3, 2], [2, 3, 5, 7, 11, 13, 17, 19], [19, 17, 13, 11, 7, 5, 3, 2], [2, 3, 5, 7, 11, 13, 17, 19], [19, 17, 13, 11, 7, 5, 3, 2], [2, 3, 5, 7, 11, 13, 17, 19], [19, 17, 13, 11, 7, 5, 3, 2]]) == 193\n assert candidate(mat = [[7, 8, 9], [8, 9, 7], [9, 7, 8], [7, 8, 9], [8, 9, 7]]) == 97\n assert candidate(mat = [[5, 3, 7, 1, 9], [2, 6, 5, 3, 7], [8, 9, 2, 6, 5], [3, 7, 1, 9, 2], [6, 5, 3, 7, 1]]) == 73\n assert candidate(mat = [[1, 3, 5, 7, 9], [9, 7, 5, 3, 1], [1, 3, 5, 7, 9], [9, 7, 5, 3, 1], [1, 3, 5, 7, 9]]) == 53\n assert candidate(mat = [[2, 3, 5, 7, 11, 13], [17, 19, 23, 29, 31, 37], [41, 43, 47, 53, 59, 61], [67, 71, 73, 79, 83, 89], [97, 101, 103, 107, 109, 113], [127, 131, 137, 139, 149, 151]]) == 233\n assert candidate(mat = [[5, 3, 5, 9, 2, 8], [2, 4, 2, 8, 7, 7], [3, 7, 8, 6, 3, 8], [7, 3, 6, 2, 6, 2], [5, 8, 4, 3, 1, 6], [7, 1, 5, 6, 1, 9]]) == 73\n assert candidate(mat = [[9, 8, 7, 6, 5], [8, 7, 6, 5, 4], [7, 6, 5, 4, 3], [6, 5, 4, 3, 2], [5, 4, 3, 2, 1]]) == 67\n assert candidate(mat = [[8, 9, 9, 8, 9, 8], [9, 8, 8, 9, 8, 9], [9, 8, 9, 8, 9, 8], [8, 9, 8, 9, 8, 9], [9, 8, 9, 8, 9, 8], [8, 9, 8, 9, 8, 9]]) == 89\n assert candidate(mat = [[3, 2, 1, 5, 9, 4, 7, 8, 6], [6, 7, 8, 1, 3, 5, 9, 2, 4], [4, 5, 9, 6, 7, 8, 1, 3, 2], [2, 1, 4, 5, 6, 7, 8, 3, 9], [9, 6, 3, 2, 1, 4, 7, 8, 5]]) == 59\n assert candidate(mat = [[3, 1, 4, 1, 5], [9, 2, 6, 5, 3], [5, 8, 9, 7, 9], [3, 2, 3, 8, 4], [6, 2, 6, 4, 3]]) == 23\n assert candidate(mat = [[5, 9, 3, 7, 1], [2, 4, 6, 8, 3], [7, 1, 5, 9, 3], [3, 5, 7, 2, 4], [9, 1, 2, 6, 8]]) == 71\n assert candidate(mat = [[9, 8, 7, 6, 5, 4], [3, 2, 1, 0, 9, 8], [7, 6, 5, 4, 3, 2], [1, 0, 9, 8, 7, 6], [5, 4, 3, 2, 1, 0], [9, 8, 7, 6, 5, 4]]) == 83\n assert candidate(mat = [[9, 7, 3, 1, 8, 6], [2, 5, 9, 4, 7, 1], [3, 8, 1, 2, 5, 9], [1, 6, 7, 3, 8, 2], [9, 4, 2, 6, 7, 3], [5, 8, 3, 9, 2, 1]]) == 23\n assert candidate(mat = [[7, 3, 5, 2, 9], [8, 6, 4, 1, 7], [3, 2, 8, 6, 5], [4, 1, 9, 7, 3], [2, 8, 6, 4, 1]]) == 67\n assert candidate(mat = [[5, 3, 1], [3, 5, 3], [1, 3, 5]]) == 53\n assert candidate(mat = [[2, 3, 5, 7, 9, 1], [3, 5, 7, 9, 1, 2], [5, 7, 9, 1, 2, 3], [7, 9, 1, 2, 3, 5], [9, 1, 2, 3, 5, 7], [1, 2, 3, 5, 7, 9]]) == 97\n assert candidate(mat = [[9, 9, 9, 9, 9, 9], [9, 8, 8, 8, 8, 9], [9, 8, 7, 7, 8, 9], [9, 8, 7, 6, 7, 9], [9, 8, 7, 7, 8, 9], [9, 8, 8, 8, 8, 9]]) == 89\n assert candidate(mat = [[2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2]]) == -1\n assert candidate(mat = [[7, 9, 5, 8, 2], [6, 3, 1, 9, 4], [1, 6, 7, 4, 3], [9, 8, 3, 2, 5], [4, 5, 8, 7, 9]]) == 73\n assert candidate(mat = [[8, 3, 1, 7, 9, 2], [4, 6, 8, 3, 1, 5], [9, 7, 5, 3, 1, 7], [2, 4, 6, 8, 3, 1], [5, 9, 7, 5, 3, 1], [1, 7, 9, 2, 4, 6]]) == 31\n assert candidate(mat = [[2, 3, 5, 7, 11, 13, 17, 19, 23], [29, 31, 37, 41, 43, 47, 53, 59, 61], [67, 71, 73, 79, 83, 89, 97, 2, 3], [5, 7, 11, 13, 17, 19, 23, 29, 31], [37, 41, 43, 47, 53, 59, 61, 67, 71], [73, 79, 83, 89, 97, 2, 3, 5, 7], [11, 13, 17, 19, 23, 29, 31, 37, 41], [43, 47, 53, 59, 61, 67, 71, 73, 79], [83, 89, 97, 2, 3, 5, 7, 11, 13]]) == 809\n assert candidate(mat = [[7, 1, 2, 3, 4, 5], [6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6], [7, 8, 9, 1, 2, 3], [4, 5, 6, 7, 8, 9], [1, 1, 1, 1, 1, 1]]) == 11\n assert candidate(mat = [[7, 3, 8, 9, 5, 1], [4, 6, 2, 7, 3, 8], [9, 5, 1, 4, 6, 2], [7, 3, 8, 9, 5, 1], [4, 6, 2, 7, 3, 8], [9, 5, 1, 4, 6, 2]]) == 83\n assert candidate(mat = [[2, 2, 3, 3, 5, 5, 7, 7], [2, 3, 5, 7, 11, 13, 17, 19], [3, 5, 7, 11, 13, 17, 19, 23], [5, 7, 11, 13, 17, 19, 23, 29], [7, 11, 13, 17, 19, 23, 29, 31], [11, 13, 17, 19, 23, 29, 31, 37], [13, 17, 19, 23, 29, 31, 37, 41], [17, 19, 23, 29, 31, 37, 41, 43]]) == 2083\n assert candidate(mat = [[1, 3, 5, 7, 9, 11], [2, 4, 6, 8, 10, 12], [13, 15, 17, 19, 21, 23], [25, 27, 29, 31, 33, 35], [37, 39, 41, 43, 45, 47], [49, 51, 53, 55, 57, 59]]) == 1021\n assert candidate(mat = [[6, 6, 6, 6, 6, 6, 6], [6, 6, 6, 6, 6, 6, 6], [6, 6, 6, 6, 6, 6, 6], [6, 6, 6, 6, 6, 6, 6], [6, 6, 6, 6, 6, 6, 6]]) == -1\n assert candidate(mat = [[3, 2, 5, 7, 9], [7, 8, 5, 3, 1], [2, 6, 9, 4, 3], [5, 1, 8, 2, 6], [9, 7, 3, 5, 1]]) == 73\n assert candidate(mat = [[3, 5, 7, 2, 1], [5, 3, 5, 3, 5], [7, 5, 3, 5, 7], [2, 1, 5, 3, 5], [1, 2, 3, 5, 3]]) == 53\n assert candidate(mat = [[5, 3, 7, 1, 9, 2], [3, 1, 5, 7, 2, 9], [7, 9, 2, 3, 5, 1], [9, 2, 1, 5, 3, 7], [2, 1, 5, 3, 7, 9], [1, 5, 3, 7, 9, 2]]) == 53\n assert candidate(mat = [[2, 3, 5, 7, 11], [13, 17, 19, 23, 29], [29, 23, 19, 17, 13], [11, 7, 5, 3, 2], [2, 3, 5, 7, 11]]) == 53\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1]]) == 11\n assert candidate(mat = [[5, 2, 8, 3, 9], [1, 7, 4, 6, 2], [9, 3, 8, 5, 1], [4, 6, 2, 8, 3], [7, 5, 1, 9, 4]]) == 43\n assert candidate(mat = [[1, 3, 1, 3, 1], [3, 1, 3, 1, 3], [1, 3, 1, 3, 1], [3, 1, 3, 1, 3], [1, 3, 1, 3, 1]]) == 31\n assert candidate(mat = [[3, 7, 11, 13, 17], [19, 23, 29, 31, 37], [41, 43, 47, 53, 59], [61, 67, 71, 73, 79], [83, 89, 97, 101, 103]]) == 577\n assert candidate(mat = [[3, 7, 2, 5, 9, 1], [4, 6, 8, 3, 7, 2], [5, 9, 1, 4, 6, 8], [2, 5, 9, 1, 4, 6], [8, 3, 7, 2, 5, 9], [1, 4, 6, 8, 3, 7]]) == 59\n assert candidate(mat = [[2, 3, 5, 7, 11, 13, 17, 19, 23], [29, 31, 37, 41, 43, 47, 53, 59, 61], [67, 71, 73, 79, 83, 89, 97, 101, 103], [107, 109, 113, 127, 131, 137, 139, 149, 151], [157, 163, 167, 173, 179, 181, 191, 193, 197], [199, 211, 223, 227, 229, 233, 239, 241, 251], [257, 263, 269, 271, 277, 281, 283, 293, 307], [311, 313, 317, 331, 337, 347, 349, 353, 359], [367, 373, 379, 383, 389, 397, 401, 409, 419]]) == 187043\n assert candidate(mat = [[6, 7, 8, 9, 1], [2, 3, 4, 5, 6], [7, 8, 9, 1, 2], [3, 4, 5, 6, 7], [8, 9, 1, 2, 3]]) == 83\n assert candidate(mat = [[2, 2, 2, 2, 2], [3, 3, 3, 3, 3], [5, 5, 5, 5, 5], [7, 7, 7, 7, 7], [11, 11, 11, 11, 11]]) == 53\n"}, "metadata": {"canonical_parameter_names": ["mat"], "leetcode_dataset_entry_point": "Solution().mostFrequentPrime", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int mostFrequentPrime(vector>& mat) {", "container": "Solution", "callable": "mostFrequentPrime", "parameters": [{"name": "mat", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3045, "task_id": "count-prefix-and-suffix-pairs-ii", "difficulty": "Hard", "problem_description": "You are given a 0-indexed string array words.\nLet's define a boolean function isPrefixAndSuffix that takes two strings, str1 and str2:\n\nisPrefixAndSuffix(str1, str2) returns true if str1 is both a prefix and a suffix of str2, and false otherwise.\n\nFor example, isPrefixAndSuffix(\"aba\", \"ababa\") is true because \"aba\" is a prefix of \"ababa\" and also a suffix, but isPrefixAndSuffix(\"abc\", \"abcd\") is false.\nReturn an integer denoting the number of index pairs (i, j) such that i < j, and isPrefixAndSuffix(words[i], words[j]) is true.\n \nExample 1:\n\nInput: words = [\"a\",\"aba\",\"ababa\",\"aa\"]\nOutput: 4\nExplanation: In this example, the counted index pairs are:\ni = 0 and j = 1 because isPrefixAndSuffix(\"a\", \"aba\") is true.\ni = 0 and j = 2 because isPrefixAndSuffix(\"a\", \"ababa\") is true.\ni = 0 and j = 3 because isPrefixAndSuffix(\"a\", \"aa\") is true.\ni = 1 and j = 2 because isPrefixAndSuffix(\"aba\", \"ababa\") is true.\nTherefore, the answer is 4.\nExample 2:\n\nInput: words = [\"pa\",\"papa\",\"ma\",\"mama\"]\nOutput: 2\nExplanation: In this example, the counted index pairs are:\ni = 0 and j = 1 because isPrefixAndSuffix(\"pa\", \"papa\") is true.\ni = 2 and j = 3 because isPrefixAndSuffix(\"ma\", \"mama\") is true.\nTherefore, the answer is 2. \nExample 3:\n\nInput: words = [\"abab\",\"ab\"]\nOutput: 0\nExplanation: In this example, the only valid index pair is i = 0 and j = 1, and isPrefixAndSuffix(\"abab\", \"ab\") is false.\nTherefore, the answer is 0.\n \nConstraints:\n\n1 <= words.length <= 105\n1 <= words[i].length <= 105\nwords[i] consists only of lowercase English letters.\nThe sum of the lengths of all words[i] does not exceed 5 * 105.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(words = ['aaaa', 'aa', 'a']) == 0\n assert candidate(words = ['a', 'a', 'a', 'a', 'a']) == 10\n assert candidate(words = ['x', 'xx', 'xxx', 'xxxx']) == 6\n assert candidate(words = ['abab', 'ab']) == 0\n assert candidate(words = ['x', 'xx', 'xxx', 'xxxx', 'xxxxx']) == 10\n assert candidate(words = ['z', 'zz', 'zzz', 'zzzz', 'zzzzz', 'zzzzzz']) == 15\n assert candidate(words = ['hello', 'hellohello', 'hellohellohello', 'he']) == 3\n assert candidate(words = ['abc', 'abcabc', 'abcd', 'abcabcabc']) == 3\n assert candidate(words = ['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a']) == 45\n assert candidate(words = ['unique', 'uniqueword', 'uniquewordunique', 'uniq']) == 1\n assert candidate(words = ['abc', 'abcabc', 'abcabcabc']) == 3\n assert candidate(words = ['xyz', 'xyzxyz', 'zyxzyx']) == 1\n assert candidate(words = ['abcd', 'abcdeabcda', 'ab']) == 0\n assert candidate(words = ['a', 'aba', 'ababa', 'aa']) == 4\n assert candidate(words = ['pa', 'papa', 'ma', 'mama']) == 2\n assert candidate(words = ['test', 'testtest', 'testtesttest', 't']) == 3\n assert candidate(words = ['abc', 'abcabc', 'abcabcabc', 'a']) == 3\n assert candidate(words = ['pattern', 'patternpattern', 'patternpatternpattern', 'patternpatternpatternpattern']) == 6\n assert candidate(words = ['same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same']) == 45\n assert candidate(words = ['mississippi', 'issis', 'sis', 'issippi', 'iss', 'missi', 'ippi', 'pi', 'ssippi', 'mississipi', 'ississippiissippi']) == 0\n assert candidate(words = ['aaaabbbb', 'aaaabbbbcccc', 'aaaabbbbccccdddd', 'aaaabbbbccccddddaaaa', 'aa', 'bb', 'cc', 'dd']) == 0\n assert candidate(words = ['abcabcabc', 'abc', 'abcabc', 'ab', 'a', 'abcabcabcabcabc']) == 4\n assert candidate(words = ['ababab', 'abab', 'ab', 'a', 'babab', 'bab', 'b']) == 0\n assert candidate(words = ['xyzyxyzyx', 'xyzyx', 'zyxzyx', 'xyz', 'zyx', 'yzy', 'zyzy', 'yzyxyzyx', 'yzyxyzyxyzyxyzyx']) == 1\n assert candidate(words = ['repeat', 'repeatrepeat', 'repeatrepeatrepeat', 'peat', 'eat', 'at', 't', 'rep', 're', 'r', 'e', 'a', 'p', 'te']) == 3\n assert candidate(words = ['abcde', 'edcba', 'abcdeabcde', 'edcbaedcba', 'abcdeedcbaabcde']) == 3\n assert candidate(words = ['xyxyxy', 'xyxyxyxyxy', 'xyxyxyxyxyxyxy', 'xy', 'yx', 'x', 'y', 'xyxy', 'yxyx', 'xyyx', 'xxyx']) == 7\n assert candidate(words = ['prefixsuffix', 'prefixsuffixprefixsuffix', 'prefixsuffixprefixsuffixprefixsuffix']) == 3\n assert candidate(words = ['abcdeabcde', 'bcdeabcd', 'cdeabcde', 'deabcdec', 'eabcdabc', 'abcde', 'bcde', 'cde', 'de', 'e', 'abc', 'bcd', 'cde', 'def', 'efg', 'fgh', 'ghi', 'hij', 'ijk', 'jkl', 'klm', 'lmn', 'mno', 'nop', 'opq', 'pqr', 'qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyz']) == 1\n assert candidate(words = ['longwordlongword', 'longwordlongwordlongword', 'longword', 'word', 'long', 'wo', 'rd', 'ngwordlongword', 'wordlongwordlong', 'ngwordlongwordngwordlongword']) == 2\n assert candidate(words = ['abcdabcdabcd', 'abcdabcd', 'abcd', 'abc', 'ab', 'a', 'abcdabcdabcdabcdabcdabcd']) == 3\n assert candidate(words = ['pattern', 'ternpat', 'ternpatpat', 'pat', 'tern', 'patternpat', 'ternpattern', 'patterntern', 'ternpatternpat']) == 3\n assert candidate(words = ['abcdabcdabcdabcd', 'abcdabcdabcd', 'abcdabcd', 'abcd', 'abc', 'ab', 'a', 'b', 'c', 'd', 'abcdabcdabcdabcdabcdabcdabcdabcd', 'abcdabcdabcdabcdabcdabcdabcd', 'abcdabcdabcdabcdabcdabcd', 'abcdabcdabcdabcdabcd', 'abcdabcdabcdabcd', 'abcdabcdabcd', 'abcdabcd', 'abcd', 'abc', 'ab', 'a', 'b', 'c', 'd']) == 32\n assert candidate(words = ['aaaaa', 'aaa', 'aaaa', 'aaaaaa', 'aa']) == 4\n assert candidate(words = ['prefixsuffix', 'prefix', 'suffix', 'prefixprefix', 'suffixsuffix', 'pre', 'suf']) == 2\n assert candidate(words = ['xyxyxyxy', 'xyxy', 'xyxyxy', 'xy', 'x', 'xyxyxyxyxyxy']) == 5\n assert candidate(words = ['xyxyxyxyxy', 'xyxyxyxy', 'xyxyxy', 'xyxy', 'xy', 'x', 'y', 'xyxyxyxyxyxyxyxy', 'xyxyxyxyxyxyxyxyxyxyxy', 'xyxyxyxyxyxyxyxyxyxyxyxyxyxyxy', 'xyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy']) == 26\n assert candidate(words = ['complexwordcomplexword', 'complexword', 'complex', 'com', 'co', 'complexwordcomplexwordcomplexword']) == 2\n assert candidate(words = ['aaaa', 'aa', 'a', 'aaaaaaaaaaaa', 'aaaa']) == 6\n assert candidate(words = ['abcabcabc', 'abc', 'abcabc', 'ab', 'a', 'b', 'c']) == 1\n assert candidate(words = ['abcdabcd', 'abcd', 'cdab', 'dabc', 'bcda', 'cabd', 'bacd', 'abcdabcdabcd', 'abcdabcdabcdabcd', 'abcdabcdabcdabcdabcdabcdabcdabcd']) == 9\n assert candidate(words = ['abcabcabc', 'abcabc', 'abc', 'a', 'b', 'c', 'abcabcabcabc']) == 3\n assert candidate(words = ['longprefix', 'longprefixlongprefix', 'longprefixlongprefixlongprefix']) == 3\n assert candidate(words = ['abc', 'abcabc', 'abcabcabc', 'abcabcabcabc']) == 6\n assert candidate(words = ['abcabcabc', 'abcabc', 'abc', 'a', 'b', 'c']) == 0\n assert candidate(words = ['prefixsuffix', 'prefix', 'suffix', 'prefixsuffixprefixsuffix', 'prefixprefix', 'suffixsuffix', 'prefixsuffixprefix', 'suffixprefixsuffix']) == 5\n assert candidate(words = ['repeatedrepeated', 'repeated', 'repeatedrepeatedrepeated', 'repeatedrepeatedrepeatedrepeated', 'repeatedrepeatedrepeatedrepeatedrepeated', 'repeatedrepeatedrepeated', 'repeated', 'repeatedrepeatedrepeatedrepeatedrepeated']) == 20\n assert candidate(words = ['aaaa', 'aaab', 'aabb', 'abbb', 'bbbb', 'baaa', 'baab', 'babb', 'bbba', 'bbbb', 'abab', 'baba', 'abba', 'baab', 'abba', 'baab', 'abba', 'baab']) == 10\n assert candidate(words = ['abcd', 'abcdabcd', 'abcdabcdabcd', 'abcde', 'abcdeabcde']) == 4\n assert candidate(words = ['abacaba', 'abac', 'acaba', 'aba', 'ba', 'a', 'abacabaabacaba', 'abacabaabacabaabacaba']) == 7\n assert candidate(words = ['banana', 'anan', 'nana', 'anana', 'banana', 'bananaana', 'anana', 'ana', 'nana', 'banana']) == 5\n assert candidate(words = ['aabbcc', 'bbccdd', 'ccddaa', 'aabb', 'bbaa', 'ccdd', 'aabbccdd', 'ddccbb', 'bbccddaa', 'aabbccbbcc', 'ccddbbcc', 'bbccddcc', 'aabbccddccdd', 'ddccbbccbbcc']) == 0\n assert candidate(words = ['abcdabcdabcd', 'abcd', 'abc', 'ab', 'a', 'abcdabcd']) == 1\n assert candidate(words = ['aaaaaa', 'aaaaaaa', 'aaaaaaaa', 'aaaaaaaaa', 'aaaaaaaaaa']) == 10\n assert candidate(words = ['aabb', 'aabbaabb', 'aabbaabbaabb', 'aabbaabbaabbaabb', 'aabbaabbaabbaabbaabb', 'aabb', 'aabbaabb', 'aabbaabbaabb', 'aabbaabbaabbaabbaabb']) == 27\n assert candidate(words = ['abcabcabc', 'abcabc', 'abc', 'ab', 'a']) == 0\n assert candidate(words = ['a', 'aa', 'aaa', 'aaaa', 'aaaaa', 'aaaaaa']) == 15\n assert candidate(words = ['ababab', 'abab', 'aba', 'ab', 'a', 'abcabcabcabc']) == 0\n assert candidate(words = ['longwordlongword', 'longword', 'word', 'long', 'short', 'longwordlong', 'longwordshort']) == 1\n assert candidate(words = ['racecar', 'race', 'car', 'racecar', 'racecarcar', 'racecarcarcar']) == 1\n assert candidate(words = ['ababababab', 'babababa', 'abab', 'bab', 'ab', 'a', 'abababababababababab', 'abababababababababababababababababab']) == 7\n assert candidate(words = ['racecar', 'racecarracecar', 'racecarracecarracecar', 'racecarracecarracecarracecar', 'racecarracecarracecarracecarracecar', 'racecarracecarracecarracecarracecarracecar']) == 15\n assert candidate(words = ['repeated', 'repeatedrepeated', 'repeatedrepeatedrepeated']) == 3\n assert candidate(words = ['repeatrepeatrepeat', 'repeat', 'repeatrepeat', 'rep', 're', 'repeatrepeatrepeatrepeat']) == 4\n assert candidate(words = ['aaa', 'aaaa', 'aaaaa', 'aaaaaa', 'aaaaaaa', 'aaaaaaaa']) == 15\n assert candidate(words = ['repeatedrepeated', 'repeated', 'rep', 'eated', 'eat', 'eatereat', 'eatrepeat']) == 2\n assert candidate(words = ['palindromemordnilap', 'mordnilap', 'ordnil', 'rnil', 'nil', 'il', 'l', 'o', 'd', 'p', 'emordnilap']) == 0\n assert candidate(words = ['mixedcase', 'mixed', 'mix', 'edcase', 'edc', 'ase', 'asem', 'mixedcasemixed', 'mixedcasem', 'mixedcasease']) == 1\n assert candidate(words = ['same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same']) == 190\n"}, "metadata": {"canonical_parameter_names": ["words"], "leetcode_dataset_entry_point": "Solution().countPrefixSuffixPairs", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "long long countPrefixSuffixPairs(vector& words) {", "container": "Solution", "callable": "countPrefixSuffixPairs", "parameters": [{"name": "words", "type": "vector&"}], "return_type": "long long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3046, "task_id": "split-the-array", "difficulty": "Easy", "problem_description": "You are given an integer array nums of even length. You have to split the array into two parts nums1 and nums2 such that:\n\nnums1.length == nums2.length == nums.length / 2.\nnums1 should contain distinct elements.\nnums2 should also contain distinct elements.\n\nReturn true if it is possible to split the array, and false otherwise.\n \nExample 1:\n\nInput: nums = [1,1,2,2,3,4]\nOutput: true\nExplanation: One of the possible ways to split nums is nums1 = [1,2,3] and nums2 = [1,2,4].\n\nExample 2:\n\nInput: nums = [1,1,1,1]\nOutput: false\nExplanation: The only possible way to split nums is nums1 = [1,1] and nums2 = [1,1]. Both nums1 and nums2 do not contain distinct elements. Therefore, we return false.\n\n \nConstraints:\n\n1 <= nums.length <= 100\nnums.length % 2 == 0 \n1 <= nums[i] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [2, 2, 3, 3, 4, 4]) == True\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4]) == True\n assert candidate(nums = [1, 1, 1, 1]) == False\n assert candidate(nums = [50, 50, 50, 50]) == False\n assert candidate(nums = [1, 1, 2, 2, 3, 4]) == True\n assert candidate(nums = [1, 2, 2, 3, 4, 4]) == True\n assert candidate(nums = [1, 2, 2, 3, 3, 4]) == True\n assert candidate(nums = [5, 5, 6, 6, 7, 7, 8, 8]) == True\n assert candidate(nums = [1, 1, 2, 3, 4, 5]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 5]) == True\n assert candidate(nums = [5, 5, 6, 6, 7, 7]) == True\n assert candidate(nums = [1, 2, 1, 2, 3, 4]) == True\n assert candidate(nums = [2, 2, 2, 2, 3, 3]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6]) == True\n assert candidate(nums = [10, 20, 10, 20, 30, 30]) == True\n assert candidate(nums = [50, 50, 50, 50, 60, 60]) == False\n assert candidate(nums = [10, 10, 20, 20, 30, 30]) == True\n assert candidate(nums = [50, 50, 50, 50, 50, 50]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8]) == True\n assert candidate(nums = [1, 1, 2, 3, 4, 4]) == True\n assert candidate(nums = [1, 2, 1, 2, 3, 3]) == True\n assert candidate(nums = [99, 99, 100, 100, 98, 98]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2]) == False\n assert candidate(nums = [9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == True\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 5]) == False\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10]) == False\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == False\n assert candidate(nums = [1, 1, 2, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == False\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(nums = [7, 8, 8, 9, 10, 10, 11, 11, 12, 12, 13, 13]) == True\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 8, 8, 9, 9]) == False\n assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50, 60, 60, 70, 70, 80, 80, 90, 90, 100, 100]) == True\n assert candidate(nums = [1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 7, 8, 9, 10]) == True\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 4, 5, 6, 7, 8, 9]) == False\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 5, 6, 6]) == True\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == False\n assert candidate(nums = [1, 1, 2, 2, 2, 2, 3, 3, 4, 4, 5, 5]) == False\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == True\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(nums = [17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == True\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1, 1]) == False\n assert candidate(nums = [7, 7, 8, 8, 8, 8, 9, 9, 10, 10]) == False\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == True\n assert candidate(nums = [1, 2, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8]) == True\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 4, 5, 6, 7]) == False\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == False\n assert candidate(nums = [1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6]) == True\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == True\n assert candidate(nums = [5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12]) == True\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == True\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 10, 20, 30, 40, 50, 60]) == True\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == True\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 11, 21, 31, 41, 51, 61, 71, 81, 91, 101, 12, 22, 32, 42, 52, 62, 72, 82, 92, 102]) == True\n assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50]) == True\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12]) == True\n assert candidate(nums = [50, 50, 51, 51, 52, 52, 53, 53, 54, 54, 55, 55, 56, 56, 57, 57, 58, 58, 59, 59, 60, 60]) == True\n assert candidate(nums = [2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5]) == False\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == True\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60]) == True\n assert candidate(nums = [5, 5, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == False\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6]) == True\n assert candidate(nums = [41, 41, 42, 42, 43, 43, 44, 44, 45, 45, 46, 46, 47, 47, 48, 48, 49, 49, 50, 50]) == True\n assert candidate(nums = [42, 42, 43, 43, 44, 44, 45, 45, 46, 46]) == True\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]) == False\n assert candidate(nums = [51, 51, 52, 52, 53, 53, 54, 54, 55, 55, 56, 56, 57, 57, 58, 58, 59, 59, 60, 60]) == True\n assert candidate(nums = [5, 5, 5, 5, 6, 6, 7, 7]) == False\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12]) == False\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 6]) == True\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14]) == True\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == True\n assert candidate(nums = [61, 61, 62, 62, 63, 63, 64, 64, 65, 65, 66, 66, 67, 67, 68, 68, 69, 69, 70, 70, 71, 71]) == True\n assert candidate(nums = [99, 99, 98, 98, 97, 97, 96, 96, 95, 95, 94, 94, 93, 93, 92, 92, 91, 91, 90, 90, 89, 89, 88, 88, 87, 87, 86, 86, 85, 85]) == True\n assert candidate(nums = [11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16]) == True\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5]) == True\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6]) == True\n assert candidate(nums = [50, 50, 51, 51, 52, 52, 53, 53, 54, 54, 55, 55, 56, 56]) == True\n assert candidate(nums = [1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8]) == False\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1, 2, 3, 4, 5, 6]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 4, 4, 5]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(nums = [10, 20, 20, 30, 30, 30, 40, 40, 50, 50]) == False\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14]) == True\n assert candidate(nums = [5, 5, 5, 5, 6, 6, 6, 6]) == False\n assert candidate(nums = [5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == True\n assert candidate(nums = [6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13]) == True\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8]) == False\n assert candidate(nums = [32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39, 40, 40]) == True\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == False\n assert candidate(nums = [7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12]) == True\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11]) == True\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16]) == True\n assert candidate(nums = [99, 99, 100, 100, 98, 98, 97, 97, 96, 96]) == True\n assert candidate(nums = [24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31]) == True\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2]) == True\n assert candidate(nums = [5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == True\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().isPossibleToSplit", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool isPossibleToSplit(vector& nums) {", "container": "Solution", "callable": "isPossibleToSplit", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3047, "task_id": "find-the-largest-area-of-square-inside-two-rectangles", "difficulty": "Medium", "problem_description": "There exist n rectangles in a 2D plane with edges parallel to the x and y axis. You are given two 2D integer arrays bottomLeft and topRight where bottomLeft[i] = [a_i, b_i] and topRight[i] = [c_i, d_i] represent the bottom-left and top-right coordinates of the ith rectangle, respectively.\nYou need to find the maximum area of a square that can fit inside the intersecting region of at least two rectangles. Return 0 if such a square does not exist.\n \nExample 1:\n\nInput: bottomLeft = [[1,1],[2,2],[3,1]], topRight = [[3,3],[4,4],[6,6]]\nOutput: 1\nExplanation:\nA square with side length 1 can fit inside either the intersecting region of rectangles 0 and 1 or the intersecting region of rectangles 1 and 2. Hence the maximum area is 1. It can be shown that a square with a greater side length can not fit inside any intersecting region of two rectangles.\nExample 2:\n\nInput: bottomLeft = [[1,1],[1,3],[1,5]], topRight = [[5,5],[5,7],[5,9]]\nOutput: 4\nExplanation:\nA square with side length 2 can fit inside either the intersecting region of rectangles 0 and 1 or the intersecting region of rectangles 1 and 2. Hence the maximum area is 2 * 2 = 4. It can be shown that a square with a greater side length can not fit inside any intersecting region of two rectangles.\nExample 3:\n \nInput: bottomLeft = [[1,1],[2,2],[1,2]], topRight = [[3,3],[4,4],[3,4]]\nOutput: 1\nExplanation:\nA square with side length 1 can fit inside the intersecting region of any two rectangles. Also, no larger square can, so the maximum area is 1. Note that the region can be formed by the intersection of more than 2 rectangles.\nExample 4:\n \nInput: bottomLeft = [[1,1],[3,3],[3,1]], topRight = [[2,2],[4,4],[4,2]]\nOutput: 0\nExplanation:\nNo pair of rectangles intersect, hence, the answer is 0.\n \nConstraints:\n\nn == bottomLeft.length == topRight.length\n2 <= n <= 103\nbottomLeft[i].length == topRight[i].length == 2\n1 <= bottomLeft[i][0], bottomLeft[i][1] <= 107\n1 <= topRight[i][0], topRight[i][1] <= 107\nbottomLeft[i][0] < topRight[i][0]\nbottomLeft[i][1] < topRight[i][1]\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(bottomLeft = [[1, 1], [2, 2], [3, 1]],topRight = [[3, 3], [4, 4], [6, 6]]) == 1\n assert candidate(bottomLeft = [[2, 2], [4, 4], [6, 6]],topRight = [[4, 4], [6, 6], [8, 8]]) == 0\n assert candidate(bottomLeft = [[1, 1], [3, 3], [3, 1]],topRight = [[2, 2], [4, 4], [4, 2]]) == 0\n assert candidate(bottomLeft = [[1, 1], [2, 2], [3, 3], [4, 4]],topRight = [[3, 3], [4, 4], [5, 5], [6, 6]]) == 1\n assert candidate(bottomLeft = [[1, 1], [2, 2]],topRight = [[3, 3], [4, 4]]) == 1\n assert candidate(bottomLeft = [[1, 1], [3, 3], [5, 5]],topRight = [[2, 2], [4, 4], [6, 6]]) == 0\n assert candidate(bottomLeft = [[1, 1], [1, 1]],topRight = [[2, 2], [2, 2]]) == 1\n assert candidate(bottomLeft = [[1, 1], [1, 3], [1, 5]],topRight = [[5, 5], [5, 7], [5, 9]]) == 4\n assert candidate(bottomLeft = [[1, 1], [2, 2], [3, 3]],topRight = [[4, 4], [5, 5], [6, 6]]) == 4\n assert candidate(bottomLeft = [[1, 1], [2, 2], [1, 2]],topRight = [[3, 3], [4, 4], [3, 4]]) == 1\n assert candidate(bottomLeft = [[1, 1], [6, 1], [1, 6], [6, 6]],topRight = [[5, 5], [7, 3], [3, 7], [10, 10]]) == 0\n assert candidate(bottomLeft = [[2, 2], [3, 4], [5, 3], [6, 6]],topRight = [[4, 4], [7, 5], [6, 6], [8, 8]]) == 1\n assert candidate(bottomLeft = [[1, 1], [3, 3], [3, 1]],topRight = [[3, 3], [5, 5], [5, 3]]) == 0\n assert candidate(bottomLeft = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6]],topRight = [[2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]]) == 0\n assert candidate(bottomLeft = [[1, 1], [2, 3], [4, 5], [6, 7]],topRight = [[5, 5], [6, 8], [8, 9], [10, 10]]) == 4\n assert candidate(bottomLeft = [[1, 1], [2, 3], [4, 5], [6, 7]],topRight = [[3, 5], [5, 7], [7, 9], [9, 11]]) == 1\n assert candidate(bottomLeft = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],topRight = [[2, 3], [4, 5], [6, 7], [8, 9], [10, 11]]) == 9\n assert candidate(bottomLeft = [[2, 2], [3, 3], [5, 5], [7, 7]],topRight = [[4, 4], [6, 6], [8, 8], [10, 10]]) == 1\n assert candidate(bottomLeft = [[1, 1], [1, 1], [1, 1], [1, 1]],topRight = [[2, 2], [2, 2], [2, 2], [2, 2]]) == 1\n assert candidate(bottomLeft = [[1, 1], [2, 2], [3, 3], [4, 4]],topRight = [[10, 10], [11, 11], [12, 12], [13, 13]]) == 64\n assert candidate(bottomLeft = [[1, 1], [5, 5], [10, 10], [15, 15]],topRight = [[4, 4], [8, 8], [13, 13], [18, 18]]) == 0\n assert candidate(bottomLeft = [[1, 1], [3, 3], [6, 6], [9, 9], [12, 12]],topRight = [[2, 2], [5, 5], [8, 8], [11, 11], [14, 14]]) == 0\n assert candidate(bottomLeft = [[1, 1], [2, 3], [3, 5], [4, 7]],topRight = [[5, 5], [6, 8], [7, 10], [8, 12]]) == 9\n assert candidate(bottomLeft = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],topRight = [[5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 9\n assert candidate(bottomLeft = [[1, 1], [5, 1], [9, 1], [13, 1]],topRight = [[3, 5], [7, 5], [11, 5], [15, 5]]) == 0\n assert candidate(bottomLeft = [[1, 1], [2, 2], [3, 3], [4, 4]],topRight = [[2, 2], [4, 4], [6, 6], [8, 8]]) == 4\n assert candidate(bottomLeft = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],topRight = [[4, 4], [5, 5], [6, 6], [7, 7], [8, 8]]) == 4\n assert candidate(bottomLeft = [[1, 1], [5, 5], [9, 9]],topRight = [[3, 3], [7, 7], [11, 11]]) == 0\n assert candidate(bottomLeft = [[1, 1], [5, 5], [9, 9], [13, 13]],topRight = [[3, 3], [7, 7], [11, 11], [15, 15]]) == 0\n assert candidate(bottomLeft = [[1, 1], [3, 3], [5, 5], [7, 7]],topRight = [[2, 2], [4, 4], [6, 6], [8, 8]]) == 0\n assert candidate(bottomLeft = [[1, 1], [3, 3], [3, 1], [5, 5]],topRight = [[2, 2], [4, 4], [4, 2], [6, 6]]) == 0\n assert candidate(bottomLeft = [[1, 1], [1, 3], [1, 5], [1, 7]],topRight = [[5, 5], [5, 7], [5, 9], [5, 11]]) == 4\n assert candidate(bottomLeft = [[5, 5], [10, 10], [15, 15], [20, 20]],topRight = [[10, 10], [15, 15], [20, 20], [25, 25]]) == 0\n assert candidate(bottomLeft = [[1, 1], [1, 2], [1, 3], [1, 4]],topRight = [[10, 10], [10, 11], [10, 12], [10, 13]]) == 64\n assert candidate(bottomLeft = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6]],topRight = [[4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 4\n assert candidate(bottomLeft = [[1, 1], [2, 1], [1, 2], [2, 2]],topRight = [[4, 4], [5, 4], [4, 5], [5, 5]]) == 4\n assert candidate(bottomLeft = [[1, 1], [1, 3], [1, 5], [1, 7], [1, 9]],topRight = [[5, 5], [5, 7], [5, 9], [5, 11], [5, 13]]) == 4\n assert candidate(bottomLeft = [[1, 1], [1, 1], [1, 1], [1, 1]],topRight = [[5, 5], [5, 5], [5, 5], [5, 5]]) == 16\n assert candidate(bottomLeft = [[1, 1], [2, 3], [3, 5], [4, 7], [5, 9], [6, 11]],topRight = [[3, 5], [5, 7], [7, 9], [9, 11], [11, 13], [13, 15]]) == 4\n assert candidate(bottomLeft = [[1, 1], [2, 4], [5, 5], [8, 8], [11, 11]],topRight = [[3, 3], [7, 7], [10, 10], [13, 13], [15, 15]]) == 4\n assert candidate(bottomLeft = [[1, 1], [2, 3], [4, 5], [6, 7]],topRight = [[3, 2], [5, 4], [7, 6], [9, 8]]) == 0\n assert candidate(bottomLeft = [[1, 1], [3, 3], [5, 5]],topRight = [[3, 3], [5, 5], [7, 7]]) == 0\n assert candidate(bottomLeft = [[1, 1], [6, 1], [11, 1], [1, 6], [6, 6], [11, 6]],topRight = [[6, 6], [11, 6], [16, 6], [6, 11], [11, 11], [16, 11]]) == 0\n assert candidate(bottomLeft = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],topRight = [[2, 2], [3, 3], [4, 4], [5, 5], [6, 6]]) == 0\n assert candidate(bottomLeft = [[1, 1], [10, 10], [20, 20], [30, 30]],topRight = [[5, 5], [15, 15], [25, 25], [35, 35]]) == 0\n assert candidate(bottomLeft = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1]],topRight = [[2, 2], [3, 2], [4, 2], [5, 2], [6, 2]]) == 0\n assert candidate(bottomLeft = [[1, 1], [1, 3], [1, 5], [1, 7]],topRight = [[7, 2], [7, 4], [7, 6], [7, 8]]) == 0\n assert candidate(bottomLeft = [[1, 1], [10, 10], [20, 20], [30, 30]],topRight = [[15, 15], [25, 25], [35, 35], [45, 45]]) == 25\n assert candidate(bottomLeft = [[1, 1], [4, 4], [7, 7]],topRight = [[2, 2], [5, 5], [8, 8]]) == 0\n assert candidate(bottomLeft = [[1, 1], [3, 3], [6, 6], [10, 10]],topRight = [[4, 4], [7, 7], [11, 11], [15, 15]]) == 1\n assert candidate(bottomLeft = [[1, 1], [2, 2], [3, 3], [4, 4]],topRight = [[2, 3], [3, 4], [4, 5], [5, 6]]) == 0\n assert candidate(bottomLeft = [[1, 1], [5, 5], [9, 9]],topRight = [[10, 10], [12, 12], [14, 14]]) == 25\n assert candidate(bottomLeft = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],topRight = [[6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 16\n assert candidate(bottomLeft = [[1, 1], [2, 3], [3, 5], [5, 7]],topRight = [[3, 3], [4, 5], [6, 7], [8, 9]]) == 0\n assert candidate(bottomLeft = [[1, 1], [2, 2], [1, 2], [3, 3]],topRight = [[3, 3], [4, 4], [3, 4], [5, 5]]) == 1\n assert candidate(bottomLeft = [[1, 1], [2, 3], [4, 5], [6, 7], [8, 9]],topRight = [[2, 2], [5, 6], [7, 8], [9, 10], [11, 12]]) == 1\n assert candidate(bottomLeft = [[1, 1], [5, 5], [9, 9], [13, 13]],topRight = [[4, 4], [8, 8], [12, 12], [16, 16]]) == 0\n assert candidate(bottomLeft = [[1, 1], [1, 3], [1, 5], [1, 7]],topRight = [[3, 3], [3, 5], [3, 7], [3, 9]]) == 0\n assert candidate(bottomLeft = [[2, 3], [4, 1], [6, 5], [8, 7]],topRight = [[4, 5], [6, 3], [8, 7], [10, 9]]) == 0\n assert candidate(bottomLeft = [[10, 10], [20, 20], [30, 30], [40, 40]],topRight = [[20, 20], [30, 30], [40, 40], [50, 50]]) == 0\n assert candidate(bottomLeft = [[1, 1], [3, 3], [5, 5], [7, 7]],topRight = [[4, 4], [6, 6], [8, 8], [10, 10]]) == 1\n assert candidate(bottomLeft = [[1, 1], [1, 2], [1, 3], [1, 4]],topRight = [[2, 4], [2, 5], [2, 6], [2, 7]]) == 1\n assert candidate(bottomLeft = [[1, 1], [3, 1], [1, 3], [3, 3]],topRight = [[4, 2], [6, 2], [4, 6], [6, 6]]) == 1\n assert candidate(bottomLeft = [[1, 1], [2, 2], [3, 3], [4, 4]],topRight = [[2, 2], [3, 3], [4, 4], [5, 5]]) == 0\n assert candidate(bottomLeft = [[1, 1], [2, 2], [3, 3], [4, 4]],topRight = [[5, 5], [6, 6], [7, 7], [8, 8]]) == 9\n assert candidate(bottomLeft = [[1, 1], [5, 5], [3, 3]],topRight = [[4, 4], [7, 7], [6, 6]]) == 1\n assert candidate(bottomLeft = [[1, 1], [3, 3], [5, 5], [7, 7], [9, 9]],topRight = [[2, 4], [6, 8], [10, 12], [14, 16], [18, 20]]) == 25\n assert candidate(bottomLeft = [[1, 1], [3, 1], [5, 1], [7, 1]],topRight = [[2, 3], [4, 3], [6, 3], [8, 3]]) == 0\n assert candidate(bottomLeft = [[1, 1], [2, 2], [10, 10], [15, 15]],topRight = [[2, 2], [3, 3], [12, 12], [16, 16]]) == 0\n assert candidate(bottomLeft = [[1, 1], [2, 1], [3, 1], [4, 1]],topRight = [[4, 10], [5, 10], [6, 10], [7, 10]]) == 4\n assert candidate(bottomLeft = [[1, 1], [10, 1], [1, 10], [10, 10]],topRight = [[10, 10], [20, 10], [10, 20], [20, 20]]) == 0\n assert candidate(bottomLeft = [[1, 1], [1, 1], [1, 1], [1, 1]],topRight = [[10, 10], [10, 10], [10, 10], [10, 10]]) == 81\n assert candidate(bottomLeft = [[1, 1], [2, 1], [3, 1], [4, 1]],topRight = [[4, 2], [5, 2], [6, 2], [7, 2]]) == 1\n assert candidate(bottomLeft = [[1, 1], [10, 1], [1, 10], [10, 10]],topRight = [[5, 5], [15, 5], [5, 15], [15, 15]]) == 0\n assert candidate(bottomLeft = [[1, 1], [3, 1], [5, 1], [7, 1]],topRight = [[2, 2], [4, 2], [6, 2], [8, 2]]) == 0\n assert candidate(bottomLeft = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6]],topRight = [[3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8]]) == 1\n assert candidate(bottomLeft = [[1, 1], [1, 2], [2, 1], [2, 2]],topRight = [[3, 3], [3, 4], [4, 3], [4, 4]]) == 1\n assert candidate(bottomLeft = [[1, 10], [10, 20], [20, 30]],topRight = [[10, 20], [20, 30], [30, 40]]) == 0\n assert candidate(bottomLeft = [[1, 1], [1, 2], [2, 1], [2, 2], [3, 1], [3, 2]],topRight = [[3, 3], [3, 4], [4, 3], [4, 4], [5, 3], [5, 4]]) == 1\n assert candidate(bottomLeft = [[1, 1], [2, 3], [3, 5], [4, 7], [5, 9]],topRight = [[4, 5], [6, 8], [8, 11], [10, 13], [12, 15]]) == 16\n assert candidate(bottomLeft = [[1, 1], [4, 4], [7, 7], [10, 10]],topRight = [[5, 5], [8, 8], [11, 11], [13, 13]]) == 1\n assert candidate(bottomLeft = [[1, 1], [2, 3], [3, 5], [4, 7]],topRight = [[2, 2], [4, 4], [6, 6], [8, 8]]) == 0\n assert candidate(bottomLeft = [[1, 1], [4, 4], [7, 7], [10, 10]],topRight = [[3, 3], [6, 6], [9, 9], [12, 12]]) == 0\n assert candidate(bottomLeft = [[1, 1], [1, 5], [1, 9], [1, 13]],topRight = [[10, 10], [10, 15], [10, 19], [10, 23]]) == 36\n assert candidate(bottomLeft = [[1, 1], [4, 4], [6, 6], [8, 8]],topRight = [[3, 3], [7, 7], [10, 10], [12, 12]]) == 4\n assert candidate(bottomLeft = [[1, 1], [1, 3], [1, 5], [1, 7], [1, 9]],topRight = [[2, 2], [2, 4], [2, 6], [2, 8], [2, 10]]) == 0\n assert candidate(bottomLeft = [[1, 1], [3, 3], [5, 5], [7, 7], [9, 9]],topRight = [[2, 2], [4, 4], [6, 6], [8, 8], [10, 10]]) == 0\n assert candidate(bottomLeft = [[1, 1], [2, 3], [4, 5], [6, 7]],topRight = [[3, 2], [4, 4], [6, 6], [8, 8]]) == 0\n assert candidate(bottomLeft = [[1, 1], [2, 4], [3, 7], [4, 10], [5, 13]],topRight = [[6, 6], [7, 9], [8, 12], [9, 15], [10, 18]]) == 4\n assert candidate(bottomLeft = [[1, 1], [3, 3], [5, 5], [7, 7], [9, 9], [11, 11]],topRight = [[2, 2], [4, 4], [6, 6], [8, 8], [10, 10], [12, 12]]) == 0\n assert candidate(bottomLeft = [[10, 10], [20, 20], [30, 30]],topRight = [[20, 20], [30, 30], [40, 40]]) == 0\n assert candidate(bottomLeft = [[2, 2], [5, 5], [8, 8], [11, 11], [14, 14]],topRight = [[4, 4], [7, 7], [10, 10], [13, 13], [16, 16]]) == 0\n assert candidate(bottomLeft = [[2, 2], [6, 6], [10, 10], [14, 14]],topRight = [[4, 4], [8, 8], [12, 12], [16, 16]]) == 0\n assert candidate(bottomLeft = [[2, 2], [3, 3], [4, 4], [5, 5]],topRight = [[3, 3], [4, 4], [5, 5], [6, 6]]) == 0\n assert candidate(bottomLeft = [[1, 1], [2, 2], [5, 5], [7, 7]],topRight = [[3, 3], [6, 6], [8, 8], [10, 10]]) == 1\n assert candidate(bottomLeft = [[1, 1], [1, 5], [5, 1], [5, 5]],topRight = [[5, 5], [5, 9], [9, 5], [9, 9]]) == 0\n assert candidate(bottomLeft = [[1, 1], [3, 1], [5, 1], [7, 1]],topRight = [[3, 3], [5, 3], [7, 3], [9, 3]]) == 0\n assert candidate(bottomLeft = [[1, 10], [5, 15], [10, 20], [15, 25]],topRight = [[10, 20], [20, 25], [25, 30], [30, 35]]) == 25\n assert candidate(bottomLeft = [[2, 2], [3, 3], [4, 4], [5, 5]],topRight = [[6, 6], [7, 7], [8, 8], [9, 9]]) == 9\n assert candidate(bottomLeft = [[1, 1], [3, 3], [6, 6], [8, 8]],topRight = [[4, 4], [6, 6], [9, 9], [11, 11]]) == 1\n assert candidate(bottomLeft = [[1, 1], [3, 2], [5, 3], [7, 4]],topRight = [[2, 2], [4, 3], [6, 4], [8, 5]]) == 0\n assert candidate(bottomLeft = [[1, 1], [3, 1], [5, 1], [7, 1], [9, 1]],topRight = [[2, 2], [4, 2], [6, 2], [8, 2], [10, 2]]) == 0\n"}, "metadata": {"canonical_parameter_names": ["bottomLeft", "topRight"], "leetcode_dataset_entry_point": "Solution().largestSquareArea", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "long long largestSquareArea(vector>& bottomLeft, vector>& topRight) {", "container": "Solution", "callable": "largestSquareArea", "parameters": [{"name": "bottomLeft", "type": "vector>&"}, {"name": "topRight", "type": "vector>&"}], "return_type": "long long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3048, "task_id": "earliest-second-to-mark-indices-i", "difficulty": "Medium", "problem_description": "You are given two 1-indexed integer arrays, nums and, changeIndices, having lengths n and m, respectively.\nInitially, all indices in nums are unmarked. Your task is to mark all indices in nums.\nIn each second, s, in order from 1 to m (inclusive), you can perform one of the following operations:\n\nChoose an index i in the range [1, n] and decrement nums[i] by 1.\nIf nums[changeIndices[s]] is equal to 0, mark the index changeIndices[s].\nDo nothing.\n\nReturn an integer denoting the earliest second in the range [1, m] when all indices in nums can be marked by choosing operations optimally, or -1 if it is impossible.\n \nExample 1:\n\nInput: nums = [2,2,0], changeIndices = [2,2,2,2,3,2,2,1]\nOutput: 8\nExplanation: In this example, we have 8 seconds. The following operations can be performed to mark all indices:\nSecond 1: Choose index 1 and decrement nums[1] by one. nums becomes [1,2,0].\nSecond 2: Choose index 1 and decrement nums[1] by one. nums becomes [0,2,0].\nSecond 3: Choose index 2 and decrement nums[2] by one. nums becomes [0,1,0].\nSecond 4: Choose index 2 and decrement nums[2] by one. nums becomes [0,0,0].\nSecond 5: Mark the index changeIndices[5], which is marking index 3, since nums[3] is equal to 0.\nSecond 6: Mark the index changeIndices[6], which is marking index 2, since nums[2] is equal to 0.\nSecond 7: Do nothing.\nSecond 8: Mark the index changeIndices[8], which is marking index 1, since nums[1] is equal to 0.\nNow all indices have been marked.\nIt can be shown that it is not possible to mark all indices earlier than the 8th second.\nHence, the answer is 8.\n\nExample 2:\n\nInput: nums = [1,3], changeIndices = [1,1,1,2,1,1,1]\nOutput: 6\nExplanation: In this example, we have 7 seconds. The following operations can be performed to mark all indices:\nSecond 1: Choose index 2 and decrement nums[2] by one. nums becomes [1,2].\nSecond 2: Choose index 2 and decrement nums[2] by one. nums becomes [1,1].\nSecond 3: Choose index 2 and decrement nums[2] by one. nums becomes [1,0].\nSecond 4: Mark the index changeIndices[4], which is marking index 2, since nums[2] is equal to 0.\nSecond 5: Choose index 1 and decrement nums[1] by one. nums becomes [0,0].\nSecond 6: Mark the index changeIndices[6], which is marking index 1, since nums[1] is equal to 0.\nNow all indices have been marked.\nIt can be shown that it is not possible to mark all indices earlier than the 6th second.\nHence, the answer is 6.\n\nExample 3:\n\nInput: nums = [0,1], changeIndices = [2,2,2]\nOutput: -1\nExplanation: In this example, it is impossible to mark all indices because index 1 isn't in changeIndices.\nHence, the answer is -1.\n\n \nConstraints:\n\n1 <= n == nums.length <= 2000\n0 <= nums[i] <= 109\n1 <= m == changeIndices.length <= 2000\n1 <= changeIndices[i] <= n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 0, 1, 0],changeIndices = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]) == 6\n assert candidate(nums = [10, 0, 10],changeIndices = [1, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == -1\n assert candidate(nums = [0, 0, 0, 0],changeIndices = [1, 2, 3, 4]) == 4\n assert candidate(nums = [1, 3],changeIndices = [1, 1, 1, 2, 1, 1, 1]) == 6\n assert candidate(nums = [0, 0, 0],changeIndices = [1, 2, 3]) == 3\n assert candidate(nums = [5, 4, 3],changeIndices = [1, 2, 3, 1, 2, 3, 1, 2, 3]) == -1\n assert candidate(nums = [1, 2, 3, 4],changeIndices = [4, 3, 2, 1, 4, 3, 2, 1]) == -1\n assert candidate(nums = [10, 20, 30, 40],changeIndices = [4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1]) == -1\n assert candidate(nums = [3, 3, 3, 3],changeIndices = [4, 3, 2, 1, 4, 3, 2, 1]) == -1\n assert candidate(nums = [1, 1, 1, 1],changeIndices = [1, 2, 3, 4, 1, 2, 3, 4]) == 8\n assert candidate(nums = [1, 2, 3, 4, 5],changeIndices = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [10, 10, 10, 10],changeIndices = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]) == -1\n assert candidate(nums = [0, 0, 0, 0],changeIndices = [1, 2, 3, 4, 1, 2, 3, 4]) == 4\n assert candidate(nums = [100, 200, 300],changeIndices = [1, 2, 3, 1, 2, 3, 1, 2, 3]) == -1\n assert candidate(nums = [10, 10, 10],changeIndices = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == -1\n assert candidate(nums = [0, 1],changeIndices = [2, 2, 2]) == -1\n assert candidate(nums = [1000000000, 1000000000],changeIndices = [1, 2, 1, 2, 1, 2]) == -1\n assert candidate(nums = [100, 0, 50],changeIndices = [1, 1, 1, 3, 3, 3, 2, 2, 2]) == -1\n assert candidate(nums = [2, 2, 0],changeIndices = [2, 2, 2, 2, 3, 2, 2, 1]) == 8\n assert candidate(nums = [5, 5, 5],changeIndices = [1, 2, 3, 1, 2, 3, 1, 2, 3]) == -1\n assert candidate(nums = [1, 0, 3],changeIndices = [3, 3, 3, 1, 1, 2, 2, 2]) == -1\n assert candidate(nums = [1, 2, 3, 4],changeIndices = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4]) == 14\n assert candidate(nums = [3, 2, 1],changeIndices = [3, 2, 1, 3, 2, 1]) == -1\n assert candidate(nums = [0, 0, 0, 0, 0],changeIndices = [1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [10, 20, 30],changeIndices = [1, 1, 1, 2, 2, 2, 3, 3, 3]) == -1\n assert candidate(nums = [10, 10, 10],changeIndices = [1, 1, 1, 2, 2, 2, 3, 3, 3]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1],changeIndices = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 10\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],changeIndices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1],changeIndices = [1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8]) == 16\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],changeIndices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],changeIndices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [100, 200, 300, 400],changeIndices = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],changeIndices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == -1\n assert candidate(nums = [10, 20, 30, 40, 50],changeIndices = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [0, 0, 0, 0],changeIndices = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]) == 4\n assert candidate(nums = [1, 0, 1, 0, 1, 0],changeIndices = [2, 4, 6, 1, 3, 5, 1, 3, 5, 2, 4, 6]) == 9\n assert candidate(nums = [0, 0, 0, 0, 0],changeIndices = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [5, 5, 5, 5, 5],changeIndices = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],changeIndices = [9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5],changeIndices = [1, 2, 3, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == -1\n assert candidate(nums = [10, 20, 30, 40, 50],changeIndices = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [2, 3, 5, 7, 11, 13],changeIndices = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6]) == -1\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],changeIndices = [9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],changeIndices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 20\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],changeIndices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 15\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9],changeIndices = [9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],changeIndices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000],changeIndices = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]) == -1\n assert candidate(nums = [10, 20, 30, 40],changeIndices = [4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1]) == -1\n assert candidate(nums = [100, 200, 300],changeIndices = [3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],changeIndices = [10, 1, 9, 2, 8, 3, 7, 4, 6, 5]) == -1\n assert candidate(nums = [10, 20, 30, 40, 50],changeIndices = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == -1\n assert candidate(nums = [100, 100, 100, 100],changeIndices = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]) == -1\n assert candidate(nums = [10, 0, 0, 10],changeIndices = [4, 4, 4, 1, 1, 1, 4, 4, 4, 1, 1, 1]) == -1\n assert candidate(nums = [5, 7, 9, 10],changeIndices = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]) == -1\n assert candidate(nums = [5, 5, 5, 5, 5],changeIndices = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],changeIndices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == -1\n assert candidate(nums = [5, 5, 5, 5, 5, 5],changeIndices = [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [100, 200, 300, 400],changeIndices = [4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1]) == -1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0],changeIndices = [1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7]) == 7\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],changeIndices = [9, 8, 7, 6, 5, 4, 3, 2, 1, 9]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],changeIndices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [0, 10, 20, 30, 40],changeIndices = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],changeIndices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == -1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],changeIndices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [1, 0, 2, 3, 4],changeIndices = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70],changeIndices = [7, 6, 5, 4, 3, 2, 1, 7, 6, 5, 4, 3, 2, 1, 7, 6, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],changeIndices = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == -1\n assert candidate(nums = [100, 200, 300],changeIndices = [3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == -1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],changeIndices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],changeIndices = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == -1\n assert candidate(nums = [5, 0, 2, 7, 3],changeIndices = [1, 5, 3, 4, 4, 2, 5, 3, 1, 2, 4, 3]) == -1\n assert candidate(nums = [10, 20, 30, 40],changeIndices = [4, 3, 2, 1, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]) == -1\n assert candidate(nums = [999999999, 999999999, 999999999],changeIndices = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == -1\n assert candidate(nums = [5, 10, 15, 20],changeIndices = [4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1]) == -1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],changeIndices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],changeIndices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [1000000000, 1000000000, 1000000000],changeIndices = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == -1\n assert candidate(nums = [0, 0, 0, 0],changeIndices = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]) == 4\n assert candidate(nums = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0],changeIndices = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10, 1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == -1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],changeIndices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],changeIndices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [1000000000, 1000000000, 1000000000],changeIndices = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == -1\n assert candidate(nums = [0, 0, 0, 0, 0],changeIndices = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [5, 0, 8, 3],changeIndices = [4, 1, 2, 3, 1, 2, 3, 4, 1, 2, 3, 4]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],changeIndices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 20\n assert candidate(nums = [9, 8, 7, 6, 5],changeIndices = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [100, 200, 300, 400],changeIndices = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]) == -1\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],changeIndices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],changeIndices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [1000000000, 1000000000, 1000000000],changeIndices = [3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == -1\n assert candidate(nums = [1000000000, 1000000000, 1000000000],changeIndices = [1, 1, 1, 2, 2, 2, 3, 3, 3]) == -1\n assert candidate(nums = [5, 5, 5, 5, 5],changeIndices = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == -1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],changeIndices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [100, 0, 50, 25, 75],changeIndices = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [100, 200, 300, 400, 500],changeIndices = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [10, 20, 30, 40, 50],changeIndices = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == -1\n assert candidate(nums = [0, 0, 1, 1, 2, 2],changeIndices = [3, 3, 4, 4, 5, 5, 1, 1, 2, 2]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],changeIndices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [0, 0, 0, 0],changeIndices = [1, 2, 3, 4, 1, 2, 3, 4]) == 4\n assert candidate(nums = [2000, 1999, 1998, 1997, 1996, 1995, 1994, 1993, 1992, 1991],changeIndices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [1000000000, 1000000000],changeIndices = [1, 1, 2, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == -1\n assert candidate(nums = [100, 200, 300, 400],changeIndices = [4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1]) == -1\n assert candidate(nums = [1000, 1000, 1000, 1000],changeIndices = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]) == -1\n assert candidate(nums = [1, 0, 0, 1],changeIndices = [4, 4, 4, 1, 1, 1, 4, 4, 4, 1, 1, 1, 4, 4, 4, 1, 1, 1]) == -1\n assert candidate(nums = [10, 20, 30],changeIndices = [1, 2, 3, 3, 2, 1, 1, 2, 3, 3, 2, 1, 1, 2, 3]) == -1\n assert candidate(nums = [1, 0, 0, 0, 1],changeIndices = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 7\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],changeIndices = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8],changeIndices = [8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1],changeIndices = [1, 3, 5, 7, 2, 4, 6, 1, 3, 5, 7, 2, 4, 6]) == 11\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],changeIndices = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == -1\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],changeIndices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == -1\n assert candidate(nums = [10, 20, 30, 40],changeIndices = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]) == -1\n"}, "metadata": {"canonical_parameter_names": ["nums", "changeIndices"], "leetcode_dataset_entry_point": "Solution().earliestSecondToMarkIndices", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int earliestSecondToMarkIndices(vector& nums, vector& changeIndices) {", "container": "Solution", "callable": "earliestSecondToMarkIndices", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "changeIndices", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3065, "task_id": "minimum-operations-to-exceed-threshold-value-i", "difficulty": "Easy", "problem_description": "You are given a 0-indexed integer array nums, and an integer k.\nIn one operation, you can remove one occurrence of the smallest element of nums.\nReturn the minimum number of operations needed so that all elements of the array are greater than or equal to k.\n \nExample 1:\n\nInput: nums = [2,11,10,1,3], k = 10\nOutput: 3\nExplanation: After one operation, nums becomes equal to [2, 11, 10, 3].\nAfter two operations, nums becomes equal to [11, 10, 3].\nAfter three operations, nums becomes equal to [11, 10].\nAt this stage, all the elements of nums are greater than or equal to 10 so we can stop.\nIt can be shown that 3 is the minimum number of operations needed so that all elements of the array are greater than or equal to 10.\n\nExample 2:\n\nInput: nums = [1,1,2,4,9], k = 1\nOutput: 0\nExplanation: All elements of the array are greater than or equal to 1 so we do not need to apply any operations on nums.\nExample 3:\n\nInput: nums = [1,1,2,4,9], k = 9\nOutput: 4\nExplanation: only a single element of nums is greater than or equal to 9 so we need to apply the operations 4 times on nums.\n\n \nConstraints:\n\n1 <= nums.length <= 50\n1 <= nums[i] <= 109\n1 <= k <= 109\nThe input is generated such that there is at least one index i such that nums[i] >= k.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [7, 7, 7, 7, 7],k = 7) == 0\n assert candidate(nums = [5, 5, 5, 5, 5],k = 5) == 0\n assert candidate(nums = [1, 1, 2, 4, 9],k = 1) == 0\n assert candidate(nums = [1, 2, 3, 4, 5],k = 3) == 2\n assert candidate(nums = [5, 3, 8, 9, 2],k = 5) == 2\n assert candidate(nums = [100, 200, 300, 400, 500],k = 100) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 4\n assert candidate(nums = [3, 6, 9, 12, 15],k = 12) == 3\n assert candidate(nums = [10, 20, 30, 40, 50],k = 25) == 2\n assert candidate(nums = [10, 20, 30, 40, 50],k = 15) == 1\n assert candidate(nums = [1, 1, 2, 4, 9],k = 9) == 4\n assert candidate(nums = [8, 8, 8, 8, 8, 8],k = 8) == 0\n assert candidate(nums = [2, 11, 10, 1, 3],k = 10) == 3\n assert candidate(nums = [10, 9, 8, 7, 6],k = 7) == 1\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90],k = 95) == 5\n assert candidate(nums = [1000000000, 999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111],k = 555555555) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 9\n assert candidate(nums = [10, 20, 30, 40, 50],k = 25) == 2\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 25) == 8\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 1],k = 5) == 4\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 60) == 5\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == 0\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996],k = 999999997) == 1\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],k = 95) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3],k = 2) == 5\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42],k = 42) == 0\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 9) == 8\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 6) == 5\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],k = 28) == 13\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 0\n assert candidate(nums = [5, 3, 8, 2, 6, 1, 4],k = 4) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 6) == 5\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11],k = 15) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 20) == 10\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 55) == 5\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 4) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 15) == 14\n assert candidate(nums = [34, 23, 54, 12, 45, 67, 89, 23, 45, 67, 89, 12, 34, 56, 78, 90, 12, 34, 56, 78, 90, 12, 34, 56, 78, 90, 12, 34, 56, 78, 90],k = 45) == 12\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 1000) == 9\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 50) == 4\n assert candidate(nums = [5, 5, 5, 5, 5],k = 6) == 5\n assert candidate(nums = [5, 3, 1, 4, 2, 6],k = 4) == 3\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 50) == 4\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 15) == 14\n assert candidate(nums = [1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000],k = 1000000000) == 3\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996],k = 999999997) == 1\n assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5],k = 5) == 19\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == 0\n assert candidate(nums = [34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34],k = 33) == 0\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 3) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2],k = 2) == 9\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],k = 10) == 5\n assert candidate(nums = [10, 10, 10, 10, 10],k = 10) == 0\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31],k = 35) == 4\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 15) == 13\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 60) == 5\n assert candidate(nums = [5, 3, 8, 6, 2, 10, 4, 9],k = 5) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],k = 40) == 39\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 4\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30],k = 40) == 10\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],k = 99) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 6) == 45\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 4\n assert candidate(nums = [5, 3, 3, 2, 1, 1, 1, 1],k = 3) == 5\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 3) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 6) == 10\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995],k = 999999997) == 2\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],k = 20) == 8\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 75) == 7\n assert candidate(nums = [3, 1, 2, 4, 5, 6, 7, 8, 9, 10],k = 4) == 3\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 15) == 7\n assert candidate(nums = [2, 3, 1, 5, 4, 7, 6, 9, 8, 10],k = 7) == 6\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 30) == 5\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94],k = 96) == 2\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42],k = 25) == 12\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 10) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 8) == 7\n assert candidate(nums = [1, 1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000],k = 1000000000) == 5\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 25) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 8) == 7\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 1) == 0\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 2) == 23\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 4\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 500) == 4\n assert candidate(nums = [5, 3, 1, 4, 2, 6, 7],k = 4) == 3\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 4) == 10\n assert candidate(nums = [3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1],k = 2) == 30\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996],k = 999999998) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 9\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 4\n assert candidate(nums = [47, 23, 89, 5, 76, 12, 34, 67, 9, 100],k = 25) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],k = 25) == 24\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 1) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12, 13, 14, 15],k = 10) == 9\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10],k = 10) == 51\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 1) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10],k = 10) == 10\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 8) == 0\n assert candidate(nums = [100, 99, 98, 97, 96, 95],k = 98) == 3\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10],k = 10) == 5\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 3) == 2\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minOperations(vector& nums, int k) {", "container": "Solution", "callable": "minOperations", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3066, "task_id": "minimum-operations-to-exceed-threshold-value-ii", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums, and an integer k.\nYou are allowed to perform some operations on nums, where in a single operation, you can:\n\nSelect the two smallest integers x and y from nums.\nRemove x and y from nums.\nInsert (min(x, y) * 2 + max(x, y)) at any position in the array.\n\nNote that you can only apply the described operation if nums contains at least two elements.\nReturn the minimum number of operations needed so that all elements of the array are greater than or equal to k.\n \nExample 1:\n\nInput: nums = [2,11,10,1,3], k = 10\nOutput: 2\nExplanation:\n\nIn the first operation, we remove elements 1 and 2, then add 1 * 2 + 2 to nums. nums becomes equal to [4, 11, 10, 3].\nIn the second operation, we remove elements 3 and 4, then add 3 * 2 + 4 to nums. nums becomes equal to [10, 11, 10].\n\nAt this stage, all the elements of nums are greater than or equal to 10 so we can stop. \nIt can be shown that 2 is the minimum number of operations needed so that all elements of the array are greater than or equal to 10.\n\nExample 2:\n\nInput: nums = [1,1,2,4,9], k = 20\nOutput: 4\nExplanation:\n\nAfter one operation, nums becomes equal to [2, 4, 9, 3]. \nAfter two operations, nums becomes equal to [7, 4, 9]. \nAfter three operations, nums becomes equal to [15, 9]. \nAfter four operations, nums becomes equal to [33].\n\nAt this stage, all the elements of nums are greater than 20 so we can stop. \nIt can be shown that 4 is the minimum number of operations needed so that all elements of the array are greater than or equal to 20.\n\n \nConstraints:\n\n2 <= nums.length <= 2 * 105\n1 <= nums[i] <= 109\n1 <= k <= 109\nThe input is generated such that an answer always exists. That is, after performing some number of operations, all elements of the array are greater than or equal to k.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 10) == 7\n assert candidate(nums = [5, 4, 3, 2, 1],k = 10) == 3\n assert candidate(nums = [5, 5, 5, 5],k = 10) == 2\n assert candidate(nums = [5, 10, 15, 20],k = 25) == 3\n assert candidate(nums = [5, 5, 5, 5, 5],k = 11) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6],k = 10) == 4\n assert candidate(nums = [1, 1000000000],k = 1000000000) == 1\n assert candidate(nums = [100, 200, 300],k = 500) == 2\n assert candidate(nums = [2, 11, 10, 1, 3],k = 10) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6],k = 10) == 4\n assert candidate(nums = [1, 1, 1, 1, 1, 1],k = 2) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 9\n assert candidate(nums = [5, 6, 7],k = 14) == 2\n assert candidate(nums = [1000000000, 1000000000],k = 1000000000) == 0\n assert candidate(nums = [1000000000, 1],k = 2000000000) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],k = 18) == 6\n assert candidate(nums = [1, 1, 2, 4, 9],k = 20) == 4\n assert candidate(nums = [1000000000, 1000000000],k = 1000000000) == 0\n assert candidate(nums = [1, 1000000000],k = 1000000000) == 1\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 20) == 14\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 4) == 5\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],k = 1000) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],k = 40) == 24\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 30) == 13\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 10\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89],k = 100) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 20) == 7\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256],k = 512) == 8\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100],k = 100) == 7\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 1500) == 7\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 15\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 55) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 3) == 32\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 35) == 9\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 1000) == 5\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 50) == 3\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 105) == 6\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15],k = 20) == 5\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 5) == 5\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],k = 1024) == 9\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 10) == 6\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],k = 50) == 10\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 60) == 6\n assert candidate(nums = [2, 3, 1, 6, 5, 4],k = 7) == 4\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 8\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 3) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 25) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 15) == 9\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 9\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],k = 50) == 7\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 40) == 12\n assert candidate(nums = [999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 999999990],k = 1999999988) == 5\n assert candidate(nums = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16],k = 50) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 35) == 19\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 20) == 10\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50],k = 50) == 14\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 10) == 8\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 10) == 8\n assert candidate(nums = [999999999, 999999998, 999999997, 999999996, 999999995, 999999994],k = 1999999997) == 3\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 10\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 150) == 7\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991],k = 2000000000) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 15) == 7\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71],k = 100) == 14\n assert candidate(nums = [100000000, 200000000, 300000000, 400000000, 500000000],k = 1000000000) == 3\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],k = 32768) == 14\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991],k = 1999990) == 5\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 12) == 6\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300],k = 250) == 14\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 6) == 15\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 100) == 5\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996],k = 2000000000) == 3\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 20) == 7\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 7) == 15\n assert candidate(nums = [500000000, 400000000, 300000000, 200000000, 100000000, 90000000, 80000000, 70000000, 60000000, 50000000],k = 1000000000) == 8\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],k = 1048576) == 19\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],k = 10) == 9\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],k = 1500) == 9\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 8\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 26\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 15) == 7\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109],k = 200) == 5\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],k = 1000000000) == 9\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],k = 512) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],k = 10) == 5\n assert candidate(nums = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55],k = 100) == 8\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 50) == 7\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],k = 500000000) == 9\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41],k = 100) == 5\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 20) == 6\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 30) == 7\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 16\n assert candidate(nums = [999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 999999990],k = 2000000000) == 5\n assert candidate(nums = [2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5],k = 10) == 13\n assert candidate(nums = [1, 2, 3, 6, 9, 18, 27, 54, 81, 162, 243, 486, 729, 1458, 2187, 4374, 6561, 13122, 19683, 38364],k = 10000) == 15\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],k = 2048) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 25) == 12\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60],k = 61) == 18\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 30) == 17\n assert candidate(nums = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10],k = 18) == 7\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],k = 60) == 18\n assert candidate(nums = [1, 1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000],k = 2000000000) == 8\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2],k = 10) == 9\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minOperations(vector& nums, int k) {", "container": "Solution", "callable": "minOperations", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3067, "task_id": "count-pairs-of-connectable-servers-in-a-weighted-tree-network", "difficulty": "Medium", "problem_description": "You are given an unrooted weighted tree with n vertices representing servers numbered from 0 to n - 1, an array edges where edges[i] = [ai, bi, weighti] represents a bidirectional edge between vertices ai and bi of weight weighti. You are also given an integer signalSpeed.\nTwo servers a and b are connectable through a server c if:\n\na < b, a != c and b != c.\nThe distance from c to a is divisible by signalSpeed.\nThe distance from c to b is divisible by signalSpeed.\nThe path from c to b and the path from c to a do not share any edges.\n\nReturn an integer array count of length n where count[i] is the number of server pairs that are connectable through the server i.\n \nExample 1:\n\n\nInput: edges = [[0,1,1],[1,2,5],[2,3,13],[3,4,9],[4,5,2]], signalSpeed = 1\nOutput: [0,4,6,6,4,0]\nExplanation: Since signalSpeed is 1, count[c] is equal to the number of pairs of paths that start at c and do not share any edges.\nIn the case of the given path graph, count[c] is equal to the number of servers to the left of c multiplied by the servers to the right of c.\n\nExample 2:\n\n\nInput: edges = [[0,6,3],[6,5,3],[0,3,1],[3,2,7],[3,1,6],[3,4,2]], signalSpeed = 3\nOutput: [2,0,0,0,0,0,2]\nExplanation: Through server 0, there are 2 pairs of connectable servers: (4, 5) and (4, 6).\nThrough server 6, there are 2 pairs of connectable servers: (4, 5) and (0, 5).\nIt can be shown that no two servers are connectable through servers other than 0 and 6.\n\n \nConstraints:\n\n2 <= n <= 1000\nedges.length == n - 1\nedges[i].length == 3\n0 <= ai, bi < n\nedges[i] = [ai, bi, weighti]\n1 <= weighti <= 106\n1 <= signalSpeed <= 106\nThe input is generated such that edges represents a valid tree.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(edges = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1]],signalSpeed = 1) == [0, 8, 14, 18, 20, 20, 18, 14, 8, 0]\n assert candidate(edges = [[0, 1, 1], [1, 2, 5], [2, 3, 13], [3, 4, 9], [4, 5, 2]],signalSpeed = 1) == [0, 4, 6, 6, 4, 0]\n assert candidate(edges = [[0, 1, 5], [1, 2, 10], [2, 3, 15], [3, 4, 20]],signalSpeed = 5) == [0, 3, 4, 3, 0]\n assert candidate(edges = [[0, 1, 2], [0, 2, 3], [1, 3, 4], [1, 4, 5], [2, 5, 6], [2, 6, 7]],signalSpeed = 1) == [9, 9, 9, 0, 0, 0, 0]\n assert candidate(edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [1, 4, 10], [2, 5, 10], [2, 6, 10]],signalSpeed = 5) == [9, 9, 9, 0, 0, 0, 0]\n assert candidate(edges = [[0, 1, 4], [1, 2, 8], [2, 3, 12], [3, 4, 16]],signalSpeed = 4) == [0, 3, 4, 3, 0]\n assert candidate(edges = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6]],signalSpeed = 2) == [0, 2, 0, 0, 2, 0]\n assert candidate(edges = [[0, 1, 1], [0, 2, 2], [0, 3, 3], [1, 4, 4], [1, 5, 5], [2, 6, 6], [3, 7, 7]],signalSpeed = 1) == [16, 11, 6, 6, 0, 0, 0, 0]\n assert candidate(edges = [[0, 1, 2], [1, 2, 4], [2, 3, 6], [3, 4, 8]],signalSpeed = 2) == [0, 3, 4, 3, 0]\n assert candidate(edges = [[0, 1, 3], [1, 2, 6], [2, 3, 9], [3, 4, 12], [4, 5, 15]],signalSpeed = 3) == [0, 4, 6, 6, 4, 0]\n assert candidate(edges = [[0, 6, 3], [6, 5, 3], [0, 3, 1], [3, 2, 7], [3, 1, 6], [3, 4, 2]],signalSpeed = 3) == [2, 0, 0, 0, 0, 0, 2]\n assert candidate(edges = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40]],signalSpeed = 10) == [0, 3, 4, 3, 0]\n assert candidate(edges = [[0, 1, 4], [1, 2, 8], [2, 3, 12]],signalSpeed = 4) == [0, 2, 2, 0]\n assert candidate(edges = [[0, 1, 4], [1, 2, 5], [2, 3, 6]],signalSpeed = 2) == [0, 0, 0, 0]\n assert candidate(edges = [[0, 1, 2], [1, 2, 4], [2, 3, 8], [3, 4, 16]],signalSpeed = 2) == [0, 3, 4, 3, 0]\n assert candidate(edges = [[0, 1, 13], [0, 2, 26], [1, 3, 39], [1, 4, 52], [2, 5, 65], [2, 6, 78], [3, 7, 91], [4, 8, 104], [5, 9, 117], [6, 10, 130], [7, 11, 143], [8, 12, 156], [9, 13, 169]],signalSpeed = 13) == [42, 51, 46, 22, 22, 22, 12, 12, 12, 12, 0, 0, 0, 0]\n assert candidate(edges = [[0, 1, 19], [1, 2, 38], [1, 3, 57], [2, 4, 76], [2, 5, 95], [3, 6, 114], [3, 7, 133], [4, 8, 152], [5, 9, 171], [6, 10, 190], [7, 11, 209], [8, 12, 228], [9, 13, 247], [10, 14, 266], [11, 15, 285], [12, 16, 304], [13, 17, 323], [14, 18, 342]],signalSpeed = 19) == [0, 89, 96, 89, 45, 45, 45, 32, 32, 32, 32, 17, 17, 17, 17, 0, 0, 0, 0]\n assert candidate(edges = [[0, 1, 6], [0, 2, 12], [1, 3, 18], [1, 4, 24], [2, 5, 30], [2, 6, 36], [3, 7, 42], [3, 8, 48], [4, 9, 54], [5, 10, 60], [6, 11, 66]],signalSpeed = 6) == [30, 36, 32, 19, 10, 10, 10, 0, 0, 0, 0, 0]\n assert candidate(edges = [[0, 1, 7], [0, 2, 14], [1, 3, 21], [1, 4, 28], [2, 5, 35], [2, 6, 42], [3, 7, 49], [3, 8, 56], [4, 9, 63], [4, 10, 70]],signalSpeed = 7) == [21, 33, 17, 17, 17, 0, 0, 0, 0, 0, 0]\n assert candidate(edges = [[0, 1, 11], [1, 2, 22], [2, 3, 33], [3, 4, 44], [4, 5, 55], [5, 6, 66], [6, 7, 77], [7, 8, 88], [8, 9, 99], [9, 10, 110]],signalSpeed = 11) == [0, 9, 16, 21, 24, 25, 24, 21, 16, 9, 0]\n assert candidate(edges = [[0, 1, 1], [0, 2, 2], [0, 3, 3], [0, 4, 4], [1, 5, 5], [1, 6, 6], [2, 7, 7], [2, 8, 8], [3, 9, 9], [3, 10, 10], [4, 11, 11], [4, 12, 12]],signalSpeed = 1) == [54, 21, 21, 21, 21, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(edges = [[0, 1, 9], [1, 2, 18], [2, 3, 27], [3, 4, 36], [4, 5, 45], [5, 6, 54], [6, 7, 63], [7, 8, 72], [8, 9, 81], [9, 10, 90], [10, 11, 99], [11, 12, 108]],signalSpeed = 9) == [0, 11, 20, 27, 32, 35, 36, 35, 32, 27, 20, 11, 0]\n assert candidate(edges = [[0, 1, 7], [0, 2, 14], [1, 3, 21], [1, 4, 28], [2, 5, 35], [2, 6, 42], [3, 7, 49], [3, 8, 56], [4, 9, 63], [5, 10, 70], [6, 11, 77]],signalSpeed = 7) == [30, 36, 32, 19, 10, 10, 10, 0, 0, 0, 0, 0]\n assert candidate(edges = [[0, 1, 7], [0, 2, 14], [1, 3, 21], [1, 4, 28], [2, 5, 35], [2, 6, 42], [3, 7, 49], [3, 8, 56], [4, 9, 63], [4, 10, 70], [5, 11, 77], [5, 12, 84], [6, 13, 91], [6, 14, 98]],signalSpeed = 7) == [49, 57, 57, 25, 25, 25, 25, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(edges = [[0, 1, 17], [0, 2, 34], [1, 3, 51], [1, 4, 68], [2, 5, 85], [2, 6, 102], [3, 7, 119], [3, 8, 136], [4, 9, 153], [4, 10, 170], [5, 11, 187], [5, 12, 204], [6, 13, 221], [6, 14, 238]],signalSpeed = 17) == [49, 57, 57, 25, 25, 25, 25, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(edges = [[0, 1, 2], [1, 2, 4], [2, 3, 8], [3, 4, 16], [4, 5, 32], [5, 6, 64], [6, 7, 128], [7, 8, 256], [8, 9, 512]],signalSpeed = 2) == [0, 8, 14, 18, 20, 20, 18, 14, 8, 0]\n assert candidate(edges = [[0, 1, 100000], [1, 2, 200000], [2, 3, 300000], [3, 4, 400000], [4, 5, 500000], [5, 6, 600000], [6, 7, 700000]],signalSpeed = 100000) == [0, 6, 10, 12, 12, 10, 6, 0]\n assert candidate(edges = [[0, 1, 2], [1, 2, 4], [2, 3, 8], [3, 4, 16], [4, 5, 32], [5, 6, 64]],signalSpeed = 2) == [0, 5, 8, 9, 8, 5, 0]\n assert candidate(edges = [[0, 1, 10], [0, 2, 20], [0, 3, 30], [1, 4, 40], [1, 5, 50], [2, 6, 60], [2, 7, 70], [3, 8, 80], [3, 9, 90], [4, 10, 100], [5, 11, 110], [6, 12, 120]],signalSpeed = 10) == [47, 36, 29, 21, 11, 11, 11, 0, 0, 0, 0, 0, 0]\n assert candidate(edges = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10]],signalSpeed = 2) == [0, 4, 0, 2, 6, 6, 2, 0, 4, 0]\n assert candidate(edges = [[0, 1, 5], [1, 2, 10], [1, 3, 15], [2, 4, 20], [3, 5, 25], [4, 6, 30], [5, 7, 35]],signalSpeed = 5) == [0, 15, 10, 10, 6, 6, 0, 0]\n assert candidate(edges = [[0, 1, 2], [1, 2, 4], [2, 3, 8], [3, 4, 16], [4, 5, 32], [5, 6, 64], [6, 7, 128], [7, 8, 256], [8, 9, 512], [9, 10, 1024]],signalSpeed = 2) == [0, 9, 16, 21, 24, 25, 24, 21, 16, 9, 0]\n assert candidate(edges = [[0, 1, 3], [0, 2, 6], [1, 3, 9], [1, 4, 12], [2, 5, 15], [2, 6, 18]],signalSpeed = 3) == [9, 9, 9, 0, 0, 0, 0]\n assert candidate(edges = [[0, 1, 7], [1, 2, 14], [2, 3, 21], [3, 4, 28], [4, 5, 35], [5, 6, 42], [6, 7, 49], [7, 8, 56]],signalSpeed = 7) == [0, 7, 12, 15, 16, 15, 12, 7, 0]\n assert candidate(edges = [[0, 1, 6], [1, 2, 12], [1, 3, 18], [3, 4, 24], [3, 5, 30], [5, 6, 36], [5, 7, 42], [7, 8, 48], [7, 9, 54], [9, 10, 60], [10, 11, 66]],signalSpeed = 6) == [0, 19, 0, 31, 0, 35, 0, 31, 0, 18, 10, 0]\n assert candidate(edges = [[0, 1, 10], [0, 2, 20], [1, 3, 15], [1, 4, 25], [2, 5, 30], [2, 6, 35]],signalSpeed = 5) == [9, 9, 9, 0, 0, 0, 0]\n assert candidate(edges = [[0, 1, 7], [0, 2, 14], [1, 3, 21], [1, 4, 28], [2, 5, 35], [2, 6, 42], [3, 7, 49], [4, 8, 56], [5, 9, 63], [6, 10, 70], [7, 11, 77], [8, 12, 84], [9, 13, 91], [10, 14, 98], [11, 15, 105], [12, 16, 112], [13, 17, 119], [14, 18, 126]],signalSpeed = 7) == [81, 96, 96, 45, 45, 45, 45, 32, 32, 32, 32, 17, 17, 17, 17, 0, 0, 0, 0]\n assert candidate(edges = [[0, 1, 3], [0, 2, 9], [1, 3, 12], [1, 4, 6], [2, 5, 15], [2, 6, 3]],signalSpeed = 3) == [9, 9, 9, 0, 0, 0, 0]\n assert candidate(edges = [[0, 1, 1], [0, 2, 1], [0, 3, 1], [0, 4, 1], [1, 5, 1], [1, 6, 1], [2, 7, 1], [2, 8, 1], [3, 9, 1], [3, 10, 1], [4, 11, 1], [4, 12, 1]],signalSpeed = 1) == [54, 21, 21, 21, 21, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(edges = [[0, 1, 5], [0, 2, 10], [0, 3, 15], [1, 4, 20], [2, 5, 25], [3, 6, 30]],signalSpeed = 5) == [12, 5, 5, 5, 0, 0, 0]\n assert candidate(edges = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50], [5, 6, 60], [6, 7, 70]],signalSpeed = 5) == [0, 6, 10, 12, 12, 10, 6, 0]\n assert candidate(edges = [[0, 1, 5], [0, 2, 10], [1, 3, 15], [1, 4, 20], [2, 5, 25], [2, 6, 30], [3, 7, 35], [4, 8, 40], [5, 9, 45], [6, 10, 50], [7, 11, 55], [8, 12, 60], [9, 13, 65], [10, 14, 70]],signalSpeed = 5) == [49, 57, 57, 24, 24, 24, 24, 13, 13, 13, 13, 0, 0, 0, 0]\n assert candidate(edges = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50], [5, 6, 60], [6, 7, 70], [7, 8, 80], [8, 9, 90], [9, 10, 100], [10, 11, 110]],signalSpeed = 10) == [0, 10, 18, 24, 28, 30, 30, 28, 24, 18, 10, 0]\n assert candidate(edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [1, 4, 4], [2, 5, 5], [2, 6, 6], [3, 7, 7], [3, 8, 8], [4, 9, 9], [5, 10, 10], [6, 11, 11]],signalSpeed = 1) == [30, 36, 32, 19, 10, 10, 10, 0, 0, 0, 0, 0]\n assert candidate(edges = [[0, 1, 11], [1, 2, 22], [2, 3, 33], [3, 4, 44], [4, 5, 55], [5, 6, 66], [6, 7, 77], [7, 8, 88], [8, 9, 99]],signalSpeed = 33) == [0, 0, 5, 8, 1, 9, 8, 0, 5, 0]\n assert candidate(edges = [[0, 1, 100], [1, 2, 200], [2, 3, 300], [3, 4, 400], [4, 5, 500], [5, 6, 600], [6, 7, 700], [7, 8, 800]],signalSpeed = 100) == [0, 7, 12, 15, 16, 15, 12, 7, 0]\n assert candidate(edges = [[0, 1, 3], [1, 2, 4], [2, 3, 5], [3, 4, 6], [4, 5, 7], [5, 6, 8], [6, 7, 9]],signalSpeed = 3) == [0, 4, 0, 6, 6, 0, 4, 0]\n assert candidate(edges = [[0, 1, 5], [1, 2, 10], [2, 3, 15], [3, 4, 20], [4, 5, 25], [5, 6, 30], [6, 7, 35], [7, 8, 40]],signalSpeed = 7) == [0, 0, 0, 0, 0, 1, 1, 0, 0]\n assert candidate(edges = [[0, 1, 11], [0, 2, 22], [2, 3, 33], [2, 4, 44], [4, 5, 55], [4, 6, 66], [6, 7, 77], [6, 8, 88], [8, 9, 99], [8, 10, 110], [9, 11, 121], [11, 12, 132]],signalSpeed = 11) == [11, 0, 29, 0, 39, 0, 41, 0, 35, 20, 0, 11, 0]\n assert candidate(edges = [[0, 1, 5], [1, 2, 15], [1, 3, 25], [3, 4, 35], [3, 5, 45], [5, 6, 55], [5, 7, 65], [7, 8, 75], [7, 9, 85], [9, 10, 95]],signalSpeed = 5) == [0, 17, 0, 27, 0, 29, 0, 23, 0, 9, 0]\n assert candidate(edges = [[0, 1, 8], [0, 2, 16], [1, 3, 24], [1, 4, 32], [2, 5, 40], [2, 6, 48], [3, 7, 56], [3, 8, 64], [4, 9, 72], [4, 10, 80], [5, 11, 88], [5, 12, 96], [6, 13, 104], [6, 14, 112]],signalSpeed = 8) == [49, 57, 57, 25, 25, 25, 25, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(edges = [[0, 1, 11], [0, 2, 22], [1, 3, 33], [1, 4, 44], [2, 5, 55], [2, 6, 66], [3, 7, 77], [4, 8, 88], [5, 9, 99], [6, 10, 110], [7, 11, 121], [8, 12, 132], [9, 13, 143], [10, 14, 154], [11, 15, 165], [12, 16, 176], [13, 17, 187], [14, 18, 198], [15, 19, 209], [16, 20, 220]],signalSpeed = 11) == [99, 125, 112, 64, 64, 51, 51, 51, 51, 36, 36, 36, 36, 19, 19, 19, 19, 0, 0, 0, 0]\n assert candidate(edges = [[0, 1, 19], [0, 2, 38], [1, 3, 57], [1, 4, 76], [2, 5, 95], [2, 6, 114], [3, 7, 133], [3, 8, 152], [4, 9, 171], [4, 10, 190], [5, 11, 209], [5, 12, 228], [6, 13, 247], [6, 14, 266]],signalSpeed = 19) == [49, 57, 57, 25, 25, 25, 25, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(edges = [[0, 1, 5], [1, 2, 10], [2, 3, 15], [3, 4, 20], [4, 5, 25], [5, 6, 30], [6, 7, 35], [7, 8, 40], [8, 9, 45]],signalSpeed = 5) == [0, 8, 14, 18, 20, 20, 18, 14, 8, 0]\n assert candidate(edges = [[0, 1, 13], [1, 2, 26], [2, 3, 39], [3, 4, 52], [4, 5, 65], [5, 6, 78], [6, 7, 91], [7, 8, 104], [8, 9, 117], [9, 10, 130]],signalSpeed = 13) == [0, 9, 16, 21, 24, 25, 24, 21, 16, 9, 0]\n assert candidate(edges = [[0, 1, 15], [1, 2, 30], [2, 3, 45], [3, 4, 60], [4, 5, 75], [5, 6, 90], [6, 7, 105], [7, 8, 120]],signalSpeed = 15) == [0, 7, 12, 15, 16, 15, 12, 7, 0]\n assert candidate(edges = [[0, 1, 3], [0, 2, 9], [2, 3, 27], [2, 4, 81], [4, 5, 243], [4, 6, 729], [6, 7, 2187], [6, 8, 6561], [8, 9, 19683], [8, 10, 59049]],signalSpeed = 3) == [9, 0, 23, 0, 29, 0, 27, 0, 17, 0, 0]\n assert candidate(edges = [[0, 1, 7], [1, 2, 14], [2, 3, 21], [3, 4, 28], [4, 5, 35], [5, 6, 42], [6, 7, 49], [7, 8, 56], [8, 9, 63], [9, 10, 70]],signalSpeed = 7) == [0, 9, 16, 21, 24, 25, 24, 21, 16, 9, 0]\n assert candidate(edges = [[0, 1, 3], [1, 2, 9], [2, 3, 12], [1, 4, 7], [4, 5, 14], [5, 6, 8]],signalSpeed = 3) == [0, 5, 3, 0, 0, 0, 0]\n assert candidate(edges = [[0, 1, 13], [0, 2, 26], [1, 3, 39], [1, 4, 52], [2, 5, 65], [2, 6, 78], [3, 7, 91], [3, 8, 104], [4, 9, 117], [4, 10, 130], [5, 11, 143], [5, 12, 156], [6, 13, 169], [6, 14, 182]],signalSpeed = 13) == [49, 57, 57, 25, 25, 25, 25, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(edges = [[0, 1, 1], [0, 2, 3], [0, 3, 5], [1, 4, 7], [1, 5, 9], [2, 6, 11], [2, 7, 13], [3, 8, 15], [3, 9, 17]],signalSpeed = 1) == [27, 15, 15, 15, 0, 0, 0, 0, 0, 0]\n assert candidate(edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9]],signalSpeed = 3) == [0, 0, 5, 8, 1, 9, 8, 0, 5, 0]\n assert candidate(edges = [[0, 1, 10], [0, 2, 20], [0, 3, 30], [1, 4, 40], [1, 5, 50], [2, 6, 60], [2, 7, 70], [3, 8, 80], [3, 9, 90]],signalSpeed = 10) == [27, 15, 15, 15, 0, 0, 0, 0, 0, 0]\n assert candidate(edges = [[0, 1, 11], [0, 2, 22], [1, 3, 33], [1, 4, 44], [2, 5, 55], [2, 6, 66], [3, 7, 77], [3, 8, 88], [4, 9, 99], [4, 10, 110], [5, 11, 121], [5, 12, 132], [6, 13, 143], [6, 14, 154]],signalSpeed = 11) == [49, 57, 57, 25, 25, 25, 25, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(edges = [[0, 1, 5], [0, 2, 10], [1, 3, 15], [1, 4, 20], [2, 5, 25], [2, 6, 30], [3, 7, 35], [3, 8, 40], [4, 9, 45], [4, 10, 50], [5, 11, 55], [5, 12, 60], [6, 13, 65], [6, 14, 70]],signalSpeed = 5) == [49, 57, 57, 25, 25, 25, 25, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(edges = [[0, 1, 10], [0, 2, 20], [1, 3, 30], [1, 4, 40], [2, 5, 50], [2, 6, 60], [5, 7, 70], [5, 8, 80]],signalSpeed = 10) == [15, 13, 19, 0, 0, 13, 0, 0, 0]\n assert candidate(edges = [[0, 1, 13], [1, 2, 26], [2, 3, 39], [3, 4, 52], [4, 5, 65], [5, 6, 78], [6, 7, 91], [7, 8, 104], [8, 9, 117], [9, 10, 130], [10, 11, 143]],signalSpeed = 13) == [0, 10, 18, 24, 28, 30, 30, 28, 24, 18, 10, 0]\n assert candidate(edges = [[0, 1, 6], [1, 2, 12], [2, 3, 18], [3, 4, 24], [4, 5, 30], [5, 6, 36], [6, 7, 42], [7, 8, 48], [8, 9, 54]],signalSpeed = 6) == [0, 8, 14, 18, 20, 20, 18, 14, 8, 0]\n assert candidate(edges = [[0, 1, 2], [1, 2, 4], [2, 3, 6], [3, 4, 8], [4, 5, 10], [5, 6, 12], [6, 7, 14], [7, 8, 16], [8, 9, 18], [9, 10, 20]],signalSpeed = 2) == [0, 9, 16, 21, 24, 25, 24, 21, 16, 9, 0]\n assert candidate(edges = [[0, 1, 3], [1, 2, 9], [2, 3, 27], [3, 4, 81], [4, 5, 243], [5, 6, 729], [6, 7, 2187], [7, 8, 6561], [8, 9, 19683]],signalSpeed = 3) == [0, 8, 14, 18, 20, 20, 18, 14, 8, 0]\n assert candidate(edges = [[0, 1, 7], [0, 2, 14], [1, 3, 21], [1, 4, 28], [2, 5, 35], [2, 6, 42], [3, 7, 49], [4, 8, 56], [5, 9, 63]],signalSpeed = 7) == [20, 24, 20, 8, 8, 8, 0, 0, 0, 0]\n assert candidate(edges = [[0, 1, 9], [1, 2, 18], [2, 3, 27], [3, 4, 36], [4, 5, 45], [5, 6, 54], [6, 7, 63], [7, 8, 72], [8, 9, 81], [9, 10, 90], [10, 11, 99]],signalSpeed = 9) == [0, 10, 18, 24, 28, 30, 30, 28, 24, 18, 10, 0]\n assert candidate(edges = [[0, 1, 17], [1, 2, 34], [2, 3, 51], [3, 4, 68], [4, 5, 85], [5, 6, 102], [6, 7, 119], [7, 8, 136], [8, 9, 153], [9, 10, 170], [10, 11, 187], [11, 12, 204]],signalSpeed = 17) == [0, 11, 20, 27, 32, 35, 36, 35, 32, 27, 20, 11, 0]\n assert candidate(edges = [[0, 1, 2], [1, 2, 4], [2, 3, 6], [3, 4, 8], [4, 5, 10], [5, 6, 12], [6, 7, 14], [7, 8, 16], [8, 9, 18]],signalSpeed = 2) == [0, 8, 14, 18, 20, 20, 18, 14, 8, 0]\n assert candidate(edges = [[0, 1, 5], [1, 2, 10], [2, 3, 15], [3, 4, 20], [4, 5, 25], [5, 6, 30], [6, 7, 35], [7, 8, 40]],signalSpeed = 5) == [0, 7, 12, 15, 16, 15, 12, 7, 0]\n assert candidate(edges = [[0, 1, 23], [1, 2, 46], [2, 3, 69], [3, 4, 92], [4, 5, 115], [5, 6, 138], [6, 7, 161], [7, 8, 184], [8, 9, 207], [9, 10, 230], [10, 11, 253], [11, 12, 276], [12, 13, 299], [13, 14, 322]],signalSpeed = 23) == [0, 13, 24, 33, 40, 45, 48, 49, 48, 45, 40, 33, 24, 13, 0]\n assert candidate(edges = [[0, 1, 12], [0, 2, 24], [1, 3, 36], [1, 4, 48], [2, 5, 60], [2, 6, 72], [3, 7, 84], [3, 8, 96], [4, 9, 108], [4, 10, 120], [5, 11, 132], [5, 12, 144], [6, 13, 156], [6, 14, 168]],signalSpeed = 12) == [49, 57, 57, 25, 25, 25, 25, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(edges = [[0, 1, 100], [1, 2, 200], [2, 3, 300], [3, 4, 400], [4, 5, 500], [5, 6, 600], [6, 7, 700], [7, 8, 800], [8, 9, 900]],signalSpeed = 50) == [0, 8, 14, 18, 20, 20, 18, 14, 8, 0]\n assert candidate(edges = [[0, 1, 19], [1, 2, 38], [2, 3, 57], [3, 4, 76], [4, 5, 95], [5, 6, 114], [6, 7, 133], [7, 8, 152], [8, 9, 171], [9, 10, 190], [10, 11, 209], [11, 12, 228], [12, 13, 247]],signalSpeed = 19) == [0, 12, 22, 30, 36, 40, 42, 42, 40, 36, 30, 22, 12, 0]\n assert candidate(edges = [[0, 1, 11], [1, 2, 22], [2, 3, 33], [3, 4, 44], [4, 5, 55], [5, 6, 66], [6, 7, 77], [7, 8, 88], [8, 9, 99]],signalSpeed = 11) == [0, 8, 14, 18, 20, 20, 18, 14, 8, 0]\n assert candidate(edges = [[0, 1, 11], [0, 2, 22], [0, 3, 33], [1, 4, 44], [1, 5, 55], [2, 6, 66], [2, 7, 77], [3, 8, 88], [3, 9, 99], [4, 10, 110], [4, 11, 121], [5, 12, 132], [5, 13, 143], [6, 14, 154], [6, 15, 165], [7, 16, 176], [7, 17, 187], [8, 18, 198], [8, 19, 209], [9, 20, 220], [9, 21, 231]],signalSpeed = 11) == [147, 99, 99, 99, 39, 39, 39, 39, 39, 39, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(edges = [[0, 1, 11], [1, 2, 22], [1, 3, 33], [2, 4, 44], [2, 5, 55], [3, 6, 66], [3, 7, 77], [4, 8, 88], [5, 9, 99], [6, 10, 110], [7, 11, 121]],signalSpeed = 11) == [0, 35, 32, 32, 10, 10, 10, 10, 0, 0, 0, 0]\n assert candidate(edges = [[0, 1, 3], [1, 2, 6], [1, 3, 9], [2, 4, 12], [2, 5, 15], [3, 6, 18], [3, 7, 21]],signalSpeed = 3) == [0, 15, 11, 11, 0, 0, 0, 0]\n assert candidate(edges = [[0, 1, 2], [0, 2, 4], [0, 3, 6], [1, 4, 8], [1, 5, 10], [2, 6, 12], [2, 7, 14], [3, 8, 16], [3, 9, 18]],signalSpeed = 2) == [27, 15, 15, 15, 0, 0, 0, 0, 0, 0]\n assert candidate(edges = [[0, 1, 6], [1, 2, 12], [2, 3, 18], [3, 4, 24], [4, 5, 30], [5, 6, 36], [6, 7, 42], [7, 8, 48], [8, 9, 54], [9, 10, 60], [10, 11, 66]],signalSpeed = 6) == [0, 10, 18, 24, 28, 30, 30, 28, 24, 18, 10, 0]\n assert candidate(edges = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50], [5, 6, 60], [6, 7, 70]],signalSpeed = 10) == [0, 6, 10, 12, 12, 10, 6, 0]\n assert candidate(edges = [[0, 1, 3], [0, 2, 6], [1, 3, 9], [1, 4, 12], [2, 5, 15], [2, 6, 18], [3, 7, 21], [4, 8, 24], [5, 9, 27], [6, 10, 30]],signalSpeed = 3) == [25, 28, 28, 9, 9, 9, 9, 0, 0, 0, 0]\n assert candidate(edges = [[0, 1, 2], [0, 2, 4], [1, 3, 6], [1, 4, 8], [2, 5, 10], [2, 6, 12]],signalSpeed = 2) == [9, 9, 9, 0, 0, 0, 0]\n assert candidate(edges = [[0, 1, 7], [1, 2, 14], [2, 3, 21], [3, 4, 28], [4, 5, 35], [5, 6, 42], [6, 7, 49], [7, 8, 56], [8, 9, 63]],signalSpeed = 7) == [0, 8, 14, 18, 20, 20, 18, 14, 8, 0]\n assert candidate(edges = [[0, 1, 17], [1, 2, 34], [1, 3, 51], [2, 4, 68], [2, 5, 85], [3, 6, 102], [3, 7, 119], [4, 8, 136], [5, 9, 153], [6, 10, 170], [7, 11, 187], [8, 12, 204], [9, 13, 221], [10, 14, 238]],signalSpeed = 17) == [0, 55, 57, 51, 24, 24, 24, 13, 13, 13, 13, 0, 0, 0, 0]\n assert candidate(edges = [[0, 1, 14], [0, 2, 28], [1, 3, 42], [1, 4, 56], [2, 5, 70], [2, 6, 84], [4, 7, 98], [4, 8, 112], [5, 9, 126], [5, 10, 140], [7, 11, 154], [7, 12, 168]],signalSpeed = 14) == [35, 41, 35, 0, 35, 21, 0, 21, 0, 0, 0, 0, 0]\n assert candidate(edges = [[0, 1, 3], [1, 2, 6], [2, 3, 9], [3, 4, 12], [4, 5, 15], [5, 6, 18]],signalSpeed = 3) == [0, 5, 8, 9, 8, 5, 0]\n"}, "metadata": {"canonical_parameter_names": ["edges", "signalSpeed"], "leetcode_dataset_entry_point": "Solution().countPairsOfConnectableServers", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector countPairsOfConnectableServers(vector>& edges, int signalSpeed) {", "container": "Solution", "callable": "countPairsOfConnectableServers", "parameters": [{"name": "edges", "type": "vector>&"}, {"name": "signalSpeed", "type": "int"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3068, "task_id": "find-the-maximum-sum-of-node-values", "difficulty": "Hard", "problem_description": "There exists an undirected tree with n nodes numbered 0 to n - 1. You are given a 0-indexed 2D integer array edges of length n - 1, where edges[i] = [ui, vi] indicates that there is an edge between nodes ui and vi in the tree. You are also given a positive integer k, and a 0-indexed array of non-negative integers nums of length n, where nums[i] represents the value of the node numbered i.\nAlice wants the sum of values of tree nodes to be maximum, for which Alice can perform the following operation any number of times (including zero) on the tree:\n\nChoose any edge [u, v] connecting the nodes u and v, and update their values as follows:\n\n\t\nnums[u] = nums[u] XOR k\nnums[v] = nums[v] XOR k\n\n\n\nReturn the maximum possible sum of the values Alice can achieve by performing the operation any number of times.\n \nExample 1:\n\n\nInput: nums = [1,2,1], k = 3, edges = [[0,1],[0,2]]\nOutput: 6\nExplanation: Alice can achieve the maximum sum of 6 using a single operation:\n- Choose the edge [0,2]. nums[0] and nums[2] become: 1 XOR 3 = 2, and the array nums becomes: [1,2,1] -> [2,2,2].\nThe total sum of values is 2 + 2 + 2 = 6.\nIt can be shown that 6 is the maximum achievable sum of values.\n\nExample 2:\n\n\nInput: nums = [2,3], k = 7, edges = [[0,1]]\nOutput: 9\nExplanation: Alice can achieve the maximum sum of 9 using a single operation:\n- Choose the edge [0,1]. nums[0] becomes: 2 XOR 7 = 5 and nums[1] become: 3 XOR 7 = 4, and the array nums becomes: [2,3] -> [5,4].\nThe total sum of values is 5 + 4 = 9.\nIt can be shown that 9 is the maximum achievable sum of values.\n\nExample 3:\n\n\nInput: nums = [7,7,7,7,7,7], k = 3, edges = [[0,1],[0,2],[0,3],[0,4],[0,5]]\nOutput: 42\nExplanation: The maximum achievable sum is 42 which can be achieved by Alice performing no operations.\n\n \nConstraints:\n\n2 <= n == nums.length <= 2 * 104\n1 <= k <= 109\n0 <= nums[i] <= 109\nedges.length == n - 1\nedges[i].length == 2\n0 <= edges[i][0], edges[i][1] <= n - 1\nThe input is generated such that edges represent a valid tree.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [0, 1, 2, 3, 4],k = 5,edges = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 26\n assert candidate(nums = [7, 7, 7, 7, 7, 7],k = 3,edges = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5]]) == 42\n assert candidate(nums = [1, 2, 3, 4, 5],k = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 51\n assert candidate(nums = [1, 2, 1],k = 3,edges = [[0, 1], [0, 2]]) == 6\n assert candidate(nums = [5, 9, 14],k = 8,edges = [[0, 1], [1, 2]]) == 28\n assert candidate(nums = [0, 0, 0, 0],k = 1,edges = [[0, 1], [1, 2], [2, 3]]) == 4\n assert candidate(nums = [2, 3],k = 7,edges = [[0, 1]]) == 9\n assert candidate(nums = [10, 10, 10, 10],k = 1,edges = [[0, 1], [1, 2], [2, 3]]) == 44\n assert candidate(nums = [0, 0, 0],k = 5,edges = [[0, 1], [1, 2]]) == 10\n assert candidate(nums = [5, 9, 14, 10],k = 6,edges = [[0, 1], [1, 2], [1, 3]]) == 46\n assert candidate(nums = [5, 9, 4, 8],k = 6,edges = [[0, 1], [1, 2], [2, 3]]) == 38\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256],k = 255,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8]]) == 2297\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 2,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 108\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],k = 3,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 2075\n assert candidate(nums = [100, 200, 300, 400, 500],k = 50,edges = [[0, 1], [0, 2], [1, 3], [1, 4]]) == 1568\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 9,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]]) == 306\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0],k = 1,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == 8\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 10\n assert candidate(nums = [100, 200, 300, 400, 500, 600],k = 123,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == 2234\n assert candidate(nums = [100000000, 90000000, 80000000, 70000000, 60000000, 50000000],k = 123456789,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == 514688170\n assert candidate(nums = [123456789, 987654321, 111222333, 444555666, 777888999],k = 987654321,edges = [[0, 1], [0, 2], [1, 3], [2, 4]]) == 4257254234\n assert candidate(nums = [123456789, 987654321, 111111111, 222222222, 333333333],k = 987654321,edges = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 4656069870\n assert candidate(nums = [1000, 900, 800, 700, 600],k = 150,edges = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 4268\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 30\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 15,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 592\n assert candidate(nums = [123456789, 987654321, 112233445, 556677889, 998877665, 443322110],k = 987654321,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == 5049931145\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70],k = 25,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == 316\n assert candidate(nums = [10, 20, 30, 40, 50, 60],k = 15,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == 228\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991],k = 1000000007,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 9999999955\n assert candidate(nums = [0, 1000000000, 500000000, 250000000, 125000000],k = 987654321,edges = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 4554116228\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29]]) == 30\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35],k = 50,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == 332\n assert candidate(nums = [1, 10, 100, 1000, 10000],k = 1234,edges = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 15531\n assert candidate(nums = [10, 20, 30, 40, 50, 60],k = 13,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == 228\n assert candidate(nums = [10, 20, 30, 40, 50, 60],k = 25,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5]]) == 228\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 1000000000,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]]) == 20000000000\n assert candidate(nums = [10, 21, 32, 43, 54, 65, 76, 87, 98, 109],k = 101,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 859\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 11,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 103\n assert candidate(nums = [10, 20, 30, 40, 50],k = 15,edges = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 168\n assert candidate(nums = [20, 15, 10, 5, 0],k = 25,edges = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 114\n assert candidate(nums = [100, 200, 300, 400, 500],k = 123,edges = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 1634\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 1024,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == 14456\n assert candidate(nums = [10, 20, 30, 40, 50],k = 15,edges = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 168\n assert candidate(nums = [10, 15, 20, 25, 30],k = 17,edges = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 132\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 1,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 110\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80],k = 23,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == 404\n assert candidate(nums = [12, 13, 14, 15, 16, 17, 18, 19, 20],k = 7,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == 160\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 11,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 193\n assert candidate(nums = [123456789, 987654321, 234567890, 345678901, 456789012, 567890123, 678901234, 789012345],k = 890123456,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == 6162095767\n assert candidate(nums = [9, 18, 27, 36, 45],k = 15,edges = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 153\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15],k = 16,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == 192\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800],k = 123,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == 3804\n assert candidate(nums = [9, 14, 3, 5, 8, 12],k = 7,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5]]) == 63\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 3,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == 89\n assert candidate(nums = [10, 20, 30, 40, 50, 60],k = 15,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5]]) == 228\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000],k = 1,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7]]) == 8000000008\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14]]) == 15\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63],k = 23,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == 288\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 11,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]]) == 216\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125],k = 1000000000,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]]) == 9340892827\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996],k = 500000000,edges = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 4999999990\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1],k = 1,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 7], [5, 7], [6, 7]]) == 8\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 7,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]]) == 293\n assert candidate(nums = [8, 16, 32, 64, 128, 256],k = 15,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == 578\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40],k = 17,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == 244\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000],k = 123456789,edges = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 1976228234\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 1,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == 49\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 31,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 353\n assert candidate(nums = [10, 21, 32, 43, 54, 65, 76, 87, 98, 109],k = 12,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 643\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 50,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 5636\n assert candidate(nums = [123, 456, 789, 101, 202, 303, 404, 505, 606, 707],k = 111,edges = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [1, 6], [2, 7], [2, 8], [3, 9]]) == 4400\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]]) == 16\n assert candidate(nums = [999, 888, 777, 666, 555, 444, 333, 222, 111, 0],k = 456,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 6387\n assert candidate(nums = [12, 14, 16, 18, 20, 22, 24, 26, 28],k = 13,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == 216\n assert candidate(nums = [1, 3, 5, 7, 9, 11],k = 15,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == 64\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 30,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 614\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 15,edges = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [1, 6], [2, 7], [2, 8], [3, 9]]) == 109\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995],k = 123456789,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == 6115696553\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 7,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 73\n assert candidate(nums = [1, 2, 3, 4, 5],k = 1000000000,edges = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 4000000015\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 1,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 49\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 1,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 10\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800],k = 255,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == 4092\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],k = 255,edges = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [1, 6], [2, 7], [2, 8], [3, 9]]) == 3063\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000],k = 123456789,edges = [[0, 1], [1, 2], [2, 3]]) == 1875000000\n assert candidate(nums = [100, 200, 300, 400, 500],k = 99,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [0, 2]]) == 1634\n assert candidate(nums = [12345, 67890, 54321, 98765, 43210, 87654, 32109, 76543],k = 11111,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == 510661\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 21,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]]) == 434\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996],k = 999999995,edges = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 4999999990\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],k = 255,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 4343\n assert candidate(nums = [123456789, 987654321, 135792468, 246813579, 1112131415],k = 987654321,edges = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 5774158170\n"}, "metadata": {"canonical_parameter_names": ["nums", "k", "edges"], "leetcode_dataset_entry_point": "Solution().maximumValueSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "long long maximumValueSum(vector& nums, int k, vector>& edges) {", "container": "Solution", "callable": "maximumValueSum", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "k", "type": "int"}, {"name": "edges", "type": "vector>&"}], "return_type": "long long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3069, "task_id": "distribute-elements-into-two-arrays-i", "difficulty": "Easy", "problem_description": "You are given a 1-indexed array of distinct integers nums of length n.\nYou need to distribute all the elements of nums between two arrays arr1 and arr2 using n operations. In the first operation, append nums[1] to arr1. In the second operation, append nums[2] to arr2. Afterwards, in the ith operation:\n\nIf the last element of arr1 is greater than the last element of arr2, append nums[i] to arr1. Otherwise, append nums[i] to arr2.\n\nThe array result is formed by concatenating the arrays arr1 and arr2. For example, if arr1 == [1,2,3] and arr2 == [4,5,6], then result = [1,2,3,4,5,6].\nReturn the array result.\n \nExample 1:\n\nInput: nums = [2,1,3]\nOutput: [2,3,1]\nExplanation: After the first 2 operations, arr1 = [2] and arr2 = [1].\nIn the 3rd operation, as the last element of arr1 is greater than the last element of arr2 (2 > 1), append nums[3] to arr1.\nAfter 3 operations, arr1 = [2,3] and arr2 = [1].\nHence, the array result formed by concatenation is [2,3,1].\n\nExample 2:\n\nInput: nums = [5,4,3,8]\nOutput: [5,3,4,8]\nExplanation: After the first 2 operations, arr1 = [5] and arr2 = [4].\nIn the 3rd operation, as the last element of arr1 is greater than the last element of arr2 (5 > 4), append nums[3] to arr1, hence arr1 becomes [5,3].\nIn the 4th operation, as the last element of arr2 is greater than the last element of arr1 (4 > 3), append nums[4] to arr2, hence arr2 becomes [4,8].\nAfter 4 operations, arr1 = [5,3] and arr2 = [4,8].\nHence, the array result formed by concatenation is [5,3,4,8].\n\n \nConstraints:\n\n3 <= n <= 50\n1 <= nums[i] <= 100\nAll elements in nums are distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 3, 2, 4, 5]) == [1, 3, 2, 4, 5]\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1]) == [7, 5, 3, 1, 6, 4, 2]\n assert candidate(nums = [3, 1, 2, 5, 4]) == [3, 2, 5, 4, 1]\n assert candidate(nums = [10, 20, 30, 5, 15]) == [10, 15, 20, 30, 5]\n assert candidate(nums = [1, 3, 2, 4, 6, 5]) == [1, 3, 2, 4, 6, 5]\n assert candidate(nums = [5, 4, 3, 8]) == [5, 3, 4, 8]\n assert candidate(nums = [2, 1, 3]) == [2, 3, 1]\n assert candidate(nums = [8, 9, 7, 6, 10, 5]) == [8, 6, 9, 7, 10, 5]\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == [50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 49, 47, 45, 43, 41, 39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11]\n assert candidate(nums = [10, 20, 15, 25, 30]) == [10, 20, 15, 25, 30]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [10, 8, 6, 4, 2, 9, 7, 5, 3, 1]\n assert candidate(nums = [3, 5, 2, 4, 6, 8, 1]) == [3, 4, 6, 8, 1, 5, 2]\n assert candidate(nums = [3, 1, 4, 2, 5]) == [3, 4, 2, 5, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]\n assert candidate(nums = [8, 2, 14, 10, 6, 12, 4, 1, 9, 5, 11, 7, 13, 3]) == [8, 14, 10, 6, 12, 4, 1, 2, 9, 5, 11, 7, 13, 3]\n assert candidate(nums = [6, 3, 9, 2, 8, 5, 11, 4, 10, 7]) == [6, 9, 2, 3, 8, 5, 11, 4, 10, 7]\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [30, 28, 26, 24, 22, 1, 29, 27, 25, 23, 21, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [7, 3, 9, 1, 5, 11, 13, 2, 8, 6, 10, 4]) == [7, 9, 1, 3, 5, 11, 13, 2, 8, 6, 10, 4]\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91, 11, 90, 12, 89, 13, 88, 14, 87, 15, 86]) == [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91, 11, 90, 12, 89, 13, 88, 14, 87, 15, 86]\n assert candidate(nums = [5, 20, 3, 10, 8, 15, 6, 25, 12, 30, 18, 35, 22, 40, 26, 45, 32, 50, 38, 1]) == [5, 10, 8, 15, 6, 25, 12, 30, 18, 35, 22, 40, 26, 45, 32, 50, 38, 1, 20, 3]\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]\n assert candidate(nums = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == [25, 23, 21, 19, 17, 15, 13, 11, 24, 22, 20, 18, 16, 14, 12]\n assert candidate(nums = [10, 20, 5, 15, 25, 1, 30, 3, 2, 28]) == [10, 15, 25, 1, 20, 5, 30, 3, 2, 28]\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91]) == [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91]\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [15, 13, 11, 9, 7, 5, 3, 1, 14, 12, 10, 8, 6, 4, 2]\n assert candidate(nums = [25, 15, 5, 1, 4, 9, 14, 3, 8, 13, 2, 7, 12, 6, 11, 10, 20, 16, 18, 19, 21, 22, 23, 24]) == [25, 5, 4, 9, 14, 3, 8, 13, 2, 7, 12, 6, 11, 10, 20, 16, 18, 19, 21, 22, 23, 24, 15, 1]\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10]) == [1, 3, 2, 5, 4, 7, 6, 9, 8, 10]\n assert candidate(nums = [8, 16, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15]) == [8, 12, 2, 9, 5, 13, 3, 11, 7, 15, 16, 4, 10, 6, 14, 1]\n assert candidate(nums = [3, 1, 4, 2, 5, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30, 33, 32, 35, 34, 37, 36, 39, 38, 41, 40, 43, 42, 45, 44, 47, 46, 49, 48, 50]) == [3, 4, 2, 5, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30, 33, 32, 35, 34, 37, 36, 39, 38, 41, 40, 43, 42, 45, 44, 47, 46, 49, 48, 50, 1]\n assert candidate(nums = [10, 1, 20, 2, 30, 3, 40, 4, 50, 5, 60, 6, 70, 7, 80, 8, 90, 9, 100, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 24, 25, 26, 27, 28, 29, 31, 32, 33, 34, 35, 36, 37, 38, 39, 41, 42, 43, 44, 45, 46, 47, 48, 49]) == [10, 20, 2, 30, 3, 40, 4, 50, 5, 60, 6, 70, 7, 80, 8, 90, 9, 100, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 24, 25, 26, 27, 28, 29, 31, 32, 33, 34, 35, 36, 37, 38, 39, 41, 42, 43, 44, 45, 46, 47, 48, 49, 1]\n assert candidate(nums = [5, 3, 1, 4, 2, 7, 6, 9, 8, 10]) == [5, 1, 3, 4, 2, 7, 6, 9, 8, 10]\n assert candidate(nums = [5, 1, 9, 2, 8, 3, 7, 4, 6, 10]) == [5, 9, 2, 8, 3, 7, 4, 6, 10, 1]\n assert candidate(nums = [13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [13, 11, 9, 7, 5, 3, 1, 12, 10, 8, 6, 4, 2]\n assert candidate(nums = [2, 4, 6, 8, 10, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99]) == [2, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99, 4, 6, 8, 10, 1]\n assert candidate(nums = [10, 20, 15, 25, 30, 5, 35, 40, 45, 50]) == [10, 35, 40, 45, 50, 20, 15, 25, 30, 5]\n assert candidate(nums = [13, 8, 5, 17, 12, 10, 20, 6, 15, 11, 18, 3, 14, 7, 19, 2, 9, 4, 16]) == [13, 5, 14, 7, 19, 2, 8, 17, 12, 10, 20, 6, 15, 11, 18, 3, 9, 4, 16]\n assert candidate(nums = [5, 9, 3, 8, 1, 7, 4, 6, 2]) == [5, 8, 1, 9, 3, 7, 4, 6, 2]\n assert candidate(nums = [37, 52, 45, 63, 28, 75, 19, 84, 12, 91]) == [37, 75, 19, 91, 52, 45, 63, 28, 84, 12]\n assert candidate(nums = [2, 10, 3, 9, 4, 8, 5, 7, 6, 11, 12, 13, 14, 15]) == [2, 10, 3, 9, 4, 8, 5, 7, 6, 11, 12, 13, 14, 15]\n assert candidate(nums = [7, 6, 8, 5, 9, 4, 10, 3, 11, 2, 12, 1]) == [7, 8, 5, 10, 3, 12, 1, 6, 9, 4, 11, 2]\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 31]) == [30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]\n assert candidate(nums = [10, 20, 30, 40, 50, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [10, 2, 3, 4, 5, 6, 7, 8, 9, 20, 30, 40, 50, 1]\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 82, 74, 66, 58, 50, 42, 34, 26, 18, 10]) == [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 82, 74, 66, 58, 50, 42, 34, 26, 18, 10]\n assert candidate(nums = [8, 7, 6, 5, 4, 3, 2, 1, 9, 10]) == [8, 6, 4, 2, 9, 10, 7, 5, 3, 1]\n assert candidate(nums = [2, 4, 6, 8, 10, 1, 3, 5, 7, 9, 11]) == [2, 3, 5, 7, 9, 11, 4, 6, 8, 10, 1]\n assert candidate(nums = [40, 35, 30, 25, 20, 15, 10, 5, 1, 6, 11, 16, 21, 26, 31, 36, 41, 2, 7, 12, 17, 22, 27, 32, 37, 42, 3, 8, 13, 18, 23, 28, 33, 38, 43, 4, 9, 14, 19, 24, 29, 34, 39, 44]) == [40, 30, 20, 10, 1, 35, 25, 15, 5, 6, 11, 16, 21, 26, 31, 36, 41, 2, 7, 12, 17, 22, 27, 32, 37, 42, 3, 8, 13, 18, 23, 28, 33, 38, 43, 4, 9, 14, 19, 24, 29, 34, 39, 44]\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]\n assert candidate(nums = [12, 6, 18, 3, 21, 9, 15, 1, 13, 5, 17, 7, 2, 14, 8, 10, 16, 4, 19, 11]) == [12, 18, 3, 13, 5, 17, 7, 2, 14, 8, 10, 16, 4, 19, 11, 6, 21, 9, 15, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]\n assert candidate(nums = [10, 1, 20, 2, 30, 3, 40, 4]) == [10, 20, 2, 30, 3, 40, 4, 1]\n assert candidate(nums = [10, 20, 30, 40, 50, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == [10, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 30, 40, 50, 1]\n assert candidate(nums = [5, 8, 6, 3, 9, 2, 11, 7, 1, 4, 10]) == [5, 9, 2, 4, 10, 8, 6, 3, 11, 7, 1]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 50]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 50]\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41]) == [20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]\n assert candidate(nums = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [10, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1]\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96]) == [1, 100, 2, 99, 3, 98, 4, 97, 5, 96]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [10, 8, 6, 4, 2, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 9, 7, 5, 3, 1]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [10, 8, 6, 4, 2, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 9, 7, 5, 3, 1]\n assert candidate(nums = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2]\n assert candidate(nums = [50, 1, 49, 2, 48, 3, 47, 4, 46, 5, 45, 6, 44, 7, 43, 8, 42, 9, 41, 10, 40, 11, 39, 12, 38, 13, 37, 14, 36, 15, 35, 16, 34, 17, 33, 18, 32, 19, 31, 20, 30, 21, 29, 22, 28, 23, 27, 24, 26, 25]) == [50, 49, 2, 48, 3, 47, 4, 46, 5, 45, 6, 44, 7, 43, 8, 42, 9, 41, 10, 40, 11, 39, 12, 38, 13, 37, 14, 36, 15, 35, 16, 34, 17, 33, 18, 32, 19, 31, 20, 30, 21, 29, 22, 28, 23, 27, 24, 26, 25, 1]\n assert candidate(nums = [41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [41, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 20, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 42, 43, 44, 45, 46, 47, 48, 49, 50, 30, 21, 22, 23, 24, 25, 26, 27, 28, 29, 10, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2]\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 20, 12, 19, 13, 18, 14, 17, 15, 16]) == [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 20, 12, 19, 13, 18, 14, 17, 15, 16]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [10, 8, 6, 4, 2, 9, 7, 5, 3, 1]\n assert candidate(nums = [1, 15, 2, 14, 3, 13, 4, 12, 5, 11, 6, 10, 7, 9, 8]) == [1, 15, 2, 14, 3, 13, 4, 12, 5, 11, 6, 10, 7, 9, 8]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [30, 20, 10, 40, 50, 60, 70, 80, 90, 100]) == [30, 10, 20, 40, 50, 60, 70, 80, 90, 100]\n assert candidate(nums = [25, 1, 26, 2, 27, 3, 28, 4, 29, 5, 30, 6, 31, 7, 32, 8, 33, 9, 34, 10, 35, 11, 36, 12, 37, 13, 38, 14, 39, 15, 40, 16, 41, 17, 42, 18, 43, 19, 44, 20, 45, 21, 46, 22, 47, 23, 48, 24, 49, 25, 50]) == [25, 26, 2, 27, 3, 28, 4, 29, 5, 30, 6, 31, 7, 32, 8, 33, 9, 34, 10, 35, 11, 36, 12, 37, 13, 38, 14, 39, 15, 40, 16, 41, 17, 42, 18, 43, 19, 44, 20, 45, 21, 46, 22, 47, 23, 48, 24, 49, 25, 50, 1]\n assert candidate(nums = [45, 35, 25, 15, 5, 6, 16, 26, 36, 46, 55, 44, 33, 22, 11]) == [45, 25, 5, 35, 15, 6, 16, 26, 36, 46, 55, 44, 33, 22, 11]\n assert candidate(nums = [3, 2, 1, 6, 5, 4, 9, 8, 7, 12, 11, 10]) == [3, 1, 2, 6, 5, 4, 9, 8, 7, 12, 11, 10]\n assert candidate(nums = [3, 2, 5, 1, 8, 4, 7, 6]) == [3, 5, 1, 2, 8, 4, 7, 6]\n assert candidate(nums = [25, 50, 1, 24, 49, 2, 23, 48, 3, 22, 47, 4, 21, 46, 5, 20, 45, 6, 19, 44, 7, 18, 43, 8, 17, 42, 9, 16, 41, 10, 15, 40, 11, 14, 39, 12, 13, 38]) == [25, 24, 49, 2, 23, 48, 3, 22, 47, 4, 21, 46, 5, 20, 45, 6, 19, 44, 7, 18, 43, 8, 17, 42, 9, 16, 41, 10, 15, 40, 11, 14, 39, 12, 13, 38, 50, 1]\n assert candidate(nums = [7, 6, 5, 8, 9, 10, 1, 2, 3, 4]) == [7, 5, 2, 3, 4, 6, 8, 9, 10, 1]\n assert candidate(nums = [15, 20, 10, 25, 5, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == [15, 25, 5, 20, 10, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]\n assert candidate(nums = [25, 50, 75, 100, 125, 150, 175, 200, 225, 250]) == [25, 50, 75, 100, 125, 150, 175, 200, 225, 250]\n assert candidate(nums = [13, 7, 21, 3, 18, 11, 29, 6, 27, 15]) == [13, 21, 3, 7, 18, 11, 29, 6, 27, 15]\n assert candidate(nums = [25, 26, 23, 27, 21, 28, 19, 30, 17, 31, 15, 32, 13, 33, 11, 34, 9, 35, 7, 36, 5, 37, 3, 38, 1, 39]) == [25, 27, 21, 30, 17, 32, 13, 34, 9, 36, 5, 38, 1, 26, 23, 28, 19, 31, 15, 33, 11, 35, 7, 37, 3, 39]\n assert candidate(nums = [8, 6, 10, 3, 7, 5, 9, 2, 4, 1]) == [8, 10, 3, 4, 1, 6, 7, 5, 9, 2]\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96]) == [1, 100, 2, 99, 3, 98, 4, 97, 5, 96]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]\n assert candidate(nums = [41, 31, 21, 11, 1, 51, 61, 71, 81, 91, 101, 111, 121, 131, 141, 151, 161, 171, 181, 191]) == [41, 21, 1, 31, 11, 51, 61, 71, 81, 91, 101, 111, 121, 131, 141, 151, 161, 171, 181, 191]\n assert candidate(nums = [10, 5, 7, 3, 8, 6, 9, 2, 4, 1]) == [10, 7, 3, 4, 1, 5, 8, 6, 9, 2]\n assert candidate(nums = [10, 15, 5, 20, 1, 25, 100, 50, 75, 2]) == [10, 20, 1, 15, 5, 25, 100, 50, 75, 2]\n assert candidate(nums = [9, 1, 8, 2, 7, 3, 6, 4, 5]) == [9, 8, 2, 7, 3, 6, 4, 5, 1]\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 92, 86, 80, 74, 68, 62, 56, 50, 44, 38, 32, 26, 20, 14, 8, 2]) == [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 92, 86, 80, 74, 68, 62, 56, 50, 44, 38, 32, 26, 20, 14, 8, 2]\n assert candidate(nums = [20, 2, 18, 4, 16, 6, 14, 8, 12, 10, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == [20, 18, 4, 16, 6, 14, 8, 12, 10, 1, 2, 3, 5, 7, 9, 11, 13, 15, 17, 19]\n assert candidate(nums = [8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 11, 12, 13, 14, 15]) == [8, 6, 4, 2, 10, 9, 11, 12, 13, 14, 15, 7, 5, 3, 1]\n assert candidate(nums = [15, 1, 14, 2, 13, 3, 12, 4, 11, 5, 10, 6, 9, 7, 8]) == [15, 14, 2, 13, 3, 12, 4, 11, 5, 10, 6, 9, 7, 8, 1]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]\n assert candidate(nums = [7, 10, 5, 3, 8, 12, 9, 6, 11, 4]) == [7, 3, 10, 5, 8, 12, 9, 6, 11, 4]\n assert candidate(nums = [2, 4, 6, 8, 10, 1, 3, 5, 7, 9]) == [2, 3, 5, 7, 9, 4, 6, 8, 10, 1]\n assert candidate(nums = [42, 24, 63, 12, 84, 36, 54, 72, 90, 18]) == [42, 63, 12, 24, 84, 36, 54, 72, 90, 18]\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51]) == [100, 98, 96, 94, 92, 90, 88, 86, 84, 82, 80, 78, 76, 74, 72, 70, 68, 66, 64, 62, 60, 58, 56, 54, 52, 99, 97, 95, 93, 91, 89, 87, 85, 83, 81, 79, 77, 75, 73, 71, 69, 67, 65, 63, 61, 59, 57, 55, 53, 51]\n assert candidate(nums = [80, 70, 60, 50, 40, 30, 20, 10, 90, 85, 75, 65, 55, 45, 35, 25, 15, 5, 95, 88]) == [80, 60, 40, 20, 90, 85, 75, 65, 55, 45, 35, 25, 15, 5, 70, 50, 30, 10, 95, 88]\n assert candidate(nums = [1, 99, 2, 98, 3, 97, 4, 96, 5, 95, 6, 94, 7, 93, 8, 92, 9, 91, 10, 90, 11, 89, 12, 88, 13, 87, 14, 86, 15, 85, 16, 84, 17, 83, 18, 82, 19, 81, 20, 80, 21, 79, 22, 78, 23, 77, 24, 76, 25, 75, 26, 74, 27, 73, 28, 72, 29, 71, 30, 70]) == [1, 99, 2, 98, 3, 97, 4, 96, 5, 95, 6, 94, 7, 93, 8, 92, 9, 91, 10, 90, 11, 89, 12, 88, 13, 87, 14, 86, 15, 85, 16, 84, 17, 83, 18, 82, 19, 81, 20, 80, 21, 79, 22, 78, 23, 77, 24, 76, 25, 75, 26, 74, 27, 73, 28, 72, 29, 71, 30, 70]\n assert candidate(nums = [7, 10, 3, 6, 9, 2, 5, 8, 1, 4]) == [7, 6, 9, 2, 4, 10, 3, 5, 8, 1]\n assert candidate(nums = [1, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]) == [1, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]\n assert candidate(nums = [7, 3, 9, 1, 5, 11, 13, 2, 8, 4, 10, 6]) == [7, 9, 1, 3, 5, 11, 13, 2, 8, 4, 10, 6]\n assert candidate(nums = [30, 20, 10, 5, 15, 25, 40, 35, 3, 7, 1, 9, 2, 8, 6, 14, 12, 18, 16, 11, 17, 13, 19, 21, 23, 24, 22, 26, 28, 27, 29]) == [30, 10, 15, 25, 40, 35, 3, 9, 2, 8, 6, 14, 12, 18, 16, 11, 17, 13, 19, 21, 23, 24, 22, 26, 28, 27, 29, 20, 5, 7, 1]\n assert candidate(nums = [30, 1, 29, 2, 28, 3, 27, 4, 26, 5, 25, 6, 24, 7, 23, 8, 22, 9, 21, 10]) == [30, 29, 2, 28, 3, 27, 4, 26, 5, 25, 6, 24, 7, 23, 8, 22, 9, 21, 10, 1]\n assert candidate(nums = [25, 19, 30, 14, 24, 9, 29, 4, 23, 10, 13, 28, 5, 22, 8, 12, 27, 6, 21, 7, 20, 11, 18, 15, 17, 16]) == [25, 30, 14, 29, 4, 19, 24, 9, 23, 10, 13, 28, 5, 22, 8, 12, 27, 6, 21, 7, 20, 11, 18, 15, 17, 16]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22]\n assert candidate(nums = [12, 9, 15, 8, 18, 7, 21, 6, 24, 5]) == [12, 15, 8, 21, 6, 9, 18, 7, 24, 5]\n assert candidate(nums = [2, 3, 1, 4, 5, 6, 7, 8, 9, 10]) == [2, 4, 5, 6, 7, 8, 9, 10, 3, 1]\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().resultArray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector resultArray(vector& nums) {", "container": "Solution", "callable": "resultArray", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3070, "task_id": "count-submatrices-with-top-left-element-and-sum-less-than-k", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer matrix grid and an integer k.\nReturn the number of submatrices that contain the top-left element of the grid, and have a sum less than or equal to k.\n \nExample 1:\n\n\nInput: grid = [[7,6,3],[6,6,1]], k = 18\nOutput: 4\nExplanation: There are only 4 submatrices, shown in the image above, that contain the top-left element of grid, and have a sum less than or equal to 18.\nExample 2:\n\n\nInput: grid = [[7,2,9],[1,5,0],[2,6,6]], k = 20\nOutput: 6\nExplanation: There are only 6 submatrices, shown in the image above, that contain the top-left element of grid, and have a sum less than or equal to 20.\n\n \nConstraints:\n\nm == grid.length \nn == grid[i].length\n1 <= n, m <= 1000 \n0 <= grid[i][j] <= 1000\n1 <= k <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[5, 5, 5], [5, 5, 5], [5, 5, 5]],k = 15) == 5\n assert candidate(grid = [[1, 2], [3, 4]],k = 10) == 4\n assert candidate(grid = [[1, 0, 1], [0, 1, 0], [1, 0, 1]],k = 2) == 6\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],k = 5) == 6\n assert candidate(grid = [[1, 2, 3], [4, 5, 6]],k = 15) == 5\n assert candidate(grid = [[1]],k = 1) == 1\n assert candidate(grid = [[7, 2, 9], [1, 5, 0], [2, 6, 6]],k = 20) == 6\n assert candidate(grid = [[7, 6, 3], [6, 6, 1]],k = 18) == 4\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],k = 15) == 6\n assert candidate(grid = [[0, 0, 0], [0, 0, 0], [0, 0, 0]],k = 1) == 9\n assert candidate(grid = [[1, 2, 3], [4, 5, 6]],k = 10) == 4\n assert candidate(grid = [[1000, 1000], [1000, 1000]],k = 3000) == 3\n assert candidate(grid = [[1, 1, 1], [1, 1, 1]],k = 2) == 3\n assert candidate(grid = [[1000, 1000], [1000, 1000]],k = 2000) == 3\n assert candidate(grid = [[5, 5, 5], [5, 5, 5], [5, 5, 5]],k = 25) == 6\n assert candidate(grid = [[5, 5, 5], [5, 5, 5], [5, 5, 5]],k = 50) == 9\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]],k = 50) == 11\n assert candidate(grid = [[9, 8, 7, 6, 5], [4, 3, 2, 1, 0], [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]],k = 100) == 23\n assert candidate(grid = [[5, 10, 15], [20, 25, 30], [35, 40, 45], [50, 55, 60]],k = 100) == 6\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],k = 5) == 8\n assert candidate(grid = [[5, 10, 15, 20], [25, 30, 35, 40], [45, 50, 55, 60], [65, 70, 75, 80]],k = 150) == 9\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]],k = 30) == 9\n assert candidate(grid = [[1000, 0, 0, 0, 0], [0, 1000, 0, 0, 0], [0, 0, 1000, 0, 0], [0, 0, 0, 1000, 0], [0, 0, 0, 0, 1000]],k = 4000) == 24\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]],k = 40) == 10\n assert candidate(grid = [[900, 100, 100], [100, 900, 100], [100, 100, 900]],k = 1500) == 5\n assert candidate(grid = [[2, 2, 2, 2], [2, 2, 2, 2], [2, 2, 2, 2], [2, 2, 2, 2]],k = 16) == 12\n assert candidate(grid = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]],k = 0) == 20\n assert candidate(grid = [[1000, 1000, 1000], [1000, 1000, 1000], [1000, 1000, 1000], [1000, 1000, 1000]],k = 10000) == 11\n assert candidate(grid = [[10, 10, 10, 10, 10], [10, 10, 10, 10, 10], [10, 10, 10, 10, 10], [10, 10, 10, 10, 10], [10, 10, 10, 10, 10]],k = 100) == 17\n assert candidate(grid = [[3, 6, 9, 12, 15, 18, 21], [24, 27, 30, 33, 36, 39, 42], [45, 48, 51, 54, 57, 60, 63]],k = 200) == 14\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],k = 10) == 17\n assert candidate(grid = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]],k = 2) == 12\n assert candidate(grid = [[999, 999], [999, 999], [999, 999]],k = 2997) == 4\n assert candidate(grid = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]],k = 5) == 20\n assert candidate(grid = [[9, 9, 9], [9, 9, 9], [9, 9, 9]],k = 81) == 9\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [6, 7, 8, 9, 10]],k = 50) == 13\n assert candidate(grid = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [3, 5, 7, 9, 11]],k = 30) == 10\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],k = 15) == 22\n assert candidate(grid = [[9, 8, 7], [6, 5, 4], [3, 2, 1]],k = 20) == 4\n assert candidate(grid = [[5, 5, 5, 5], [5, 5, 5, 5], [5, 5, 5, 5], [5, 5, 5, 5]],k = 50) == 13\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]],k = 20) == 6\n assert candidate(grid = [[300, 400, 500, 600], [700, 800, 900, 1000], [1100, 1200, 1300, 1400], [1500, 1600, 1700, 1800]],k = 5000) == 10\n assert candidate(grid = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]],k = 100) == 20\n assert candidate(grid = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]],k = 1) == 25\n assert candidate(grid = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]],k = 0) == 20\n assert candidate(grid = [[5, 5, 5, 5], [5, 5, 5, 5], [5, 5, 5, 5], [5, 5, 5, 5]],k = 20) == 8\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 0) == 30\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1]],k = 7) == 12\n assert candidate(grid = [[100, 200], [300, 400], [500, 600]],k = 1200) == 5\n assert candidate(grid = [[7, 6, 3, 4], [6, 6, 1, 2], [5, 3, 8, 1], [4, 2, 7, 5]],k = 25) == 8\n assert candidate(grid = [[100, 200, 300], [400, 500, 600], [700, 800, 900]],k = 1500) == 6\n assert candidate(grid = [[5, 10, 15], [20, 25, 30], [35, 40, 45]],k = 100) == 6\n assert candidate(grid = [[999, 999, 999], [999, 999, 999], [999, 999, 999], [999, 999, 999]],k = 3000) == 5\n assert candidate(grid = [[10, 20, 30, 40], [40, 30, 20, 10], [5, 5, 5, 5]],k = 50) == 3\n assert candidate(grid = [[10, 20, 30], [40, 50, 60], [70, 80, 90]],k = 200) == 6\n assert candidate(grid = [[999, 999], [999, 999]],k = 1998) == 3\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],k = 10) == 15\n assert candidate(grid = [[100, 200, 300], [400, 500, 600], [700, 800, 900]],k = 1500) == 6\n assert candidate(grid = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]],k = 0) == 12\n assert candidate(grid = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]],k = 1) == 16\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],k = 10) == 17\n assert candidate(grid = [[500, 500, 500, 500], [500, 500, 500, 500], [500, 500, 500, 500], [500, 500, 500, 500]],k = 5000) == 13\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]],k = 30) == 9\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 3, 4, 5, 6], [6, 5, 4, 3, 2]],k = 25) == 12\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 3, 4, 5, 6], [6, 5, 4, 3, 2], [3, 4, 5, 6, 7]],k = 50) == 20\n assert candidate(grid = [[500, 500], [500, 500], [500, 500], [500, 500], [500, 500]],k = 1500) == 4\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]],k = 100) == 25\n assert candidate(grid = [[10, 20, 30], [40, 50, 60], [70, 80, 90]],k = 100) == 4\n assert candidate(grid = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]],k = 10) == 16\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]],k = 10) == 14\n assert candidate(grid = [[100, 200, 300], [200, 100, 400], [300, 400, 500]],k = 1500) == 8\n assert candidate(grid = [[1000, 900, 800], [700, 600, 500], [400, 300, 200]],k = 3000) == 5\n assert candidate(grid = [[10, 20, 30, 40], [5, 15, 25, 35], [50, 60, 70, 80]],k = 100) == 7\n assert candidate(grid = [[5, 10], [15, 20], [25, 30], [35, 40], [45, 50]],k = 100) == 6\n assert candidate(grid = [[100, 200], [300, 400], [500, 600], [700, 800]],k = 1000) == 5\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],k = 20) == 31\n assert candidate(grid = [[5, 5, 5, 5], [5, 5, 5, 5], [5, 5, 5, 5]],k = 40) == 10\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]],k = 100) == 16\n assert candidate(grid = [[5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5]],k = 100) == 20\n assert candidate(grid = [[5, 10, 15, 20], [25, 30, 35, 40], [45, 50, 55, 60], [65, 70, 75, 80]],k = 100) == 7\n assert candidate(grid = [[5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5]],k = 25) == 9\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]],k = 50) == 12\n assert candidate(grid = [[100, 200, 300], [400, 500, 600], [700, 800, 900]],k = 2500) == 7\n assert candidate(grid = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]],k = 30) == 8\n assert candidate(grid = [[3, 1, 2], [1, 4, 5], [5, 2, 3]],k = 25) == 8\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]],k = 30) == 9\n assert candidate(grid = [[10, 20, 30, 40], [50, 60, 70, 80], [90, 100, 110, 120]],k = 250) == 8\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]],k = 50) == 11\n assert candidate(grid = [[3, 3, 3, 3], [3, 3, 3, 3], [3, 3, 3, 3], [3, 3, 3, 3]],k = 30) == 13\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],k = 25) == 34\n assert candidate(grid = [[9, 8, 7, 6], [5, 4, 3, 2], [1, 0, 1, 0], [2, 3, 4, 5]],k = 25) == 6\n assert candidate(grid = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]],k = 10) == 25\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],k = 20) == 35\n assert candidate(grid = [[10, 20, 30], [40, 50, 60], [70, 80, 90]],k = 150) == 6\n assert candidate(grid = [[10, 20, 30, 40], [50, 60, 70, 80], [90, 100, 110, 120], [130, 140, 150, 160]],k = 500) == 11\n assert candidate(grid = [[250, 250, 250, 250], [250, 250, 250, 250], [250, 250, 250, 250]],k = 750) == 5\n assert candidate(grid = [[999, 998, 997], [996, 995, 994], [993, 992, 991]],k = 3000) == 5\n assert candidate(grid = [[10, 20, 30], [40, 50, 60], [70, 80, 90], [100, 110, 120]],k = 100) == 4\n assert candidate(grid = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12]],k = 20) == 6\n assert candidate(grid = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]],k = 20) == 7\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],k = 20) == 30\n assert candidate(grid = [[10, 20, 30, 40, 50], [60, 70, 80, 90, 100], [110, 120, 130, 140, 150], [160, 170, 180, 190, 200]],k = 500) == 12\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]],k = 150) == 17\n assert candidate(grid = [[900, 100, 200], [300, 400, 500], [600, 700, 800]],k = 2000) == 6\n"}, "metadata": {"canonical_parameter_names": ["grid", "k"], "leetcode_dataset_entry_point": "Solution().countSubmatrices", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int countSubmatrices(vector>& grid, int k) {", "container": "Solution", "callable": "countSubmatrices", "parameters": [{"name": "grid", "type": "vector>&"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3071, "task_id": "minimum-operations-to-write-the-letter-y-on-a-grid", "difficulty": "Medium", "problem_description": "You are given a 0-indexed n x n grid where n is odd, and grid[r][c] is 0, 1, or 2.\nWe say that a cell belongs to the Letter Y if it belongs to one of the following:\n\nThe diagonal starting at the top-left cell and ending at the center cell of the grid.\nThe diagonal starting at the top-right cell and ending at the center cell of the grid.\nThe vertical line starting at the center cell and ending at the bottom border of the grid.\n\nThe Letter Y is written on the grid if and only if:\n\nAll values at cells belonging to the Y are equal.\nAll values at cells not belonging to the Y are equal.\nThe values at cells belonging to the Y are different from the values at cells not belonging to the Y.\n\nReturn the minimum number of operations needed to write the letter Y on the grid given that in one operation you can change the value at any cell to 0, 1, or 2.\n \nExample 1:\n\n\nInput: grid = [[1,2,2],[1,1,0],[0,1,0]]\nOutput: 3\nExplanation: We can write Y on the grid by applying the changes highlighted in blue in the image above. After the operations, all cells that belong to Y, denoted in bold, have the same value of 1 while those that do not belong to Y are equal to 0.\nIt can be shown that 3 is the minimum number of operations needed to write Y on the grid.\n\nExample 2:\n\n\nInput: grid = [[0,1,0,1,0],[2,1,0,1,2],[2,2,2,0,1],[2,2,2,2,2],[2,1,2,2,2]]\nOutput: 12\nExplanation: We can write Y on the grid by applying the changes highlighted in blue in the image above. After the operations, all cells that belong to Y, denoted in bold, have the same value of 0 while those that do not belong to Y are equal to 2. \nIt can be shown that 12 is the minimum number of operations needed to write Y on the grid.\n \nConstraints:\n\n3 <= n <= 49 \nn == grid.length == grid[i].length\n0 <= grid[i][j] <= 2\nn is odd.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 4\n assert candidate(grid = [[1, 0, 2], [0, 1, 0], [2, 0, 1]]) == 4\n assert candidate(grid = [[0, 0, 0], [0, 1, 0], [0, 0, 0]]) == 3\n assert candidate(grid = [[1, 0, 1], [0, 0, 0], [1, 0, 1]]) == 4\n assert candidate(grid = [[1, 2, 2], [1, 1, 0], [0, 1, 0]]) == 3\n assert candidate(grid = [[2, 1, 0], [1, 2, 1], [0, 1, 2]]) == 4\n assert candidate(grid = [[0, 1, 2], [1, 1, 2], [2, 1, 0]]) == 5\n assert candidate(grid = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 4\n assert candidate(grid = [[0, 1, 2], [1, 0, 1], [2, 1, 0]]) == 4\n assert candidate(grid = [[2, 2, 2], [2, 2, 2], [2, 2, 2]]) == 4\n assert candidate(grid = [[0, 1, 0, 1, 0], [2, 1, 0, 1, 2], [2, 2, 2, 0, 1], [2, 2, 2, 2, 2], [2, 1, 2, 2, 2]]) == 12\n assert candidate(grid = [[2, 1, 0], [1, 1, 1], [0, 1, 2]]) == 5\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 1, 0], [0, 1, 0, 2, 0, 1, 0], [0, 1, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0]]) == 20\n assert candidate(grid = [[1, 2, 0, 2, 1, 2, 0], [2, 0, 1, 0, 2, 0, 1], [0, 1, 0, 1, 0, 1, 0], [0, 0, 1, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 1, 0, 0], [0, 1, 0, 1, 0, 1, 0], [2, 0, 1, 0, 2, 0, 1], [1, 2, 0, 2, 1, 2, 0]]) == 50\n assert candidate(grid = [[0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == 19\n assert candidate(grid = [[2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 1, 1, 1, 1, 1, 1, 1, 2], [2, 1, 0, 0, 0, 0, 0, 1, 2], [2, 1, 0, 0, 0, 0, 0, 1, 2], [2, 1, 0, 0, 2, 0, 0, 1, 2], [2, 1, 0, 0, 0, 0, 0, 1, 2], [2, 1, 0, 0, 0, 0, 0, 1, 2], [2, 1, 1, 1, 1, 1, 1, 1, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2]]) == 46\n assert candidate(grid = [[2, 0, 0, 0, 2], [0, 1, 1, 1, 0], [0, 1, 2, 1, 0], [0, 1, 1, 1, 0], [2, 0, 0, 0, 2]]) == 11\n assert candidate(grid = [[0, 1, 2, 1, 0], [1, 0, 1, 0, 1], [2, 1, 0, 1, 2], [2, 2, 2, 2, 2], [2, 2, 2, 2, 2]]) == 9\n assert candidate(grid = [[1, 2, 2, 2, 1], [2, 2, 1, 2, 2], [2, 1, 2, 1, 2], [2, 0, 2, 0, 2], [2, 2, 2, 2, 2]]) == 10\n assert candidate(grid = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2], [3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3], [4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4], [5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5], [6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6], [7, 6, 7, 6, 7, 6, 7, 6, 7, 6, 7], [8, 7, 8, 7, 8, 7, 8, 7, 8, 7, 8], [9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9], [10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10]]) == 105\n assert candidate(grid = [[0, 2, 2, 2, 0], [2, 0, 2, 0, 2], [2, 2, 1, 2, 2], [2, 0, 2, 0, 2], [0, 2, 2, 2, 0]]) == 7\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 1, 0], [0, 0, 1, 0, 1, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 1, 0, 1, 0, 0], [0, 1, 0, 0, 0, 1, 0], [1, 0, 0, 0, 0, 0, 1]]) == 9\n assert candidate(grid = [[2, 2, 2, 2, 2], [2, 2, 2, 2, 2], [2, 2, 0, 2, 2], [2, 2, 2, 2, 2], [2, 2, 2, 2, 2]]) == 6\n assert candidate(grid = [[2, 0, 2, 0, 2, 0, 2], [0, 1, 0, 1, 0, 1, 0], [2, 0, 1, 0, 1, 0, 2], [0, 0, 0, 2, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == 11\n assert candidate(grid = [[0, 2, 1, 2, 0], [2, 1, 0, 1, 2], [1, 0, 0, 0, 1], [0, 1, 1, 1, 0], [2, 0, 1, 0, 2]]) == 14\n assert candidate(grid = [[2, 2, 2, 2, 2], [2, 1, 1, 1, 2], [2, 1, 0, 1, 2], [2, 1, 1, 1, 2], [2, 2, 2, 2, 2]]) == 9\n assert candidate(grid = [[1, 1, 2, 1, 1], [1, 0, 0, 0, 1], [2, 0, 1, 0, 2], [2, 0, 1, 0, 2], [2, 2, 2, 2, 2]]) == 12\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 1], [1, 2, 0, 0, 0, 2, 1], [1, 2, 0, 1, 0, 2, 1], [1, 2, 0, 0, 0, 2, 1], [1, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1]]) == 25\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 1], [1, 2, 1, 1, 1, 2, 1], [1, 2, 1, 0, 1, 2, 1], [1, 2, 1, 1, 1, 2, 1], [1, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1]]) == 20\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]]) == 9\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1]]) == 10\n assert candidate(grid = [[2, 0, 1, 0, 2], [0, 0, 2, 0, 0], [1, 2, 1, 2, 1], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0]]) == 11\n assert candidate(grid = [[0, 1, 2, 3, 4, 5, 6, 7, 8], [8, 7, 6, 5, 4, 3, 2, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4, 4, 4, 4], [5, 5, 5, 5, 5, 5, 5, 5, 5], [6, 6, 6, 6, 6, 6, 6, 6, 6], [7, 7, 7, 7, 7, 7, 7, 7, 7]]) == 69\n assert candidate(grid = [[2, 0, 2, 0, 2], [0, 1, 0, 1, 0], [2, 0, 2, 0, 2], [0, 1, 0, 1, 0], [2, 0, 2, 0, 2]]) == 10\n assert candidate(grid = [[2, 0, 0, 0, 2], [0, 0, 1, 0, 0], [0, 1, 1, 1, 0], [0, 0, 1, 0, 0], [0, 0, 2, 0, 0]]) == 7\n assert candidate(grid = [[2, 2, 1, 1, 2], [2, 2, 1, 1, 2], [1, 1, 2, 1, 1], [2, 1, 2, 1, 2], [2, 2, 1, 1, 2]]) == 10\n assert candidate(grid = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == 11\n assert candidate(grid = [[1, 0, 0, 0, 1], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [1, 0, 1, 0, 1]]) == 6\n assert candidate(grid = [[2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 1, 1, 1, 1, 1, 1, 1, 2], [2, 1, 2, 2, 2, 2, 2, 1, 2], [2, 1, 2, 1, 1, 1, 2, 1, 2], [2, 1, 2, 1, 0, 1, 2, 1, 2], [2, 1, 2, 1, 1, 1, 2, 1, 2], [2, 1, 2, 2, 2, 2, 2, 1, 2], [2, 1, 1, 1, 1, 1, 1, 1, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2]]) == 33\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 0], [0, 1, 2, 2, 2, 1, 0], [0, 1, 2, 1, 2, 1, 0], [0, 1, 2, 2, 2, 1, 0], [0, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0]]) == 24\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 1, 1, 1, 1, 1, 1, 1, 2, 0], [0, 2, 2, 1, 1, 1, 1, 1, 2, 2, 0], [0, 2, 2, 2, 1, 1, 1, 2, 2, 2, 0], [0, 2, 2, 2, 2, 1, 2, 2, 2, 2, 0], [0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0], [0, 0, 2, 2, 2, 2, 2, 2, 2, 0, 0], [0, 0, 0, 2, 2, 2, 2, 2, 0, 0, 0], [0, 0, 0, 0, 2, 2, 2, 0, 0, 0, 0], [0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 51\n assert candidate(grid = [[2, 0, 1, 0, 2], [0, 1, 0, 1, 0], [1, 0, 2, 0, 1], [0, 1, 0, 1, 0], [2, 0, 1, 0, 2]]) == 11\n assert candidate(grid = [[0, 2, 1, 2, 0], [1, 1, 0, 1, 1], [2, 0, 2, 0, 2], [2, 2, 2, 2, 2], [2, 2, 2, 2, 2]]) == 11\n assert candidate(grid = [[2, 0, 2, 0, 2], [0, 2, 0, 2, 0], [2, 0, 2, 0, 2], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == 5\n assert candidate(grid = [[0, 1, 2, 1, 0], [1, 2, 1, 2, 1], [2, 1, 0, 1, 2], [2, 1, 0, 1, 2], [2, 1, 0, 1, 2]]) == 9\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0], [0, 2, 1, 1, 1, 1, 1, 1, 1, 2, 0], [0, 2, 1, 0, 0, 0, 0, 0, 1, 2, 0], [0, 2, 1, 0, 0, 0, 0, 0, 1, 2, 0], [0, 2, 1, 0, 0, 0, 0, 0, 1, 2, 0], [0, 2, 1, 0, 0, 0, 0, 0, 1, 2, 0], [0, 2, 1, 0, 0, 0, 0, 0, 1, 2, 0], [0, 2, 1, 1, 1, 1, 1, 1, 1, 2, 0], [0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 63\n assert candidate(grid = [[0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [1, 0, 0, 0, 1], [0, 1, 1, 1, 0], [0, 0, 1, 0, 0]]) == 8\n assert candidate(grid = [[1, 2, 1, 2, 1], [2, 1, 2, 1, 2], [1, 2, 1, 2, 1], [2, 1, 2, 1, 2], [1, 2, 1, 2, 1]]) == 8\n assert candidate(grid = [[0, 0, 1, 0, 0], [0, 1, 2, 1, 0], [1, 2, 0, 2, 1], [2, 2, 2, 2, 2], [0, 0, 2, 0, 0]]) == 15\n assert candidate(grid = [[2, 1, 1, 1, 1, 1, 2], [1, 2, 1, 1, 1, 2, 1], [1, 1, 2, 1, 2, 1, 1], [1, 1, 1, 2, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1]]) == 3\n assert candidate(grid = [[1, 1, 2, 1, 1], [1, 2, 2, 2, 1], [1, 2, 0, 2, 1], [0, 2, 0, 2, 0], [0, 0, 0, 0, 0]]) == 16\n assert candidate(grid = [[2, 0, 0, 0, 2, 0, 0, 0, 2], [0, 1, 0, 0, 1, 0, 0, 1, 0], [0, 0, 2, 0, 2, 0, 2, 0, 0], [0, 0, 0, 2, 2, 2, 0, 0, 0], [0, 0, 0, 2, 2, 2, 0, 0, 0], [0, 0, 0, 2, 2, 2, 0, 0, 0], [0, 0, 0, 2, 2, 2, 0, 0, 0], [0, 0, 1, 0, 2, 0, 1, 0, 0], [0, 1, 0, 0, 1, 0, 0, 1, 0]]) == 17\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == 5\n assert candidate(grid = [[2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 1, 1, 1, 1, 1, 1, 1, 2], [2, 1, 0, 0, 0, 0, 0, 1, 2], [2, 1, 0, 2, 2, 2, 0, 1, 2], [2, 1, 0, 2, 1, 2, 0, 1, 2], [2, 1, 0, 2, 2, 2, 0, 1, 2], [2, 1, 0, 0, 0, 0, 0, 1, 2], [2, 1, 1, 1, 1, 1, 1, 1, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2]]) == 43\n assert candidate(grid = [[2, 0, 1, 0, 2], [0, 1, 1, 1, 0], [1, 1, 1, 1, 1], [0, 1, 1, 1, 0], [2, 0, 1, 0, 2]]) == 12\n assert candidate(grid = [[2, 1, 0, 1, 2], [1, 0, 0, 0, 1], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [2, 1, 0, 1, 2]]) == 13\n assert candidate(grid = [[1, 2, 2, 1, 1], [2, 1, 2, 1, 2], [1, 2, 2, 1, 1], [1, 2, 1, 1, 1], [1, 1, 1, 1, 1]]) == 12\n assert candidate(grid = [[1, 1, 2, 2, 1], [1, 1, 1, 2, 1], [0, 1, 1, 1, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0]]) == 10\n assert candidate(grid = [[2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 1, 1, 1, 1, 1, 1, 1, 2], [2, 1, 2, 2, 2, 2, 2, 1, 2], [2, 1, 2, 1, 1, 1, 2, 1, 2], [2, 1, 2, 1, 2, 1, 2, 1, 2], [2, 1, 2, 1, 1, 1, 2, 1, 2], [2, 1, 2, 2, 2, 2, 2, 1, 2], [2, 1, 1, 1, 1, 1, 1, 1, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2]]) == 33\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 1, 0], [0, 0, 1, 0, 1, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 1, 0, 1, 0, 0], [0, 1, 0, 0, 0, 1, 0], [1, 0, 0, 0, 0, 0, 1]]) == 9\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 2, 2, 2, 0, 1], [1, 0, 2, 1, 2, 0, 1], [1, 0, 2, 2, 2, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1]]) == 25\n assert candidate(grid = [[2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 0, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2]]) == 9\n assert candidate(grid = [[2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 1, 2, 1, 2, 1, 2, 1, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2]]) == 13\n assert candidate(grid = [[1, 2, 0, 2, 0, 2, 1], [2, 0, 0, 0, 0, 0, 2], [0, 0, 1, 1, 1, 0, 0], [0, 1, 1, 2, 1, 1, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 2, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == 17\n assert candidate(grid = [[0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 26\n assert candidate(grid = [[1, 2, 1, 2, 1], [2, 1, 0, 1, 2], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 2, 1, 2, 1]]) == 13\n assert candidate(grid = [[2, 2, 2, 2, 2, 2, 2], [2, 0, 0, 0, 0, 0, 2], [2, 0, 1, 1, 1, 0, 2], [2, 0, 1, 0, 1, 0, 2], [2, 0, 1, 1, 1, 0, 2], [2, 0, 0, 0, 0, 0, 2], [2, 2, 2, 2, 2, 2, 2]]) == 24\n assert candidate(grid = [[2, 1, 0, 1, 2], [1, 0, 1, 0, 1], [0, 1, 2, 1, 0], [0, 1, 1, 0, 0], [0, 0, 0, 0, 0]]) == 12\n assert candidate(grid = [[0, 1, 2, 1, 0], [1, 0, 2, 0, 1], [2, 2, 2, 2, 2], [2, 2, 2, 2, 2], [2, 1, 2, 2, 2]]) == 8\n assert candidate(grid = [[1, 2, 1, 2, 1], [2, 1, 2, 1, 2], [1, 2, 1, 2, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 11\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 0, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1]]) == 9\n assert candidate(grid = [[2, 0, 1, 0, 2, 0, 2], [0, 2, 0, 2, 0, 2, 0], [1, 0, 1, 0, 1, 0, 1], [0, 2, 0, 2, 0, 2, 0], [2, 0, 2, 2, 2, 0, 2], [0, 2, 0, 2, 0, 2, 0], [2, 0, 2, 0, 2, 0, 2]]) == 20\n assert candidate(grid = [[0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [1, 1, 1, 1, 1], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0]]) == 10\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 1], [1, 2, 1, 1, 1, 2, 1], [1, 2, 1, 0, 1, 2, 1], [1, 2, 1, 1, 1, 2, 1], [1, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1]]) == 20\n assert candidate(grid = [[0, 1, 2, 1, 0, 1, 2], [1, 0, 1, 0, 1, 0, 1], [2, 1, 0, 1, 2, 1, 0], [1, 0, 1, 2, 1, 0, 1], [0, 1, 2, 1, 0, 1, 2], [1, 0, 1, 0, 1, 0, 1], [2, 1, 0, 1, 2, 1, 0]]) == 22\n assert candidate(grid = [[2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 1, 2, 2, 2], [2, 2, 1, 0, 1, 2, 2], [2, 1, 0, 0, 0, 1, 2], [2, 0, 0, 0, 0, 0, 2], [2, 0, 0, 0, 0, 0, 2]]) == 21\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().minimumOperationsToWriteY", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumOperationsToWriteY(vector>& grid) {", "container": "Solution", "callable": "minimumOperationsToWriteY", "parameters": [{"name": "grid", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3072, "task_id": "distribute-elements-into-two-arrays-ii", "difficulty": "Hard", "problem_description": "You are given a 1-indexed array of integers nums of length n.\nWe define a function greaterCount such that greaterCount(arr, val) returns the number of elements in arr that are strictly greater than val.\nYou need to distribute all the elements of nums between two arrays arr1 and arr2 using n operations. In the first operation, append nums[1] to arr1. In the second operation, append nums[2] to arr2. Afterwards, in the ith operation:\n\nIf greaterCount(arr1, nums[i]) > greaterCount(arr2, nums[i]), append nums[i] to arr1.\nIf greaterCount(arr1, nums[i]) < greaterCount(arr2, nums[i]), append nums[i] to arr2.\nIf greaterCount(arr1, nums[i]) == greaterCount(arr2, nums[i]), append nums[i] to the array with a lesser number of elements.\nIf there is still a tie, append nums[i] to arr1.\n\nThe array result is formed by concatenating the arrays arr1 and arr2. For example, if arr1 == [1,2,3] and arr2 == [4,5,6], then result = [1,2,3,4,5,6].\nReturn the integer array result.\n \nExample 1:\n\nInput: nums = [2,1,3,3]\nOutput: [2,3,1,3]\nExplanation: After the first 2 operations, arr1 = [2] and arr2 = [1].\nIn the 3rd operation, the number of elements greater than 3 is zero in both arrays. Also, the lengths are equal, hence, append nums[3] to arr1.\nIn the 4th operation, the number of elements greater than 3 is zero in both arrays. As the length of arr2 is lesser, hence, append nums[4] to arr2.\nAfter 4 operations, arr1 = [2,3] and arr2 = [1,3].\nHence, the array result formed by concatenation is [2,3,1,3].\n\nExample 2:\n\nInput: nums = [5,14,3,1,2]\nOutput: [5,3,1,2,14]\nExplanation: After the first 2 operations, arr1 = [5] and arr2 = [14].\nIn the 3rd operation, the number of elements greater than 3 is one in both arrays. Also, the lengths are equal, hence, append nums[3] to arr1.\nIn the 4th operation, the number of elements greater than 1 is greater in arr1 than arr2 (2 > 1). Hence, append nums[4] to arr1.\nIn the 5th operation, the number of elements greater than 2 is greater in arr1 than arr2 (2 > 1). Hence, append nums[5] to arr1.\nAfter 5 operations, arr1 = [5,3,1,2] and arr2 = [14].\nHence, the array result formed by concatenation is [5,3,1,2,14].\n\nExample 3:\n\nInput: nums = [3,3,3,3]\nOutput: [3,3,3,3]\nExplanation: At the end of 4 operations, arr1 = [3,3] and arr2 = [3,3].\nHence, the array result formed by concatenation is [3,3,3,3].\n\n \nConstraints:\n\n3 <= n <= 105\n1 <= nums[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [3, 2, 1, 5, 4, 9, 8, 7, 6, 10]) == [3, 1, 9, 8, 7, 6, 2, 5, 4, 10]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == [100, 80, 70, 60, 50, 40, 30, 20, 10, 90]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]\n assert candidate(nums = [7, 10, 4, 3, 20, 15]) == [7, 4, 3, 10, 20, 15]\n assert candidate(nums = [10, 5, 20, 15, 25, 30]) == [10, 20, 15, 5, 25, 30]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]\n assert candidate(nums = [1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1]) == [1000000000, 1000000000, 1, 1, 1000000000, 1, 1, 1000000000, 1000000000, 1]\n assert candidate(nums = [5, 14, 3, 1, 2]) == [5, 3, 1, 2, 14]\n assert candidate(nums = [9, 1, 8, 2, 7, 3, 6, 4, 5, 10]) == [9, 8, 2, 7, 3, 6, 4, 5, 1, 10]\n assert candidate(nums = [2, 1, 3, 3]) == [2, 3, 1, 3]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [10, 8, 7, 6, 5, 4, 3, 2, 1, 9]\n assert candidate(nums = [3, 3, 3, 3]) == [3, 3, 3, 3]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]\n assert candidate(nums = [1, 3, 2, 6, 5, 4, 9, 8, 7, 10, 13, 12, 11, 15, 14, 17, 16, 19, 18, 20, 21, 22, 23, 24, 25]) == [1, 6, 5, 4, 10, 13, 12, 11, 19, 18, 21, 23, 25, 3, 2, 9, 8, 7, 15, 14, 17, 16, 20, 22, 24]\n assert candidate(nums = [1000000000, 1, 1000000000, 2, 1000000000, 3, 1000000000, 4, 1000000000]) == [1000000000, 1000000000, 2, 3, 1000000000, 1, 1000000000, 1000000000, 4]\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, 17, 16]) == [15, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, 20, 19, 18, 17, 16]\n assert candidate(nums = [50, 25, 75, 12, 37, 62, 88, 43, 59, 100, 20, 90, 30, 80, 40, 70, 60, 50, 10, 95]) == [50, 75, 12, 37, 62, 43, 59, 20, 30, 40, 10, 25, 88, 100, 90, 80, 70, 60, 50, 95]\n assert candidate(nums = [1, 1000000000, 2, 999999999, 3, 999999998, 4, 999999997, 5, 999999996, 6, 999999995, 7, 999999994, 8, 999999993, 9, 999999992, 10, 999999991]) == [1, 1000000000, 2, 999999999, 3, 999999998, 4, 999999997, 5, 999999996, 6, 999999995, 7, 999999994, 8, 999999993, 9, 999999992, 10, 999999991]\n assert candidate(nums = [20, 10, 30, 5, 25, 15, 35, 1, 2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 16, 17, 18, 19, 21, 22, 23, 24, 26, 27, 28, 29, 31, 32, 33, 34, 36, 37, 38, 39, 40]) == [20, 30, 5, 25, 15, 1, 2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 16, 17, 18, 19, 21, 22, 23, 24, 10, 35, 26, 27, 28, 29, 31, 32, 33, 34, 36, 37, 38, 39, 40]\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [20, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 19]\n assert candidate(nums = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == [5, 3, 2, 1, 9, 4, 6, 7, 8, 10, 1, 2, 3, 4, 5]\n assert candidate(nums = [10, 20, 15, 25, 30, 5, 35, 40, 45, 50, 55, 5, 60, 65, 70]) == [10, 25, 30, 5, 45, 55, 60, 70, 20, 15, 35, 40, 50, 5, 65]\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91]) == [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91]\n assert candidate(nums = [1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3]) == [1, 3, 2, 1, 3, 2, 1, 2, 3, 2, 1, 3]\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3]) == [1, 1, 1, 2, 2, 3, 3, 3, 1, 1, 2, 2, 2, 3, 3]\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [15, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 14]\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [15, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 14]\n assert candidate(nums = [5, 3, 8, 6, 7, 2, 4, 1, 9, 10]) == [5, 8, 6, 7, 2, 4, 1, 3, 9, 10]\n assert candidate(nums = [100, 99, 101, 98, 102, 97, 103, 96, 104, 95, 105, 94, 106, 93, 107]) == [100, 101, 98, 97, 96, 95, 94, 93, 99, 102, 103, 104, 105, 106, 107]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 3, 5, 7, 9, 2, 4, 6, 8, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [25, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 24]\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1000000000, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]\n assert candidate(nums = [5, 1, 9, 2, 8, 3, 7, 4, 6, 10]) == [5, 9, 2, 8, 3, 7, 4, 6, 1, 10]\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 21, 20, 23, 22, 25, 24]) == [1, 5, 4, 9, 8, 13, 12, 17, 16, 21, 20, 25, 24, 3, 2, 7, 6, 11, 10, 15, 14, 19, 18, 23, 22]\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4]) == [5, 7, 9, 1, 3, 6, 8, 10, 2, 4, 6, 8, 10, 2, 4, 5, 7, 9, 1, 3]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [1, 3, 5, 7, 9, 11, 13, 15, 2, 4, 6, 8, 10, 12, 14]\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2]) == [1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2]\n assert candidate(nums = [109, 108, 107, 106, 105, 104, 103, 102, 101, 100]) == [109, 107, 106, 105, 104, 103, 102, 101, 100, 108]\n assert candidate(nums = [2, 3, 1, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 20]) == [2, 1, 7, 6, 11, 10, 15, 14, 19, 18, 3, 5, 4, 9, 8, 13, 12, 17, 16, 20]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == [3, 2, 1, 3, 1, 2, 1, 3, 2, 3]\n assert candidate(nums = [10, 1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, 17, 8, 18, 9, 19, 20]) == [10, 11, 2, 3, 14, 5, 16, 7, 18, 9, 1, 12, 13, 4, 15, 6, 17, 8, 19, 20]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [10, 30, 50, 70, 90, 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, 40, 60, 80, 100]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [10, 1, 20, 2, 30, 3, 40, 4, 50, 5]) == [10, 20, 2, 3, 50, 5, 1, 30, 40, 4]\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == [1, 5, 9, 4, 8, 3, 7, 2, 6, 10]\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991]) == [1000000000, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 999999999]\n assert candidate(nums = [5, 10, 15, 20, 25, 1, 6, 11, 16, 21, 3, 8, 13, 18, 23, 4, 9, 14, 19, 24, 7, 12, 17, 22, 26]) == [5, 15, 25, 1, 11, 21, 3, 8, 13, 18, 23, 4, 9, 14, 19, 24, 7, 12, 17, 22, 10, 20, 6, 16, 26]\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125]) == [1000000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125, 500000000]\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]\n assert candidate(nums = [7, 10, 5, 8, 3, 6, 9, 2, 1, 4]) == [7, 5, 3, 10, 8, 6, 9, 2, 1, 4]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109]) == [100, 102, 104, 106, 108, 101, 103, 105, 107, 109]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71]) == [100, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 99]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96]) == [1, 100, 2, 99, 3, 98, 4, 97, 5, 96]\n assert candidate(nums = [9, 1, 8, 2, 7, 3, 6, 4, 5, 10, 11, 12, 13, 14, 15]) == [9, 8, 2, 7, 3, 6, 4, 5, 1, 10, 11, 12, 13, 14, 15]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [10, 8, 7, 6, 5, 4, 3, 2, 1, 19, 9, 11, 12, 13, 14, 15, 16, 17, 18, 20]\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 9, 1, 10]) == [5, 8, 6, 2, 7, 4, 1, 3, 9, 10]\n assert candidate(nums = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10]) == [5, 3, 2, 1, 9, 4, 6, 7, 8, 10]\n assert candidate(nums = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [25, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 24]\n assert candidate(nums = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == [5, 4, 3, 2, 1, 5, 4, 3, 2, 1]\n assert candidate(nums = [5, 2, 7, 1, 8, 3, 6, 4, 9, 10, 1, 1, 1, 1, 1]) == [5, 7, 1, 3, 9, 2, 8, 6, 4, 10, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]) == [1, 5, 4, 9, 8, 13, 12, 3, 2, 7, 6, 11, 10, 15, 14]\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1]) == [2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1]) == [1, 3, 2, 1, 3, 2, 1, 3, 2, 1]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 20, 12, 19, 13, 18, 14, 17, 15, 16]) == [1, 11, 20, 12, 19, 13, 18, 14, 17, 15, 16, 10, 2, 9, 3, 8, 4, 7, 5, 6]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [10, 8, 7, 6, 5, 4, 3, 2, 1, 9]\n assert candidate(nums = [1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3]) == [1, 3, 2, 1, 3, 2, 1, 3, 2, 3, 2, 1, 3, 2, 1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == [1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == [1, 3, 5, 7, 9, 2, 4, 6, 8]\n assert candidate(nums = [10, 20, 30, 40, 50, 40, 30, 20, 10, 5, 15, 25, 35, 45, 55, 45, 35, 25, 15]) == [10, 30, 50, 40, 30, 20, 10, 5, 15, 25, 35, 45, 25, 15, 20, 40, 55, 45, 35]\n assert candidate(nums = [10, 20, 15, 25, 30, 5, 2, 1, 3, 18, 19, 21, 22, 23, 24, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == [10, 25, 30, 5, 2, 1, 3, 18, 19, 21, 22, 23, 24, 6, 7, 8, 9, 10, 11, 12, 13, 14, 20, 15]\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]) == [1, 5, 4, 9, 8, 13, 12, 3, 2, 7, 6, 11, 10, 15, 14]\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == [1, 1, 2, 3, 3, 4, 5, 5, 1, 2, 2, 3, 4, 4, 5]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]\n assert candidate(nums = [7, 3, 15, 10, 12, 1, 13, 5, 8, 2, 14, 9, 6, 11, 4]) == [7, 15, 10, 12, 1, 13, 5, 8, 2, 14, 9, 6, 11, 4, 3]\n assert candidate(nums = [5, 1, 9, 2, 8, 3, 7, 4, 6, 10]) == [5, 9, 2, 8, 3, 7, 4, 6, 1, 10]\n assert candidate(nums = [1, 2, 3, 10, 9, 8, 7, 6, 5, 4]) == [1, 3, 2, 10, 9, 8, 7, 6, 5, 4]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == [9, 7, 6, 5, 4, 3, 2, 1, 8]\n assert candidate(nums = [9, 1, 8, 2, 7, 3, 6, 4, 5]) == [9, 8, 2, 7, 3, 6, 4, 5, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 3, 5, 7, 9, 2, 4, 6, 8, 10, 2, 4, 6, 8, 10, 1, 3, 5, 7, 9]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 110, 120, 130, 140, 150, 5, 15, 25, 35, 45]) == [100, 80, 70, 60, 50, 40, 30, 20, 10, 5, 15, 25, 90, 110, 120, 130, 140, 150, 35, 45]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == [1, 5, 9, 13, 17, 4, 8, 12, 16, 20, 3, 7, 11, 15, 19, 2, 6, 10, 14, 18]\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [1000000000, 2, 3, 4, 5, 6, 7, 8, 9, 1]\n assert candidate(nums = [1, 1000000000, 2, 999999999, 3, 999999998, 4, 999999997, 5, 999999996]) == [1, 1000000000, 2, 999999999, 3, 999999998, 4, 999999997, 5, 999999996]\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 3]) == [1, 1, 2, 3, 3, 1, 2, 2, 3, 3]\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == [1, 3, 5, 2, 4, 1, 3, 5, 2, 4, 2, 4, 1, 3, 5, 2, 4, 1, 3, 5]\n assert candidate(nums = [10, 20, 15, 10, 5, 25, 30, 5, 15, 25]) == [10, 25, 30, 5, 15, 25, 20, 15, 10, 5]\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1000000000, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1]\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 20]) == [1, 5, 4, 9, 8, 13, 12, 17, 16, 20, 3, 2, 7, 6, 11, 10, 15, 14, 19, 18]\n assert candidate(nums = [50, 20, 30, 10, 40, 1, 2, 3, 4, 5]) == [50, 30, 10, 40, 1, 2, 3, 4, 5, 20]\n assert candidate(nums = [50, 40, 30, 20, 10, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155]) == [50, 30, 20, 10, 15, 25, 45, 105, 125, 145, 40, 35, 55, 65, 75, 85, 95, 115, 135, 155]\n assert candidate(nums = [25, 25, 25, 25, 25, 50, 50, 50, 50, 50, 75, 75, 75, 75, 75, 100, 100, 100, 100, 100]) == [25, 25, 25, 50, 50, 75, 75, 75, 100, 100, 25, 25, 50, 50, 50, 75, 75, 100, 100, 100]\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().resultArray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector resultArray(vector& nums) {", "container": "Solution", "callable": "resultArray", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3074, "task_id": "apple-redistribution-into-boxes", "difficulty": "Easy", "problem_description": "You are given an array apple of size n and an array capacity of size m.\nThere are n packs where the ith pack contains apple[i] apples. There are m boxes as well, and the ith box has a capacity of capacity[i] apples.\nReturn the minimum number of boxes you need to select to redistribute these n packs of apples into boxes.\nNote that, apples from the same pack can be distributed into different boxes.\n \nExample 1:\n\nInput: apple = [1,3,2], capacity = [4,3,1,5,2]\nOutput: 2\nExplanation: We will use boxes with capacities 4 and 5.\nIt is possible to distribute the apples as the total capacity is greater than or equal to the total number of apples.\n\nExample 2:\n\nInput: apple = [5,5,5], capacity = [2,4,2,7]\nOutput: 4\nExplanation: We will need to use all the boxes.\n\n \nConstraints:\n\n1 <= n == apple.length <= 50\n1 <= m == capacity.length <= 50\n1 <= apple[i], capacity[i] <= 50\nThe input is generated such that it's possible to redistribute packs of apples into boxes.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(apple = [10, 20, 30],capacity = [15, 10, 25]) == None\n assert candidate(apple = [10, 20, 30, 40],capacity = [10, 10, 10, 10, 10, 10, 10]) == None\n assert candidate(apple = [45, 5],capacity = [50]) == 1\n assert candidate(apple = [1, 1, 1, 1, 1],capacity = [1, 1, 1, 1, 1, 1]) == 5\n assert candidate(apple = [10, 20, 30],capacity = [5, 15, 10, 20]) == None\n assert candidate(apple = [2, 2, 2, 2],capacity = [1, 1, 1, 1, 1, 1, 1, 1]) == 8\n assert candidate(apple = [1, 1, 1, 1],capacity = [1, 1, 1, 1, 1]) == 4\n assert candidate(apple = [2, 2, 2, 2, 2],capacity = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(apple = [1, 1, 1, 1, 1],capacity = [1, 1, 1, 1, 1]) == 5\n assert candidate(apple = [40, 10, 10],capacity = [20, 20, 20]) == 3\n assert candidate(apple = [25, 25],capacity = [30, 20]) == 2\n assert candidate(apple = [1, 1, 1, 1],capacity = [1, 1, 1, 1, 1, 1]) == 4\n assert candidate(apple = [5, 5, 5],capacity = [2, 4, 2, 7]) == 4\n assert candidate(apple = [45, 3, 2],capacity = [50, 1, 1, 1]) == 1\n assert candidate(apple = [15, 15, 15],capacity = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 9\n assert candidate(apple = [3, 5, 7, 9],capacity = [2, 4, 6, 8, 10]) == 3\n assert candidate(apple = [10, 20, 30],capacity = [5, 10, 15, 25]) == None\n assert candidate(apple = [1, 3, 2],capacity = [4, 3, 1, 5, 2]) == 2\n assert candidate(apple = [50],capacity = [50]) == 1\n assert candidate(apple = [10, 20, 30],capacity = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == None\n assert candidate(apple = [25, 25, 25, 25, 25],capacity = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == None\n assert candidate(apple = [48, 48, 48],capacity = [16, 16, 16, 16, 16, 16]) == None\n assert candidate(apple = [25, 25, 25],capacity = [10, 10, 10, 10, 10, 10, 10]) == None\n assert candidate(apple = [49, 1, 1],capacity = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25]) == 3\n assert candidate(apple = [15, 20, 5],capacity = [12, 18, 9, 7]) == 4\n assert candidate(apple = [1, 2, 3, 4, 5],capacity = [2, 3, 4, 5, 6]) == 3\n assert candidate(apple = [25, 25, 25, 25, 25],capacity = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 13\n assert candidate(apple = [50, 40, 30, 20, 10],capacity = [10, 20, 30, 40, 50]) == 5\n assert candidate(apple = [48, 1, 1],capacity = [24, 24, 1, 1, 1]) == 4\n assert candidate(apple = [25, 25, 25, 25],capacity = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == None\n assert candidate(apple = [40, 30, 20, 10],capacity = [50, 20, 10, 10, 10]) == 5\n assert candidate(apple = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacity = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 100]) == 1\n assert candidate(apple = [15, 25, 35],capacity = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == None\n assert candidate(apple = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacity = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 20\n assert candidate(apple = [15, 25, 35, 45],capacity = [10, 20, 30, 40, 50]) == 3\n assert candidate(apple = [30, 20, 10, 40],capacity = [10, 15, 5, 25, 30, 5]) == None\n assert candidate(apple = [50, 50, 50],capacity = [16, 17, 18, 19, 20]) == None\n assert candidate(apple = [1, 2, 3, 4, 5],capacity = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 15\n assert candidate(apple = [2, 3, 5, 7, 11, 13],capacity = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 2\n assert candidate(apple = [10, 20, 30, 40],capacity = [10, 20, 30, 40, 50]) == 3\n assert candidate(apple = [30, 10, 5],capacity = [15, 10, 10, 5, 5]) == 5\n assert candidate(apple = [3, 6, 9, 12],capacity = [2, 4, 6, 8, 10, 12, 14]) == 3\n assert candidate(apple = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],capacity = [5, 10, 15, 20, 25]) == 3\n assert candidate(apple = [25, 25, 25],capacity = [20, 15, 30, 10, 25]) == 3\n assert candidate(apple = [45, 35, 25],capacity = [20, 15, 10, 5, 5, 5]) == None\n assert candidate(apple = [49, 49, 49],capacity = [50, 50, 50, 50, 50, 50]) == 3\n assert candidate(apple = [30, 30, 30],capacity = [25, 25, 25, 25]) == 4\n assert candidate(apple = [10, 20, 30, 40],capacity = [15, 25, 35, 5, 5, 5]) == None\n assert candidate(apple = [10, 20, 30, 40, 50],capacity = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == None\n assert candidate(apple = [10, 20, 30],capacity = [5, 15, 10, 25]) == None\n assert candidate(apple = [45, 45, 5],capacity = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == None\n assert candidate(apple = [40, 30, 20, 10],capacity = [15, 15, 15, 15, 15, 15]) == None\n assert candidate(apple = [30, 20, 10],capacity = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == None\n assert candidate(apple = [25, 25, 25],capacity = [10, 10, 10, 10, 10, 10, 10, 10]) == 8\n assert candidate(apple = [15, 15, 15, 15],capacity = [10, 10, 10, 10, 10]) == None\n assert candidate(apple = [49, 1, 1],capacity = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 51\n assert candidate(apple = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],capacity = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == None\n assert candidate(apple = [50, 40, 30, 20, 10],capacity = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == None\n assert candidate(apple = [3, 6, 9, 12, 15],capacity = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 6\n assert candidate(apple = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],capacity = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 4\n assert candidate(apple = [2, 3, 5, 7, 11],capacity = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 4\n assert candidate(apple = [45, 5, 3, 7],capacity = [12, 8, 15, 10, 2]) == None\n assert candidate(apple = [49, 1],capacity = [50]) == 1\n assert candidate(apple = [5, 5, 5, 5, 5, 5, 5],capacity = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 35\n assert candidate(apple = [10, 10, 10],capacity = [5, 5, 5, 5, 5, 5]) == 6\n assert candidate(apple = [50, 45, 40],capacity = [10, 20, 15, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == None\n assert candidate(apple = [1, 1, 2, 2, 3, 3, 4, 4],capacity = [1, 2, 3, 4, 5, 6, 7, 8]) == 3\n assert candidate(apple = [1, 2, 3, 4, 5, 6],capacity = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 3\n assert candidate(apple = [7, 8, 9],capacity = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 3\n assert candidate(apple = [49, 49, 49, 49, 49],capacity = [50, 50, 50, 50, 50]) == 5\n assert candidate(apple = [10, 20, 30, 40, 50],capacity = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 4\n assert candidate(apple = [9, 11, 13, 17],capacity = [8, 15, 7, 10, 6, 12]) == 5\n assert candidate(apple = [48, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],capacity = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 18\n assert candidate(apple = [49, 1],capacity = [25, 24, 1]) == 3\n assert candidate(apple = [40, 30, 20],capacity = [10, 10, 10, 10, 10, 10, 10, 10]) == None\n assert candidate(apple = [20, 20, 10, 10],capacity = [15, 15, 15, 15, 15]) == 4\n assert candidate(apple = [25, 25, 25],capacity = [50, 50]) == 2\n assert candidate(apple = [45, 2, 3],capacity = [10, 10, 10, 10, 10]) == 5\n assert candidate(apple = [10, 20, 30],capacity = [5, 15, 25, 10]) == None\n assert candidate(apple = [10, 20, 30],capacity = [5, 15, 20, 10]) == None\n assert candidate(apple = [3, 7, 2, 8],capacity = [5, 10, 3, 6, 1]) == 3\n assert candidate(apple = [25, 25, 25, 25],capacity = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(apple = [8, 16, 32, 64],capacity = [32, 32, 32, 32, 32, 32]) == 4\n assert candidate(apple = [40, 40, 40, 40],capacity = [20, 20, 20, 20, 20, 20, 20, 20]) == 8\n assert candidate(apple = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacity = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 49\n assert candidate(apple = [10, 20, 30, 40],capacity = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 20\n assert candidate(apple = [49, 49, 49],capacity = [16, 16, 16, 16, 16, 16]) == None\n assert candidate(apple = [50, 50, 50, 50, 50],capacity = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 6\n assert candidate(apple = [15, 25, 10, 5],capacity = [10, 20, 5, 5, 5, 5]) == None\n assert candidate(apple = [23, 17, 15, 12],capacity = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 7\n assert candidate(apple = [5, 10, 15, 20, 25],capacity = [30, 20, 10, 5, 1, 1, 1, 1]) == None\n assert candidate(apple = [4, 4, 4, 4, 4],capacity = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 7\n assert candidate(apple = [45, 3, 2, 1],capacity = [40, 5, 3, 2, 1, 1, 1, 1, 1]) == 5\n assert candidate(apple = [45, 5, 5],capacity = [25, 20, 5, 5, 5, 5]) == 4\n assert candidate(apple = [10, 10, 10, 10, 10],capacity = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 10\n assert candidate(apple = [1, 2, 3, 4, 5],capacity = [15, 10, 5]) == 1\n assert candidate(apple = [3, 3, 3, 3, 3, 3],capacity = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 18\n assert candidate(apple = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],capacity = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == None\n assert candidate(apple = [10, 20, 30, 40],capacity = [20, 20, 20, 20, 20]) == 5\n assert candidate(apple = [1, 2, 3, 4, 5],capacity = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == None\n assert candidate(apple = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacity = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 20\n assert candidate(apple = [45, 3, 2],capacity = [50, 25, 10, 5]) == 1\n assert candidate(apple = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],capacity = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 11\n assert candidate(apple = [45, 45, 45],capacity = [15, 15, 15, 15, 15, 15]) == None\n assert candidate(apple = [10, 20, 30],capacity = [5, 15, 10, 20, 25]) == 3\n assert candidate(apple = [50, 50, 50],capacity = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == None\n assert candidate(apple = [45, 30, 10, 5],capacity = [20, 15, 10, 5, 1]) == None\n assert candidate(apple = [10, 20, 30],capacity = [5, 15, 25, 35]) == 2\n assert candidate(apple = [8, 16, 24, 32],capacity = [4, 8, 12, 16, 20, 24, 28, 32]) == 3\n assert candidate(apple = [45, 30, 15],capacity = [10, 10, 10, 10, 10, 10]) == None\n assert candidate(apple = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacity = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 30\n assert candidate(apple = [40, 10, 10],capacity = [20, 20, 20, 20, 20, 20]) == 3\n assert candidate(apple = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],capacity = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(apple = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],capacity = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 8\n assert candidate(apple = [10, 20, 30, 40],capacity = [5, 10, 15, 20, 25, 30]) == 5\n"}, "metadata": {"canonical_parameter_names": ["apple", "capacity"], "leetcode_dataset_entry_point": "Solution().minimumBoxes", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumBoxes(vector& apple, vector& capacity) {", "container": "Solution", "callable": "minimumBoxes", "parameters": [{"name": "apple", "type": "vector&"}, {"name": "capacity", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3075, "task_id": "maximize-happiness-of-selected-children", "difficulty": "Medium", "problem_description": "You are given an array happiness of length n, and a positive integer k.\nThere are n children standing in a queue, where the ith child has happiness value happiness[i]. You want to select k children from these n children in k turns.\nIn each turn, when you select a child, the happiness value of all the children that have not been selected till now decreases by 1. Note that the happiness value cannot become negative and gets decremented only if it is positive.\nReturn the maximum sum of the happiness values of the selected children you can achieve by selecting k children.\n \nExample 1:\n\nInput: happiness = [1,2,3], k = 2\nOutput: 4\nExplanation: We can pick 2 children in the following way:\n- Pick the child with the happiness value == 3. The happiness value of the remaining children becomes [0,1].\n- Pick the child with the happiness value == 1. The happiness value of the remaining child becomes [0]. Note that the happiness value cannot become less than 0.\nThe sum of the happiness values of the selected children is 3 + 1 = 4.\n\nExample 2:\n\nInput: happiness = [1,1,1,1], k = 2\nOutput: 1\nExplanation: We can pick 2 children in the following way:\n- Pick any child with the happiness value == 1. The happiness value of the remaining children becomes [0,0,0].\n- Pick the child with the happiness value == 0. The happiness value of the remaining child becomes [0,0].\nThe sum of the happiness values of the selected children is 1 + 0 = 1.\n\nExample 3:\n\nInput: happiness = [2,3,4,5], k = 1\nOutput: 5\nExplanation: We can pick 1 child in the following way:\n- Pick the child with the happiness value == 5. The happiness value of the remaining children becomes [1,2,3].\nThe sum of the happiness values of the selected children is 5.\n\n \nConstraints:\n\n1 <= n == happiness.length <= 2 * 105\n1 <= happiness[i] <= 108\n1 <= k <= n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(happiness = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 30\n assert candidate(happiness = [10, 20, 30, 40, 50],k = 5) == 140\n assert candidate(happiness = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == 15\n assert candidate(happiness = [100000000, 100000000, 100000000],k = 2) == 199999999\n assert candidate(happiness = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 30\n assert candidate(happiness = [1],k = 1) == 1\n assert candidate(happiness = [100000000, 100000000, 100000000, 100000000],k = 2) == 199999999\n assert candidate(happiness = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 9) == 25\n assert candidate(happiness = [10, 9, 8, 7, 6],k = 3) == 24\n assert candidate(happiness = [100, 100, 100],k = 1) == 100\n assert candidate(happiness = [1, 1, 1, 1],k = 2) == 1\n assert candidate(happiness = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 5) == 12\n assert candidate(happiness = [1, 2, 3],k = 2) == 4\n assert candidate(happiness = [2, 3, 4, 5],k = 1) == 5\n assert candidate(happiness = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 1\n assert candidate(happiness = [5, 4, 3, 2, 1],k = 3) == 9\n assert candidate(happiness = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 3) == 12\n assert candidate(happiness = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10],k = 5) == 40\n assert candidate(happiness = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == 24\n assert candidate(happiness = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],k = 10) == 15\n assert candidate(happiness = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 1\n assert candidate(happiness = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 4) == 334\n assert candidate(happiness = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 12) == 110\n assert candidate(happiness = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 15) == 15\n assert candidate(happiness = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 18) == 55\n assert candidate(happiness = [10, 20, 30, 40, 50],k = 3) == 117\n assert candidate(happiness = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9],k = 7) == 24\n assert candidate(happiness = [100000000, 90000000, 80000000, 70000000, 60000000, 50000000, 40000000, 30000000, 20000000, 10000000],k = 10) == 549999955\n assert candidate(happiness = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 10) == 5455\n assert candidate(happiness = [50, 40, 30, 20, 10, 0, -10, -20, -30, -40],k = 6) == 140\n assert candidate(happiness = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 15) == 40\n assert candidate(happiness = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 7) == 1\n assert candidate(happiness = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 110\n assert candidate(happiness = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 10) == 3\n assert candidate(happiness = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81],k = 10) == 910\n assert candidate(happiness = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 8) == 492\n assert candidate(happiness = [1, 100000000, 1, 100000000, 1, 100000000, 1, 100000000, 1, 100000000],k = 5) == 499999990\n assert candidate(happiness = [98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79],k = 15) == 1260\n assert candidate(happiness = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 15) == 273\n assert candidate(happiness = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 10\n assert candidate(happiness = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 6) == 30\n assert candidate(happiness = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 100) == 1\n assert candidate(happiness = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 8) == 156\n assert candidate(happiness = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 7) == 63\n assert candidate(happiness = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 15) == 1\n assert candidate(happiness = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 15) == 9995\n assert candidate(happiness = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 7) == 63\n assert candidate(happiness = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 20) == 110\n assert candidate(happiness = [100000000, 90000000, 80000000, 70000000, 60000000, 50000000, 40000000, 30000000, 20000000, 10000000],k = 5) == 399999990\n assert candidate(happiness = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71],k = 10) == 465\n assert candidate(happiness = [9, 7, 5, 3, 1, 8, 6, 4, 2, 0, 9, 7, 5, 3, 1, 8, 6, 4, 2, 0],k = 10) == 33\n assert candidate(happiness = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],k = 10) == 910\n assert candidate(happiness = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 30\n assert candidate(happiness = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 10) == 40\n assert candidate(happiness = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 5) == 3990\n assert candidate(happiness = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 3) == 132\n assert candidate(happiness = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 7) == 30\n assert candidate(happiness = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],k = 15) == 256\n assert candidate(happiness = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10],k = 4) == 34\n assert candidate(happiness = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 10],k = 15) == 43\n assert candidate(happiness = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 8) == 25\n assert candidate(happiness = [5, 4, 3, 2, 1],k = 3) == 9\n assert candidate(happiness = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 15) == 55\n assert candidate(happiness = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 390\n assert candidate(happiness = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 1\n assert candidate(happiness = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 6) == 20\n assert candidate(happiness = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 15) == 64\n assert candidate(happiness = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 5) == 3\n assert candidate(happiness = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 25\n assert candidate(happiness = [100, 50, 10, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 159\n assert candidate(happiness = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],k = 8) == 772\n assert candidate(happiness = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 15) == 1845\n assert candidate(happiness = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 15\n assert candidate(happiness = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 390\n assert candidate(happiness = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10],k = 8) == 40\n assert candidate(happiness = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 20) == 1\n assert candidate(happiness = [20, 15, 10, 5, 0, 0, 0, 0, 0, 0],k = 4) == 44\n assert candidate(happiness = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],k = 9) == 9864\n assert candidate(happiness = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 30\n assert candidate(happiness = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5],k = 5) == 30\n assert candidate(happiness = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 20) == 240\n assert candidate(happiness = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 5) == 30\n assert candidate(happiness = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1],k = 5) == 12\n assert candidate(happiness = [5, 15, 25, 35, 45, 55, 65],k = 4) == 194\n assert candidate(happiness = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 15) == 240\n assert candidate(happiness = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 15) == 110\n assert candidate(happiness = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 30\n assert candidate(happiness = [5, 3, 8, 6, 2, 7, 4, 9, 1, 10],k = 6) == 30\n assert candidate(happiness = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14],k = 8) == 64\n assert candidate(happiness = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5],k = 10) == 14\n assert candidate(happiness = [100000000, 90000000, 80000000, 70000000, 60000000],k = 3) == 269999997\n assert candidate(happiness = [5, 15, 25, 35, 45, 55],k = 4) == 154\n assert candidate(happiness = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 30\n assert candidate(happiness = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == 505\n assert candidate(happiness = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 10) == 255\n assert candidate(happiness = [5, 3, 8, 6, 2, 7, 4, 1, 9],k = 4) == 24\n assert candidate(happiness = [100, 50, 25, 12, 6, 3, 1, 0, 0, 0],k = 5) == 183\n assert candidate(happiness = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 15) == 15\n assert candidate(happiness = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 3) == 267\n assert candidate(happiness = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11],k = 5) == 35\n"}, "metadata": {"canonical_parameter_names": ["happiness", "k"], "leetcode_dataset_entry_point": "Solution().maximumHappinessSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "long long maximumHappinessSum(vector& happiness, int k) {", "container": "Solution", "callable": "maximumHappinessSum", "parameters": [{"name": "happiness", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "long long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3076, "task_id": "shortest-uncommon-substring-in-an-array", "difficulty": "Medium", "problem_description": "You are given an array arr of size n consisting of non-empty strings.\nFind a string array answer of size n such that:\n\nanswer[i] is the shortest substring of arr[i] that does not occur as a substring in any other string in arr. If multiple such substrings exist, answer[i] should be the lexicographically smallest. And if no such substring exists, answer[i] should be an empty string.\n\nReturn the array answer.\n \nExample 1:\n\nInput: arr = [\"cab\",\"ad\",\"bad\",\"c\"]\nOutput: [\"ab\",\"\",\"ba\",\"\"]\nExplanation: We have the following:\n- For the string \"cab\", the shortest substring that does not occur in any other string is either \"ca\" or \"ab\", we choose the lexicographically smaller substring, which is \"ab\".\n- For the string \"ad\", there is no substring that does not occur in any other string.\n- For the string \"bad\", the shortest substring that does not occur in any other string is \"ba\".\n- For the string \"c\", there is no substring that does not occur in any other string.\n\nExample 2:\n\nInput: arr = [\"abc\",\"bcd\",\"abcd\"]\nOutput: [\"\",\"\",\"abcd\"]\nExplanation: We have the following:\n- For the string \"abc\", there is no substring that does not occur in any other string.\n- For the string \"bcd\", there is no substring that does not occur in any other string.\n- For the string \"abcd\", the shortest substring that does not occur in any other string is \"abcd\".\n\n \nConstraints:\n\nn == arr.length\n2 <= n <= 100\n1 <= arr[i].length <= 20\narr[i] consists only of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = ['abcabc', 'bcabc', 'cabc', 'abcd']) == ['abca', '', '', 'd']\n assert candidate(arr = ['aaa', 'aab', 'aba', 'abb']) == ['aaa', 'aab', 'ba', 'bb']\n assert candidate(arr = ['abc', 'bcd', 'abcd']) == ['', '', 'abcd']\n assert candidate(arr = ['abcd', 'bcde', 'cdef', 'defg']) == ['a', 'bcde', 'cdef', 'g']\n assert candidate(arr = ['hello', 'world', 'hel', 'wor', 'ld']) == ['ll', 'rl', '', '', '']\n assert candidate(arr = ['unique', 'strings', 'array', 'test']) == ['q', 'g', 'a', 'es']\n assert candidate(arr = ['cab', 'ad', 'bad', 'c']) == ['ab', '', 'ba', '']\n assert candidate(arr = ['aaaa', 'aaab', 'aabb', 'abbb']) == ['aaaa', 'aaab', 'aabb', 'bbb']\n assert candidate(arr = ['xyz', 'zyx', 'yzx']) == ['xy', 'yx', 'zx']\n assert candidate(arr = ['abcde', 'bcdef', 'cdefg', 'defgh']) == ['a', 'bcdef', 'cdefg', 'h']\n assert candidate(arr = ['a', 'b', 'c', 'd']) == ['a', 'b', 'c', 'd']\n assert candidate(arr = ['hello', 'world', 'python', 'programming']) == ['e', 'd', 't', 'a']\n assert candidate(arr = ['same', 'same', 'same', 'same']) == ['', '', '', '']\n assert candidate(arr = ['banana', 'bandana', 'band']) == ['nan', 'da', '']\n assert candidate(arr = ['aaa', 'aab', 'aac', 'abc']) == ['aaa', 'aab', 'ac', 'bc']\n assert candidate(arr = ['abc', 'def', 'ghi', 'jkl', 'mno']) == ['a', 'd', 'g', 'j', 'm']\n assert candidate(arr = ['banana', 'ananas', 'nana', 'ana', 'nan']) == ['b', 's', '', '', '']\n assert candidate(arr = ['xyz', 'xyzz', 'xyzzz', 'xyzzzz']) == ['', '', '', 'zzzz']\n assert candidate(arr = ['mississippi', 'missouri', 'mismatch', 'misinterpret', 'misspoke']) == ['ip', 'u', 'a', 'n', 'k']\n assert candidate(arr = ['abcdefghij', 'bcdefghijk', 'cdefghijkl', 'defghijklm', 'efghijklmn', 'fghijklmno', 'ghijklmnop', 'hijklmnopq', 'ijklmnopqr', 'jklmnopqrs']) == ['a', 'bcdefghijk', 'cdefghijkl', 'defghijklm', 'efghijklmn', 'fghijklmno', 'ghijklmnop', 'hijklmnopq', 'ijklmnopqr', 's']\n assert candidate(arr = ['mississippi', 'missouri', 'miss', 'mis', 'is', 'sip', 'pip']) == ['pp', 'o', '', '', '', '', 'pip']\n assert candidate(arr = ['abacabadabacaba', 'bacabadaba', 'acabadaba', 'cabacaba', 'abacaba', 'bacaba', 'acaba', 'cabaca']) == ['dabac', '', '', 'cabacab', '', '', '', '']\n assert candidate(arr = ['banana', 'anana', 'nana', 'ana', 'na', 'a', 'bandana', 'band']) == ['bana', '', '', '', '', '', 'da', '']\n assert candidate(arr = ['aabbcc', 'bbccdd', 'ccddaa', 'ddeaab']) == ['abb', 'bccd', 'da', 'e']\n assert candidate(arr = ['aabbccddeeff', 'bbaacceeffdd', 'ccddeeffaabb', 'ddeeffaabbcc', 'eeffddbbaacc', 'ffddbbaaccee']) == ['bccd', 'ceef', 'cddeeffa', 'faabbc', 'effddb', 'dbbaacce']\n assert candidate(arr = ['zxyzyx', 'zyxzyx', 'yzyxzy', 'xyzyxz', 'yzyxzyx', 'zyxzyxzy']) == ['zx', '', '', 'xyzyxz', 'yzyxzyx', 'xzyxz']\n assert candidate(arr = ['banana', 'ananas', 'nana', 'anan']) == ['b', 's', '', '']\n assert candidate(arr = ['abacabadaba', 'bacabadabac', 'acabadabaca', 'cadabacabad', 'adabacabadab']) == ['abacabadaba', 'bacabadabac', 'badabaca', 'cad', 'dabacabada']\n assert candidate(arr = ['xyxyxy', 'yxyx', 'xyx', 'yx', 'xyz', 'zyx']) == ['xyxy', '', '', '', 'yz', 'zy']\n assert candidate(arr = ['xyx', 'yxy', 'xyxy', 'yxyx', 'xyxyx', 'yxyxy']) == ['', '', '', '', 'xyxyx', 'yxyxy']\n assert candidate(arr = ['abacabad', 'bacabadab', 'acabadabc', 'cababad']) == ['abac', 'bacabada', 'bc', 'bab']\n assert candidate(arr = ['zzzzz', 'zzzz', 'zzz', 'zz', 'z']) == ['zzzzz', '', '', '', '']\n assert candidate(arr = ['aabbccddeeff', 'bbccddeeffaa', 'ccddeeffaabb', 'ddeeffaabbcc', 'eeffaabbc', 'ffaabbcdd', 'aabbcdd', 'bbccdd', 'ccdd', 'ddee', 'eff', 'ff', 'ee', 'dd', 'cc', 'bb', 'aa']) == ['abbccd', 'bccddeeffa', 'cddeeffaab', 'faabbcc', '', 'faabbcd', '', '', '', '', '', '', '', '', '', '', '']\n assert candidate(arr = ['longstring', 'longstringa', 'longstringb', 'longstringc', 'longstringd', 'longstringe']) == ['', 'a', 'b', 'c', 'd', 'e']\n assert candidate(arr = ['aaaaab', 'bbbbb', 'cccc', 'dddd', 'eeeee', 'aaaaabbbb', 'bbbbbcccc', 'ccccdddd', 'ddddeeee']) == ['', '', '', '', 'eeeee', 'abb', 'bc', 'cd', 'de']\n assert candidate(arr = ['aabbccddeeff', 'bbaacceeffgg', 'ccaabbeeffhh', 'ddbbccffeeii', 'eekkllmmnn', 'ffggklllnnoo', 'gggghhkkllmm', 'hhhiiikkllmm', 'iiijjkklmmnn', 'jjjjkkklnnnoo']) == ['cd', 'ac', 'be', 'cf', 'ek', 'gk', 'gh', 'hi', 'ij', 'jjj']\n assert candidate(arr = ['abcdef', 'bcdefg', 'cdefgh', 'defghi', 'efghij', 'fghijk', 'ghijkl']) == ['a', 'bcdefg', 'cdefgh', 'defghi', 'efghij', 'fghijk', 'l']\n assert candidate(arr = ['abacaba', 'cabcabc', 'babcbab', 'abcabca', 'babcabc', 'cacacac', 'abcabcabc', 'bcabcbc', 'abcbcab', 'cacbcac']) == ['aba', '', 'cba', '', 'babca', 'acac', 'bcabcab', 'cabcb', 'bcbca', 'acb']\n assert candidate(arr = ['mississippi', 'mississippis', 'mississippii', 'mississippiii', 'mississippiiii']) == ['', 'pis', '', '', 'iiii']\n assert candidate(arr = ['xyz', 'xyzz', 'xyzzy', 'xyzzz', 'zyxzyx']) == ['', '', 'zzy', 'zzz', 'xz']\n assert candidate(arr = ['aaaabbbb', 'bbbbaaaa', 'aabbaabb', 'baabbaab', 'bbaabbab']) == ['aaab', 'baaa', 'abbaabb', 'baabbaa', 'bab']\n assert candidate(arr = ['abacaba', 'bacabab', 'acababa']) == ['abac', 'bacabab', 'baba']\n assert candidate(arr = ['pqr', 'pqs', 'pqt', 'pqu', 'pqv', 'pqw', 'pqx', 'pqy', 'pqz']) == ['r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']\n assert candidate(arr = ['abcdefgh', 'efghijkl', 'ghijklmn', 'hijklmno', 'ijklmnop']) == ['a', 'fghi', 'ghijklm', 'hijklmno', 'p']\n assert candidate(arr = ['banana', 'nanana', 'anana', 'bananaaa', 'anananan', 'ananan', 'anan', 'ana', 'a', 'n', 'an', 'na']) == ['', '', '', 'aa', 'ananana', '', '', '', '', '', '', '']\n assert candidate(arr = ['abcdefg', 'bcd', 'cde', 'def', 'efg', 'fgh', 'ghi', 'hij', 'ijk', 'jkl', 'klm', 'lmn', 'mno', 'nop', 'opq', 'pqr', 'qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyz']) == ['a', '', '', '', '', 'fgh', 'ghi', 'hij', 'ijk', 'jkl', 'klm', 'lmn', 'mno', 'nop', 'opq', 'pqr', 'qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'z']\n assert candidate(arr = ['abcdefghij', 'jabcdefghi', 'ijabcdefgh', 'hijabcdefg', 'ghijabcdef', 'fghijabcde', 'efghijabcd', 'defghijabc', 'cdefghijab', 'bcdefghija']) == ['abcdefghij', 'jabcdefghi', 'ijabcdefgh', 'hijabcdefg', 'ghijabcdef', 'fghijabcde', 'efghijabcd', 'defghijabc', 'cdefghijab', 'bcdefghija']\n assert candidate(arr = ['abcdefg', 'bcdefgh', 'cdefghi', 'defghij', 'efghijk', 'fghijkl', 'ghijklm']) == ['a', 'bcdefgh', 'cdefghi', 'defghij', 'efghijk', 'fghijkl', 'm']\n assert candidate(arr = ['mamma', 'pappa', 'bappa', 'kappa', 'dappa', 'lappa', 'sappa', 'tappa', 'gappa', 'yappa', 'xappa']) == ['m', 'pap', 'b', 'k', 'd', 'l', 's', 't', 'g', 'y', 'x']\n assert candidate(arr = ['algorithm', 'logarithm', 'rhythm', 'algorithmic', 'algorhythm']) == ['', 'ar', '', 'c', 'orh']\n assert candidate(arr = ['pqrstuvw', 'qrstuvwx', 'rstuvwxy', 'stuvwxyz', 'tuvwxyzx', 'uvwxyzxy', 'vwxyzxyz']) == ['p', 'qrstuvwx', 'rstuvwxy', 'stuvwxyz', 'tuvwxyzx', 'uvwxyzxy', 'zxyz']\n assert candidate(arr = ['xyxzyxzyx', 'yxyxzyxzx', 'xzyxzyxzy', 'zyxzyxzyx', 'yxzxzyxzy']) == ['xyxzyxzy', 'yxy', 'xzyxzyxz', 'zyxzyxzyx', 'zxz']\n assert candidate(arr = ['abcdefghij', 'bcdefghija', 'cdefghijab', 'defghijabc', 'efghijabcd', 'fghijabcde', 'ghijabcdef', 'hijabcdefg', 'ijabcdefgh', 'jabcdefghi']) == ['abcdefghij', 'bcdefghija', 'cdefghijab', 'defghijabc', 'efghijabcd', 'fghijabcde', 'ghijabcdef', 'hijabcdefg', 'ijabcdefgh', 'jabcdefghi']\n assert candidate(arr = ['mississippi', 'missouri', 'miss', 'issi', 'siss']) == ['p', 'o', '', '', '']\n assert candidate(arr = ['hello', 'world', 'hold', 'hellohold', 'holdworld']) == ['', '', '', 'oh', 'dw']\n assert candidate(arr = ['elephant', 'elephantology', 'elephantine', 'elephantmania', 'elephantdom', 'elephants']) == ['', 'g', 'in', 'ia', 'd', 's']\n assert candidate(arr = ['abcdabcd', 'cdabcdab', 'bcabcdab', 'ababcdcd', 'abcdabcd', 'cdabcdabcd', 'abcdabcda', 'bcdabcdabc', 'abcdabcdab', 'abcdabcdabc']) == ['', '', 'ca', 'ba', '', 'dabcdabcd', '', '', '', 'abcdabcdabc']\n assert candidate(arr = ['hellohello', 'elloworld', 'loworldhe', 'oworldhel', 'worldhell', 'orldhello', 'rldhelloe', 'ldhelloel', 'dhelloell']) == ['oh', 'llow', 'loworldh', 'oworldhel', 'worldhell', 'orldhello', 'rldhelloe', 'ldhelloel', 'oell']\n assert candidate(arr = ['nancy', 'randy', 'bandy', 'pancy', 'pandy', 'landy']) == ['na', 'r', 'b', 'panc', 'pand', 'l']\n assert candidate(arr = ['abcdabc', 'bcdbcda', 'cdabcdab']) == ['bcdabc', 'db', 'dabcd']\n assert candidate(arr = ['abcabcabc', 'bcabcabca', 'cabcabcab', 'abcabcaaa', 'abcaaacab', 'caaacabca', 'aaacabcab']) == ['abcabcabc', 'bcabcabca', 'cabcabcab', 'cabcaa', 'bcaaac', 'caaacabc', 'acabcab']\n assert candidate(arr = ['abcdefg', 'bcdefga', 'cdefgab', 'defgabc', 'efgabcd', 'fgabcde', 'gabcdef']) == ['abcdefg', 'bcdefga', 'cdefgab', 'defgabc', 'efgabcd', 'fgabcde', 'gabcdef']\n assert candidate(arr = ['abcdabcd', 'bcdbcdbd', 'cdabcdab', 'dabcdabc', 'abcdabca']) == ['bcdabcd', 'bd', 'cdabcda', 'dabcdabc', 'ca']\n assert candidate(arr = ['xxyyyzzz', 'yyzzzxxy', 'zzxxyyyz', 'xzzyyxxy', 'yzzxxyyy', 'zxyyyzzx']) == ['yyyzzz', 'zzzx', 'zxxyyyz', 'xz', 'yzzxx', 'zxy']\n assert candidate(arr = ['algorithm', 'logarithm', 'rhythm', 'algorithmic', 'logarithmic', 'rhythmical']) == ['', '', '', 'orithmi', 'arithmi', 'ca']\n assert candidate(arr = ['abcdefg', 'bcdefgh', 'cdefghi', 'defghij', 'efghijk']) == ['a', 'bcdefgh', 'cdefghi', 'defghij', 'k']\n assert candidate(arr = ['abacabad', 'bacabad', 'acabad', 'cabad', 'abad', 'bad', 'ad', 'd']) == ['abac', '', '', '', '', '', '', '']\n assert candidate(arr = ['zxy', 'zyx', 'xyz', 'yzx', 'xzy', 'yxz', 'zyxz', 'zxzy', 'yxzx', 'xyzy']) == ['zxy', '', '', 'yzx', '', '', 'zyxz', 'zxz', 'xzx', 'yzy']\n assert candidate(arr = ['aaaabc', 'aabbb', 'acabc', 'bbccc', 'aabbcc']) == ['aaa', 'bbb', 'ac', 'ccc', 'abbc']\n assert candidate(arr = ['zzzzzz', 'zzzzzy', 'zzzyzz', 'zzyzzz']) == ['zzzzzz', 'zzzzy', 'zzzyz', 'yzzz']\n assert candidate(arr = ['mississippi', 'mississippis', 'mississippiss', 'mississippisss', 'mississippi', 'mississippis', 'mississippiss', 'mississippisss', 'mississippi']) == ['', '', '', '', '', '', '', '', '']\n assert candidate(arr = ['xyzzxyzz', 'zzyxzyzx', 'yzyzyzyz']) == ['xy', 'xz', 'yzy']\n assert candidate(arr = ['zxy', 'zyx', 'yzx', 'xyz', 'yxz', 'xzy', 'zyx']) == ['zxy', '', 'yzx', 'xyz', 'yxz', 'xzy', '']\n assert candidate(arr = ['aabbccddeeff', 'bbccddeeffgg', 'ccddeeffgghh', 'ddeeffgghhii', 'eeffgghhiijj']) == ['a', 'bccddeeffg', 'cddeeffggh', 'deeffgghhi', 'j']\n assert candidate(arr = ['aabbccdd', 'bbaacccd', 'ccddaabb', 'ddccbbaa', 'aabbddcc']) == ['bc', 'ac', 'da', 'cb', 'bd']\n assert candidate(arr = ['xyxyxyxy', 'yxyxyxyx', 'xyxyxyyx', 'xyxxyxyx', 'xxyxyxyx']) == ['xyxyxyxy', 'yxyxyxyx', 'yy', 'yxx', 'xxyxyxy']\n assert candidate(arr = ['aaaaabbbbb', 'bbbbbccccc', 'cccccddddd', 'dddddeeeee', 'eeeeefffff']) == ['a', 'bc', 'cd', 'de', 'f']\n assert candidate(arr = ['abcdabcd', 'bcdbcdbcd', 'cdcdcdcd', 'dcdcdcdc', 'cdcdcd']) == ['a', 'db', 'cdcdcdcd', 'dcdcdcdc', '']\n assert candidate(arr = ['zzzzzzz', 'zzzzzzzz', 'zzzzzzzzz', 'zzzzzzzzzz']) == ['', '', '', 'zzzzzzzzzz']\n assert candidate(arr = ['mnopqrst', 'nopqrstu', 'opqrstuv', 'pqrstuvw', 'qrstuvwx', 'rstuvwxy', 'stuvwxyz', 'tuvwxyzx']) == ['m', 'nopqrstu', 'opqrstuv', 'pqrstuvw', 'qrstuvwx', 'rstuvwxy', 'stuvwxyz', 'zx']\n assert candidate(arr = ['abababab', 'baba', 'ab', 'ba', 'aba', 'bab']) == ['abab', '', '', '', '', '']\n assert candidate(arr = ['aabbcc', 'bbaacc', 'aabbbc', 'aabbccdd', 'aabccdde', 'aabbccde']) == ['', 'ac', 'bbb', 'bbccdd', 'abc', 'cde']\n assert candidate(arr = ['abcdef', 'defgh', 'fghij', 'ghijkl', 'hijklm', 'ijklmn']) == ['a', 'efg', 'fghi', 'ghijk', 'hijklm', 'n']\n assert candidate(arr = ['abcabc', 'bcabc', 'cabc', 'abcd', 'bcde', 'cdef']) == ['abca', '', '', 'abcd', 'bcde', 'f']\n assert candidate(arr = ['zzzzzzzzzz', 'zzzzzzzzzy', 'zzzzzzzzzx', 'zzzzzzzzww', 'zzzzzzzvvv', 'zzzzzzuuuu', 'zzzzzttttt', 'zzzzsssss', 'zzzrrrrr', 'zzqqqqq', 'zppppp', 'oooooo']) == ['zzzzzzzzzz', 'y', 'x', 'w', 'v', 'u', 't', 's', 'r', 'q', 'p', 'o']\n assert candidate(arr = ['abcde', 'bcdef', 'cdefg', 'defgh', 'efghi']) == ['a', 'bcdef', 'cdefg', 'defgh', 'i']\n assert candidate(arr = ['aaa', 'aab', 'aba', 'baa', 'aabbaa', 'baabaa', 'aabaab', 'baabaa', 'abaaab', 'aababa']) == ['', '', '', '', 'bb', '', 'abaab', '', 'aaab', 'bab']\n assert candidate(arr = ['mississippi', 'missouri', 'missed', 'miss', 'mississippi']) == ['', 'o', 'd', '', '']\n assert candidate(arr = ['aaaabbbb', 'aabbbbaa', 'abbaabba', 'bbaaaabb']) == ['aaabbb', 'bbba', 'abba', 'baaa']\n assert candidate(arr = ['aaaaab', 'bbbba', 'abbbb', 'baaaa', 'abba', 'baba']) == ['aab', 'bbba', 'abbb', 'baa', 'abba', 'aba']\n assert candidate(arr = ['aabbcc', 'bbaacc', 'ccaabb', 'aabbbc', 'bbccaa']) == ['abbc', 'ac', 'caab', 'bbb', 'bcca']\n assert candidate(arr = ['abcde', 'bcdef', 'cdefg', 'defgh', 'efghi', 'fghij', 'ghijk', 'hijkl', 'ijklm', 'jklmn']) == ['a', 'bcdef', 'cdefg', 'defgh', 'efghi', 'fghij', 'ghijk', 'hijkl', 'ijklm', 'n']\n assert candidate(arr = ['elephant', 'elphant', 'lphant', 'phant', 'hant', 'ant', 'nt', 't']) == ['ep', 'elp', '', '', '', '', '', '']\n assert candidate(arr = ['abcdabcd', 'bcdabcda', 'cdabcdab', 'dabcabcd']) == ['abcdabc', 'bcdabcda', 'dabcdab', 'ca']\n assert candidate(arr = ['aaaaaaa', 'aaaaaab', 'aaaaabb', 'aaaabb', 'aaabb', 'aabb', 'abb', 'bb']) == ['aaaaaaa', 'aaaaaab', 'aaaaabb', '', '', '', '', '']\n assert candidate(arr = ['apple', 'application', 'applet', 'app']) == ['', 'c', 'et', '']\n assert candidate(arr = ['xzy', 'zyx', 'xyzzy', 'zyxzyx']) == ['', '', 'xy', 'yxz']\n assert candidate(arr = ['abcdefg', 'bcdefgh', 'cdefghi', 'defghij', 'efghijk', 'fghijkl']) == ['a', 'bcdefgh', 'cdefghi', 'defghij', 'efghijk', 'l']\n assert candidate(arr = ['aaaaabbbbb', 'bbbbbccccc', 'cccccaaaaa', 'dddddeeeee', 'eeeeeaaaaa', 'fffffbbbbb', 'gggggccccc', 'hhhhhdddd', 'iiiiieeeee', 'jjjjjfffff', 'kkkkkggggg', 'lllllhhhhh', 'mmmmmiiiii', 'nnnnnjjjjj', 'oooookkkkk', 'ppppplllll']) == ['ab', 'bc', 'ca', 'de', 'ea', 'fb', 'gc', 'hd', 'ie', 'jf', 'kg', 'lh', 'm', 'n', 'o', 'p']\n assert candidate(arr = ['qwertyuiop', 'asdfghjkl', 'zxcvbnm', 'qwerty', 'asdfg', 'zxcvb']) == ['i', 'h', 'm', '', '', '']\n assert candidate(arr = ['abcdefghij', 'bcdefghij', 'cdefghij', 'defghij', 'efghij', 'fghij', 'ghij', 'hij', 'ij', 'j']) == ['a', '', '', '', '', '', '', '', '', '']\n assert candidate(arr = ['abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yzabcd', 'efghij', 'klmnop', 'qrstuv', 'wxyzab', 'cdefgh']) == ['bcde', 'jk', 'pq', 'vw', 'zabc', 'fghi', 'lm', 'rs', 'xy', 'defg']\n assert candidate(arr = ['unique', 'uneque', 'uniquely', 'uniqely', 'unieqly']) == ['', 'ne', 'uel', 'qe', 'ie']\n assert candidate(arr = ['aabbcc', 'ababab', 'abcabc', 'aabb', 'abbb', 'bbcc', 'acca', 'bbac', 'aabbccdd', 'bbccddaa']) == ['', 'aba', 'abc', '', 'bbb', '', 'acc', 'bac', 'abbccd', 'da']\n assert candidate(arr = ['aaaaaabbbbb', 'bbbbbccccc', 'cccccaaaaa', 'aacccbbbbb', 'bbcccaaaaa']) == ['ab', 'bbbc', 'cccca', 'ac', 'bccca']\n assert candidate(arr = ['algorithm', 'algorith', 'algorit', 'algori', 'algor', 'algo', 'algr', 'alg', 'al', 'a', 'bmw', 'bmv', 'bvw', 'b', 'm', 'w']) == ['hm', '', '', '', '', '', 'gr', '', '', '', 'mw', 'mv', 'bv', '', '', '']\n assert candidate(arr = ['abcabc', 'bcabcabc', 'cabcabcab', 'abcabcabc']) == ['', '', 'cabcabca', 'abcabcabc']\n assert candidate(arr = ['aabbccddeeff', 'bbccddeeffgg', 'ccddeeffgghh', 'ddeeffgghhii', 'eeffgghhiijj', 'ffgghhiijjkk']) == ['a', 'bccddeeffg', 'cddeeffggh', 'deeffgghhi', 'effgghhiij', 'k']\n assert candidate(arr = ['abcdabcd', 'bcdbcd', 'cdabcd', 'dabcabcd', 'abcddabc']) == ['bcda', 'db', '', 'ca', 'dd']\n"}, "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().shortestSubstrings", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector shortestSubstrings(vector& arr) {", "container": "Solution", "callable": "shortestSubstrings", "parameters": [{"name": "arr", "type": "vector&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3077, "task_id": "maximum-strength-of-k-disjoint-subarrays", "difficulty": "Hard", "problem_description": "You are given an array of integers nums with length n, and a positive odd integer k.\nSelect exactly k disjoint subarrays sub1, sub2, ..., subk from nums such that the last element of subi appears before the first element of sub{i+1} for all 1 <= i <= k-1. The goal is to maximize their combined strength.\nThe strength of the selected subarrays is defined as:\nstrength = k * sum(sub1)- (k - 1) * sum(sub2) + (k - 2) * sum(sub3) - ... - 2 * sum(sub{k-1}) + sum(subk)\nwhere sum(subi) is the sum of the elements in the i-th subarray.\nReturn the maximum possible strength that can be obtained from selecting exactly k disjoint subarrays from nums.\nNote that the chosen subarrays don't need to cover the entire array.\n \nExample 1:\nInput: nums = [1,2,3,-1,2], k = 3\nOutput: 22\nExplanation:\nThe best possible way to select 3 subarrays is: nums[0..2], nums[3..3], and nums[4..4]. The strength is calculated as follows:\nstrength = 3 * (1 + 2 + 3) - 2 * (-1) + 2 = 22\n \nExample 2:\nInput: nums = [12,-2,-2,-2,-2], k = 5\nOutput: 64\nExplanation:\nThe only possible way to select 5 disjoint subarrays is: nums[0..0], nums[1..1], nums[2..2], nums[3..3], and nums[4..4]. The strength is calculated as follows:\nstrength = 5 * 12 - 4 * (-2) + 3 * (-2) - 2 * (-2) + (-2) = 64\nExample 3:\nInput: nums = [-1,-2,-3], k = 1\nOutput: -1\nExplanation:\nThe best possible way to select 1 subarray is: nums[0..0]. The strength is -1.\n \nConstraints:\n\n1 <= n <= 104\n-109 <= nums[i] <= 109\n1 <= k <= n\n1 <= n * k <= 106\nk is odd.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [-10, -20, -30, -40, -50],k = 3) == 100\n assert candidate(nums = [12, -2, -2, -2, -2],k = 5) == 64\n assert candidate(nums = [5, 1, 2, 3, 4, 5, 6],k = 3) == 41\n assert candidate(nums = [1, -1, 1, -1, 1, -1],k = 3) == 6\n assert candidate(nums = [10, -5, 1, 0, 20, -1, 3],k = 5) == 138\n assert candidate(nums = [-1, -2, -3],k = 1) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 28\n assert candidate(nums = [5, -1, 3, -2, 4, -1, 2],k = 3) == 31\n assert candidate(nums = [10, 20, 30, 40, 50],k = 5) == 30\n assert candidate(nums = [0, 0, 0, 0, 0],k = 5) == 0\n assert candidate(nums = [100, -100, 100, -100, 100],k = 5) == 1500\n assert candidate(nums = [0, 0, 0, 0, 0],k = 1) == 0\n assert candidate(nums = [5, 3, 2, 7, 1, 9],k = 3) == 58\n assert candidate(nums = [1, 2, 3, -1, 2],k = 3) == 22\n assert candidate(nums = [5, 1, 3, 2, -4, 7],k = 3) == 48\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == 140\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 101) == 6111\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 19) == 115\n assert candidate(nums = [-10, 10, -10, 10, -10, 10, -10, 10, -10, 10],k = 5) == 150\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],k = 9) == 320\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 9) == 260\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15],k = 7) == 284\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, -10, -20, -30, -40, -50, -60, -70, -80, -90, -100],k = 11) == 6050\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 7) == 62\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 15) == 145\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 15) == 2515\n assert candidate(nums = [-1, -3, -5, -7, -9, -11, -13, -15, -17, -19],k = 3) == 138\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 17) == 981\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 17) == 1959\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500],k = 7) == 7800\n assert candidate(nums = [-5, 1, -3, 2, -1, 4, -2, 3, -1, 2, 5],k = 5) == 51\n assert candidate(nums = [100, 200, -100, 300, -200, 400, -300, 500, -400, 600],k = 7) == 10800\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 55\n assert candidate(nums = [5, 4, 3, 2, 1, 0, -1, -2, -3, -4],k = 7) == 92\n assert candidate(nums = [10, 20, 30, -5, -10, 40, 50, -15, 60, 70],k = 5) == 790\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 15) == 4000\n assert candidate(nums = [10, -5, 3, -2, 1, -1, 2, -3, 4, -4, 5, -5, 6, -6, 7, -7],k = 7) == 182\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 25) == 138\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9],k = 9) == 442\n assert candidate(nums = [1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000],k = 11) == 66000\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],k = 11) == 540\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],k = 5) == 52\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],k = 5) == 57\n assert candidate(nums = [100, -50, 25, -12, 6, -3, 1, -1, 0, 2],k = 5) == 805\n assert candidate(nums = [1000000000, -1000000000, 1000000000, -1000000000, 1000000000, -1000000000, 1000000000, -1000000000, 1000000000, -1000000000],k = 9) == 45000000000\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 9) == 104\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 19) == 1150\n assert candidate(nums = [0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7],k = 11) == 227\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 9) == 330\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 19) == 29\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 49) == 1642\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 7) == 288\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 5) == 9300\n assert candidate(nums = [-100, -200, -300, -400, -500, -600, -700, -800, -900, -1000],k = 5) == 8700\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 11) == 105\n assert candidate(nums = [-999999999, 999999999, -999999999, 999999999, -999999999, 999999999, -999999999, 999999999, -999999999, 999999999],k = 9) == 44999999955\n assert candidate(nums = [-10, 20, -30, 40, -50, 60, -70, 80, -90, 100],k = 5) == 1100\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 9) == 665\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500],k = 9) == 9500\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 11) == 0\n assert candidate(nums = [10, 20, -30, 40, -50, 60, -70, 80, -90, 100],k = 7) == 1680\n assert candidate(nums = [-10, 20, -30, 40, -50, 60, -70, 80, -90, 100, -110, 120],k = 7) == 2240\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100, -110, -120, -130, -140, -150, -160, -170, -180, -190, -200],k = 19) == 950\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 5) == 87\n assert candidate(nums = [-1000000000, 1000000000, -1000000000, 1000000000, -1000000000, 1000000000],k = 3) == 6000000000\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10],k = 5) == 95\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50, 60, -60],k = 7) == 1060\n assert candidate(nums = [-10, 20, -30, 40, -50, 60, -70, 80, -90, 100, -110, 120, -130, 140, -150],k = 9) == 3900\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],k = 19) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 5) == 308\n assert candidate(nums = [1000000000, -1000000000, 1000000000, -1000000000, 1000000000, -1000000000, 1000000000],k = 3) == 6000000000\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 9) == 22\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 15) == 80\n assert candidate(nums = [100, -100, 100, -100, 100, -100, 100, -100, 100, -100],k = 7) == 2800\n assert candidate(nums = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5, 6, 7, 8, 9, 10],k = 7) == 213\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 9) == 3300\n assert candidate(nums = [1000000000, -1000000000, 1000000000, -1000000000, 1000000000],k = 3) == 6000000000\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50, 60, -60, 70, -70, 80, -80, 90, -90, 100, -100],k = 9) == 3200\n assert candidate(nums = [10, -3, 4, -1, 2, 1, -5, 6, 7, -2, 8, -4],k = 5) == 136\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 9) == 25\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500],k = 5) == 5200\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],k = 11) == 20400\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000],k = 5) == 28000000000\n assert candidate(nums = [-1, 3, -2, 4, -5, 6, -7, 8, -9, 10],k = 7) == 175\n assert candidate(nums = [10, 20, 30, -10, -20, -30, 40, 50, 60, -40, -50, -60, 70, 80, 90, -70, -80, -90, 100, 110],k = 7) == 3580\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 3) == 1000\n assert candidate(nums = [100, -50, 200, -150, 300, -250, 400, -350, 500, -450],k = 7) == 7550\n assert candidate(nums = [5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5],k = 5) == 85\n assert candidate(nums = [100, -50, 200, -150, 300, -250, 400, -350, 500, -450],k = 5) == 5400\n assert candidate(nums = [-10, 10, -20, 20, -30, 30, -40, 40, -50, 50, -60, 60, -70, 70, -80, 80, -90, 90, -100, 100, -110, 110, -120, 120, -130, 130, -140, 140, -150, 150, -160, 160],k = 25) == 26780\n assert candidate(nums = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5],k = 9) == 115\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 11) == 618\n assert candidate(nums = [-5, -10, -15, -20, -25, -30, -35, -40, -45, -50],k = 5) == 435\n assert candidate(nums = [10, -1, 20, -2, 30, -3, 40, -4, 50, -5],k = 3) == 340\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 15) == 8\n assert candidate(nums = [-5, 0, 5, -10, 15, -20, 25, -30, 35, -40, 45, -50, 55, -60, 65, -70],k = 13) == 2275\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, -2, -3, -4, -5],k = 9) == 227\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50],k = 5) == 520\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 15) == 8\n assert candidate(nums = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100],k = 7) == 1400\n assert candidate(nums = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, 8],k = 13) == 385\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 15) == 120\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1],k = 3) == 12\n assert candidate(nums = [100, -100, 100, -100, 100, -100, 100, -100, 100, -100],k = 9) == 4500\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1],k = 9) == 45\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400],k = 7) == 5000\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 3) == 123\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],k = 19) == 715\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().maximumStrength", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "long long maximumStrength(vector& nums, int k) {", "container": "Solution", "callable": "maximumStrength", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "long long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3079, "task_id": "find-the-sum-of-encrypted-integers", "difficulty": "Easy", "problem_description": "You are given an integer array nums containing positive integers. We define a function encrypt such that encrypt(x) replaces every digit in x with the largest digit in x. For example, encrypt(523) = 555 and encrypt(213) = 333.\nReturn the sum of encrypted elements.\n \nExample 1:\n\nInput: nums = [1,2,3]\nOutput: 6\nExplanation: The encrypted elements are [1,2,3]. The sum of encrypted elements is 1 + 2 + 3 == 6.\n\nExample 2:\n\nInput: nums = [10,21,31]\nOutput: 66\nExplanation: The encrypted elements are [11,22,33]. The sum of encrypted elements is 11 + 22 + 33 == 66.\n\n \nConstraints:\n\n1 <= nums.length <= 50\n1 <= nums[i] <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [523, 213, 111]) == 999\n assert candidate(nums = [523, 213, 111]) == 999\n assert candidate(nums = [1, 10, 100, 1000]) == 1234\n assert candidate(nums = [999, 100, 101]) == 1221\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 45\n assert candidate(nums = [456, 789, 321]) == 1998\n assert candidate(nums = [1111, 2222, 3333, 4444, 5555]) == 16665\n assert candidate(nums = [987, 654, 321]) == 1998\n assert candidate(nums = [5, 15, 25, 35]) == 170\n assert candidate(nums = [100, 200, 300]) == 666\n assert candidate(nums = [12, 21, 34, 43, 56, 65]) == 264\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99]) == 495\n assert candidate(nums = [123, 456, 789]) == 1998\n assert candidate(nums = [9, 99, 999, 9999]) == 11106\n assert candidate(nums = [999, 888, 777]) == 2664\n assert candidate(nums = [123, 456, 789]) == 1998\n assert candidate(nums = [999, 123, 456]) == 1998\n assert candidate(nums = [1000, 100, 10, 1]) == 1234\n assert candidate(nums = [12, 23, 34, 45, 56, 67, 78, 89]) == 484\n assert candidate(nums = [999, 888, 777, 666]) == 3330\n assert candidate(nums = [5, 15, 25]) == 115\n assert candidate(nums = [111, 222, 333]) == 666\n assert candidate(nums = [11, 22, 33, 44, 55]) == 165\n assert candidate(nums = [999, 100, 200]) == 1332\n assert candidate(nums = [1, 2, 3]) == 6\n assert candidate(nums = [10, 21, 31]) == 66\n assert candidate(nums = [99, 999, 9999, 99999]) == 111096\n assert candidate(nums = [1, 11, 111, 1111, 11111]) == 12345\n assert candidate(nums = [567, 890, 1234, 54321, 98765]) == 161774\n assert candidate(nums = [1234, 4321, 1199, 2288, 3377]) == 35552\n assert candidate(nums = [987654, 321, 4321, 111, 222, 333]) == 1005442\n assert candidate(nums = [199, 299, 399, 499, 599, 699, 799, 899, 991]) == 8991\n assert candidate(nums = [987, 654, 321, 123, 456, 789, 101112]) == 226218\n assert candidate(nums = [865, 743, 219, 987, 567, 432, 321]) == 5217\n assert candidate(nums = [12345, 67890, 11122, 33344, 55566]) == 288886\n assert candidate(nums = [123456, 789012, 345678, 901234]) == 3555552\n assert candidate(nums = [901, 892, 783, 674, 567]) == 4440\n assert candidate(nums = [199, 288, 377, 466, 555, 644, 733, 822, 911]) == 7215\n assert candidate(nums = [345, 6789, 101112]) == 232776\n assert candidate(nums = [12345, 98765, 54321, 654321, 112233]) == 1211108\n assert candidate(nums = [987, 654, 321, 123, 456, 789, 876, 543, 210]) == 5661\n assert candidate(nums = [4321, 1111, 9999, 8765, 5432]) == 29997\n assert candidate(nums = [987, 654, 321, 987]) == 2997\n assert candidate(nums = [9876, 8765, 7654, 6543, 5432, 4321]) == 43329\n assert candidate(nums = [123, 122, 121, 120, 119]) == 1998\n assert candidate(nums = [1, 10, 100, 1000, 10000]) == 12345\n assert candidate(nums = [100, 200, 300, 400, 500]) == 1665\n assert candidate(nums = [12345, 67890, 111111, 222222]) == 488887\n assert candidate(nums = [1000, 999, 888, 777, 666]) == 4441\n assert candidate(nums = [123, 321, 456, 654, 789, 987, 111, 222, 333]) == 4662\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900]) == 4995\n assert candidate(nums = [50, 51, 52, 53, 54]) == 275\n assert candidate(nums = [1234, 5678, 91011, 121314]) == 557775\n assert candidate(nums = [987, 654, 321, 123, 456]) == 2997\n assert candidate(nums = [111, 222, 333, 444, 555, 666, 777, 888, 999]) == 4995\n assert candidate(nums = [9, 99, 999, 9999, 99999]) == 111105\n assert candidate(nums = [123, 234, 345, 456, 567, 678, 789, 890, 901]) == 6660\n assert candidate(nums = [1001, 2002, 3003, 4004]) == 11110\n assert candidate(nums = [123, 456, 789, 101112, 321, 654, 987]) == 226218\n assert candidate(nums = [56, 78, 90, 123, 456, 789]) == 2251\n assert candidate(nums = [12, 23, 34, 45, 56, 67, 78, 89, 90]) == 583\n assert candidate(nums = [9876, 5432, 1111, 2222, 3333]) == 22220\n assert candidate(nums = [19, 92, 299, 9992, 123456]) == 677862\n assert candidate(nums = [1234, 5678, 9012]) == 23331\n assert candidate(nums = [12, 345, 6789, 9876]) == 20575\n assert candidate(nums = [10203, 40506, 70809]) == 199998\n assert candidate(nums = [1234, 4321, 2341, 3412, 1243]) == 22220\n assert candidate(nums = [12, 123, 1234, 12345, 123456]) == 727020\n assert candidate(nums = [1234, 5678, 91011]) == 113331\n assert candidate(nums = [9876, 8765, 7654, 6543, 5432]) == 38885\n assert candidate(nums = [12, 21, 345, 543, 654]) == 1820\n assert candidate(nums = [100, 2000, 30000, 400000, 5000000]) == 6035665\n assert candidate(nums = [990, 881, 772, 663, 554, 445, 336, 227, 118]) == 6771\n assert candidate(nums = [101010, 202020, 303030, 404040, 505050, 606060, 707070, 808080, 909090]) == 4999995\n assert candidate(nums = [1000, 200, 30, 4, 56, 7890, 12345]) == 66990\n assert candidate(nums = [12, 345, 6789, 101, 202, 303, 404, 505, 606, 707, 808, 909]) == 15571\n assert candidate(nums = [59, 68, 77, 86, 95, 104, 213, 322, 431]) == 2005\n assert candidate(nums = [9876, 8765, 7654, 6543, 5432, 4321, 3210, 2109, 1098]) == 66660\n assert candidate(nums = [888, 887, 886, 885, 884]) == 4440\n assert candidate(nums = [12, 345, 6789, 101112]) == 232798\n assert candidate(nums = [98765, 43210, 11223, 44556, 77889]) == 344441\n assert candidate(nums = [101, 102, 103, 104, 105]) == 1665\n assert candidate(nums = [1001, 2002, 3003, 4004, 5005, 6006, 7007, 8008, 9009]) == 49995\n assert candidate(nums = [1010, 2020, 3030, 4040, 5050, 6060, 7070, 8080, 9090]) == 49995\n assert candidate(nums = [1234, 4321, 2341, 3412, 1243, 2134, 4123, 3214]) == 35552\n assert candidate(nums = [12, 234, 3456, 45678, 567890]) == 1096019\n assert candidate(nums = [112233, 223344, 334455, 445566, 556677, 667788, 778899]) == 4666662\n assert candidate(nums = [199, 299, 399, 499, 599]) == 4995\n assert candidate(nums = [1234, 5678, 9012, 3456, 7890]) == 39996\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000]) == 16665\n assert candidate(nums = [56, 65, 78, 87, 90, 900]) == 1406\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 606\n assert candidate(nums = [101, 202, 303, 404, 505]) == 1665\n assert candidate(nums = [199, 299, 399, 499, 599, 699, 799, 899, 999]) == 8991\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909]) == 4995\n assert candidate(nums = [987, 654, 321, 111, 222, 333]) == 2664\n assert candidate(nums = [98765, 87654, 76543, 65432, 54321]) == 388885\n assert candidate(nums = [123456789, 987654321, 112233445566778899, 1000000000]) == 1000000003111111108\n assert candidate(nums = [12, 345, 6789, 101]) == 10687\n assert candidate(nums = [1, 22, 333, 4444, 55555, 666666, 7777777, 88888888, 999999999]) == 1097393685\n assert candidate(nums = [111111, 222222, 333333, 444444, 555555]) == 1666665\n assert candidate(nums = [12345, 67890, 54321]) == 211109\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().sumOfEncryptedInt", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int sumOfEncryptedInt(vector& nums) {", "container": "Solution", "callable": "sumOfEncryptedInt", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3080, "task_id": "mark-elements-on-array-by-performing-queries", "difficulty": "Medium", "problem_description": "You are given a 0-indexed array nums of size n consisting of positive integers.\nYou are also given a 2D array queries of size m where queries[i] = [indexi, ki].\nInitially all elements of the array are unmarked.\nYou need to apply m queries on the array in order, where on the ith query you do the following:\n\nMark the element at index indexi if it is not already marked.\nThen mark ki unmarked elements in the array with the smallest values. If multiple such elements exist, mark the ones with the smallest indices. And if less than ki unmarked elements exist, then mark all of them.\n\nReturn an array answer of size m where answer[i] is the sum of unmarked elements in the array after the ith query.\n \nExample 1:\n\nInput: nums = [1,2,2,1,2,3,1], queries = [[1,2],[3,3],[4,2]]\nOutput: [8,3,0]\nExplanation:\nWe do the following queries on the array:\n\nMark the element at index 1, and 2 of the smallest unmarked elements with the smallest indices if they exist, the marked elements now are nums = [1,2,2,1,2,3,1]. The sum of unmarked elements is 2 + 2 + 3 + 1 = 8.\nMark the element at index 3, since it is already marked we skip it. Then we mark 3 of the smallest unmarked elements with the smallest indices, the marked elements now are nums = [1,2,2,1,2,3,1]. The sum of unmarked elements is 3.\nMark the element at index 4, since it is already marked we skip it. Then we mark 2 of the smallest unmarked elements with the smallest indices if they exist, the marked elements now are nums = [1,2,2,1,2,3,1]. The sum of unmarked elements is 0.\n\n\nExample 2:\n\nInput: nums = [1,4,2,3], queries = [[0,1]]\nOutput: [7]\nExplanation: We do one query which is mark the element at index 0 and mark the smallest element among unmarked elements. The marked elements will be nums = [1,4,2,3], and the sum of unmarked elements is 4 + 3 = 7.\n\n \nConstraints:\n\nn == nums.length\nm == queries.length\n1 <= m <= n <= 105\n1 <= nums[i] <= 105\nqueries[i].length == 2\n0 <= indexi, ki <= n - 1\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 20, 30, 40, 50],queries = [[4, 1], [0, 2], [2, 2]]) == [90, 40, 0]\n assert candidate(nums = [10, 20, 30, 40, 50],queries = [[0, 2], [1, 1]]) == [90, 50]\n assert candidate(nums = [5, 3, 8, 1, 4],queries = [[2, 1], [4, 2], [0, 2]]) == [12, 0, 0]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[0, 5], [3, 3], [1, 1]]) == [4, 1, 0]\n assert candidate(nums = [1, 4, 2, 3],queries = [[0, 1]]) == [7]\n assert candidate(nums = [1, 2, 2, 1, 2, 3, 1],queries = [[1, 2], [3, 3], [4, 2]]) == [8, 3, 0]\n assert candidate(nums = [7, 7, 7, 7, 7],queries = [[0, 3], [2, 2]]) == [7, 0]\n assert candidate(nums = [10, 20, 30, 40, 50],queries = [[1, 2], [2, 1], [4, 2]]) == [90, 50, 0]\n assert candidate(nums = [1, 1, 1, 1, 1],queries = [[0, 3], [1, 1], [2, 1]]) == [1, 0, 0]\n assert candidate(nums = [1, 1, 1, 1, 1],queries = [[0, 5], [1, 1]]) == [0, 0]\n assert candidate(nums = [1, 1, 1, 1, 1],queries = [[0, 2], [1, 1], [3, 2]]) == [2, 1, 0]\n assert candidate(nums = [10, 20, 30, 40, 50],queries = [[0, 3], [1, 2], [2, 1]]) == [50, 0, 0]\n assert candidate(nums = [5, 3, 1, 2, 4],queries = [[2, 1], [0, 2], [3, 3]]) == [12, 0, 0]\n assert candidate(nums = [10, 20, 30, 40, 50],queries = [[0, 3], [1, 1], [4, 1]]) == [50, 0, 0]\n assert candidate(nums = [5, 3, 8, 1, 9],queries = [[2, 1], [4, 2]]) == [17, 0]\n assert candidate(nums = [5, 5, 5, 5, 5],queries = [[2, 1], [0, 2], [1, 2]]) == [15, 5, 0]\n assert candidate(nums = [5, 5, 5, 5, 5],queries = [[0, 2], [1, 1], [2, 3]]) == [10, 5, 0]\n assert candidate(nums = [7, 5, 3, 8, 1, 4, 6, 2],queries = [[6, 2], [3, 1], [0, 3], [5, 2]]) == [27, 16, 0, 0]\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],queries = [[0, 5], [2, 3], [4, 2], [8, 1]]) == [12, 3, 0, 0]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queries = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1]]) == [5200, 4900, 4500, 4000, 3400, 2700, 1900, 1000, 0, 0]\n assert candidate(nums = [5, 2, 7, 3, 4, 1, 6, 8, 9, 10],queries = [[4, 2], [1, 1], [7, 3], [9, 2]]) == [48, 45, 19, 0]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [[0, 10], [1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [7, 5], [8, 5], [9, 5]]) == [70, 27, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[9, 3], [8, 2], [7, 1], [6, 4], [5, 5]]) == [39, 21, 7, 0, 0]\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],queries = [[0, 5], [1, 3], [2, 1], [3, 1], [4, 2]]) == [1111000000, 1000000000, 0, 0, 0]\n assert candidate(nums = [7, 3, 9, 1, 5, 2, 8, 4, 6, 10],queries = [[0, 2], [5, 3], [8, 2], [3, 1]]) == [45, 33, 10, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],queries = [[0, 10], [1, 5], [2, 3], [3, 2], [4, 1]]) == [144, 74, 20, 0, 0]\n assert candidate(nums = [1, 3, 2, 4, 6, 5, 7, 9, 8, 10],queries = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1]]) == [52, 45, 40, 34, 27, 19, 10, 0, 0, 0]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[0, 5], [2, 3], [4, 2], [9, 1]]) == [4, 1, 0, 0]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[0, 10], [1, 5], [9, 3], [3, 2]]) == [0, 0, 0, 0]\n assert candidate(nums = [5, 1, 4, 2, 3, 6, 7, 8, 9, 10],queries = [[0, 1], [1, 2], [2, 3], [3, 4]]) == [49, 44, 19, 0]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[0, 3], [1, 2], [2, 1], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == [450, 340, 270, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],queries = [[0, 5], [1, 5], [2, 5], [3, 5], [4, 5]]) == [990, 540, 0, 0, 0]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],queries = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1]]) == [28, 26, 24, 21, 18, 14]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],queries = [[9, 4], [5, 3], [1, 2], [7, 1]]) == [35, 17, 0, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],queries = [[0, 5], [1, 5], [2, 5], [3, 5], [4, 5]]) == [189, 144, 74, 0, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[9, 1], [8, 2], [7, 3], [6, 4], [5, 5]]) == [44, 30, 7, 0, 0]\n assert candidate(nums = [10, 1, 10, 1, 10, 1, 10, 1, 10, 1],queries = [[1, 3], [3, 2], [5, 1], [7, 4]]) == [51, 40, 30, 0]\n assert candidate(nums = [5, 1, 9, 2, 8, 3, 7, 4, 6, 0],queries = [[9, 2], [3, 3], [5, 2], [0, 1], [7, 4]]) == [42, 30, 17, 9, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],queries = [[0, 5], [5, 5], [10, 5], [15, 5]]) == [189, 144, 74, 0]\n assert candidate(nums = [5, 3, 1, 2, 4, 5, 3, 1, 2, 4, 5, 3, 1, 2, 4, 5, 3, 1, 2, 4],queries = [[2, 1], [0, 2], [3, 3], [1, 4], [4, 5]]) == [58, 51, 43, 27, 5]\n assert candidate(nums = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1],queries = [[0, 3], [1, 3], [2, 3], [3, 3], [4, 3]]) == [22, 15, 0, 0, 0]\n assert candidate(nums = [15, 12, 18, 14, 16, 17, 13, 19, 20, 11],queries = [[3, 2], [0, 1], [8, 4], [2, 3]]) == [118, 90, 0, 0]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[0, 5], [5, 3], [9, 2]]) == [340, 100, 0]\n assert candidate(nums = [100, 100, 100, 100, 100],queries = [[0, 2], [1, 1], [2, 2], [3, 1], [4, 1]]) == [200, 100, 0, 0, 0]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [5, 4], [6, 3], [7, 2], [8, 1], [9, 0]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [5, 3, 1, 2, 4, 6, 8, 7, 9],queries = [[2, 3], [0, 1], [3, 2], [5, 2]]) == [35, 24, 9, 0]\n assert candidate(nums = [100000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == [54, 49, 34, 0, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 10], [1, 5], [2, 2], [3, 3], [4, 1]]) == [0, 0, 0, 0, 0]\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996],queries = [[4, 2], [3, 1], [2, 2], [1, 1], [0, 1]]) == [199999, 100000, 0, 0, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[9, 1], [8, 1], [7, 1], [6, 1], [5, 1], [4, 1], [3, 1], [2, 1], [1, 1], [0, 1]]) == [44, 33, 22, 11, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [[9, 5], [3, 3], [1, 2]]) == [34, 0, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],queries = [[0, 10], [10, 5], [15, 3], [19, 2], [0, 5]]) == [144, 74, 20, 0, 0]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],queries = [[0, 5], [5, 5], [10, 5]]) == [990, 540, 0]\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [[0, 7], [2, 5], [4, 4], [6, 3], [8, 2]]) == [77, 14, 0, 0, 0]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[0, 5], [1, 3], [2, 1], [3, 1]]) == [4, 1, 0, 0]\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],queries = [[0, 1], [1, 2], [2, 3], [3, 4]]) == [52, 35, 17, 0]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[0, 3], [1, 2], [2, 1], [3, 3], [4, 1]]) == [450, 340, 270, 0, 0]\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1], [14, 1], [15, 1], [16, 1], [17, 1], [18, 1], [19, 1]]) == [189, 168, 147, 126, 105, 84, 63, 42, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 2, 2, 1, 2, 3, 1],queries = [[1, 2], [3, 3], [4, 2], [5, 1], [6, 0], [0, 1]]) == [8, 3, 0, 0, 0, 0]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],queries = [[0, 2], [3, 2], [5, 1], [7, 3], [9, 1]]) == [420, 280, 170, 0, 0]\n assert candidate(nums = [5, 3, 1, 2, 4, 1, 2, 3, 4, 5],queries = [[0, 2], [3, 3], [5, 1], [2, 2], [7, 4]]) == [23, 13, 9, 0, 0]\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [[0, 10], [1, 5], [2, 3], [3, 2], [4, 1]]) == [135, 51, 0, 0, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],queries = [[0, 2], [1, 3], [2, 4], [3, 5], [4, 6]]) == [114, 99, 65, 0, 0]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[0, 5], [5, 3], [2, 2]]) == [4, 1, 0]\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],queries = [[0, 5], [1, 2], [2, 3], [3, 1]]) == [12, 6, 0, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[9, 5], [8, 4], [7, 3], [6, 2], [5, 1]]) == [30, 0, 0, 0, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 1], [2, 1], [4, 1], [6, 1], [8, 1], [1, 1], [3, 1], [5, 1], [7, 1], [9, 1]]) == [52, 45, 34, 19, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 5], [1, 3], [2, 2], [3, 1], [4, 0]]) == [34, 10, 0, 0, 0]\n assert candidate(nums = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20],queries = [[0, 5], [2, 2], [4, 3], [6, 2], [8, 1]]) == [80, 40, 0, 0, 0]\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],queries = [[0, 10], [5, 5], [9, 1]]) == [0, 0, 0]\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 5], [1, 2], [2, 2], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1]]) == [34, 19, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [[0, 5], [2, 3], [8, 2], [5, 1], [7, 1]]) == [30, 0, 0, 0, 0]\n assert candidate(nums = [10, 20, 30, 40, 50],queries = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]) == [140, 120, 90, 50, 0]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[0, 5], [2, 2], [4, 3]]) == [4, 2, 0]\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996],queries = [[2, 2], [0, 1], [4, 2]]) == [199999, 0, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1]]) == [52, 49, 45, 40, 34, 27, 19, 10, 0, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],queries = [[0, 3], [1, 3], [2, 3], [3, 3], [4, 3]]) == [110, 92, 65, 29, 0]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],queries = [[0, 5], [5, 3], [9, 2], [4, 4]]) == [26, 8, 0, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 10], [1, 10], [2, 10], [3, 10], [4, 10]]) == [0, 0, 0, 0, 0]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],queries = [[0, 3], [1, 3], [2, 3], [3, 3], [4, 3], [5, 3]]) == [55, 40, 25, 10, 0, 0]\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995],queries = [[0, 1], [1, 2], [2, 3], [3, 1]]) == [399990, 99998, 0, 0]\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],queries = [[0, 2], [1, 2], [2, 2], [3, 2], [4, 2]]) == [25, 19, 12, 4, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 5], [2, 2], [4, 1], [6, 3], [8, 1]]) == [34, 19, 10, 0, 0]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == [440, 300, 70, 0, 0]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[0, 5], [2, 3], [4, 2], [8, 1]]) == [4, 1, 0, 0]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],queries = [[9, 5], [8, 3], [7, 2], [6, 1], [5, 4]]) == [340, 100, 0, 0, 0]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[0, 1], [1, 2], [2, 3], [3, 2], [4, 1]]) == [8, 6, 3, 1, 0]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1]]) == [8, 7, 6, 5, 4, 3, 2, 1, 0, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],queries = [[0, 5], [2, 4], [4, 3], [6, 2], [8, 1]]) == [99, 65, 29, 0, 0]\n assert candidate(nums = [5, 1, 3, 4, 2, 5, 4, 3, 2, 1],queries = [[4, 2], [0, 2], [9, 1], [2, 3]]) == [26, 16, 13, 0]\n assert candidate(nums = [5, 6, 7, 8, 9, 1, 2, 3, 4, 10],queries = [[0, 4], [5, 2], [9, 3], [2, 1]]) == [40, 27, 0, 0]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queries = [[0, 5], [1, 3], [4, 2], [7, 1], [9, 1]]) == [3400, 1000, 0, 0, 0]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [[9, 1], [8, 2], [7, 3], [6, 4]]) == [52, 45, 27, 0]\n assert candidate(nums = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],queries = [[0, 5], [1, 3], [2, 2], [3, 1], [4, 1]]) == [300000, 0, 0, 0, 0]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],queries = [[0, 2], [2, 2], [4, 2], [6, 2], [8, 2]]) == [35, 25, 15, 5, 0]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[0, 10], [5, 5], [9, 3], [4, 2], [2, 1]]) == [0, 0, 0, 0, 0]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],queries = [[1, 4], [3, 3], [5, 2], [7, 1], [9, 1]]) == [75, 36, 0, 0, 0]\n assert candidate(nums = [5, 1, 3, 2, 4, 6, 8, 7, 10, 9],queries = [[0, 5], [3, 3], [8, 2]]) == [34, 10, 0]\n assert candidate(nums = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1],queries = [[4, 3], [0, 2], [9, 4]]) == [24, 13, 0]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[0, 5], [1, 3], [5, 2], [8, 1]]) == [4, 1, 0, 0]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[0, 5], [2, 3], [8, 2], [1, 1]]) == [4, 1, 0, 0]\n assert candidate(nums = [1, 2, 2, 1, 2, 3, 1, 3, 2, 2],queries = [[1, 2], [3, 3], [4, 2], [0, 1], [5, 1]]) == [15, 10, 6, 3, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 5], [5, 3], [9, 2], [4, 1], [2, 1]]) == [34, 10, 0, 0, 0]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],queries = [[0, 2], [1, 3], [2, 4], [3, 1], [4, 1]]) == [35, 18, 0, 0, 0]\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [[0, 5], [5, 5], [10, 5], [15, 5]]) == [175, 120, 54, 0]\n assert candidate(nums = [50, 20, 30, 10, 40],queries = [[4, 2], [3, 1], [2, 1], [1, 1], [0, 1]]) == [80, 50, 0, 0, 0]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],queries = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1]]) == [36, 27, 18, 9, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],queries = [[9, 5], [4, 2], [0, 3], [8, 4]]) == [340, 190, 0, 0]\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991],queries = [[0, 3], [2, 2], [5, 1]]) == [599979, 299992, 199996]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[9, 3], [0, 2], [5, 4]]) == [39, 30, 0]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[0, 5], [1, 2], [5, 3]]) == [4, 2, 0]\n"}, "metadata": {"canonical_parameter_names": ["nums", "queries"], "leetcode_dataset_entry_point": "Solution().unmarkedSumArray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector unmarkedSumArray(vector& nums, vector>& queries) {", "container": "Solution", "callable": "unmarkedSumArray", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "queries", "type": "vector>&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3081, "task_id": "replace-question-marks-in-string-to-minimize-its-value", "difficulty": "Medium", "problem_description": "You are given a string s. s[i] is either a lowercase English letter or '?'.\nFor a string t having length m containing only lowercase English letters, we define the function cost(i) for an index i as the number of characters equal to t[i] that appeared before it, i.e. in the range [0, i - 1].\nThe value of t is the sum of cost(i) for all indices i.\nFor example, for the string t = \"aab\":\n\ncost(0) = 0\ncost(1) = 1\ncost(2) = 0\nHence, the value of \"aab\" is 0 + 1 + 0 = 1.\n\nYour task is to replace all occurrences of '?' in s with any lowercase English letter so that the value of s is minimized.\nReturn a string denoting the modified string with replaced occurrences of '?'. If there are multiple strings resulting in the minimum value, return the lexicographically smallest one.\n \nExample 1:\n\nInput: s = \"???\" \nOutput: \"abc\" \nExplanation: In this example, we can replace the occurrences of '?' to make s equal to \"abc\".\nFor \"abc\", cost(0) = 0, cost(1) = 0, and cost(2) = 0.\nThe value of \"abc\" is 0.\nSome other modifications of s that have a value of 0 are \"cba\", \"abz\", and, \"hey\".\nAmong all of them, we choose the lexicographically smallest.\n\nExample 2:\n\nInput: s = \"a?a?\"\nOutput: \"abac\"\nExplanation: In this example, the occurrences of '?' can be replaced to make s equal to \"abac\".\nFor \"abac\", cost(0) = 0, cost(1) = 0, cost(2) = 1, and cost(3) = 0.\nThe value of \"abac\" is 1.\n\n \nConstraints:\n\n1 <= s.length <= 105\ns[i] is either a lowercase English letter or '?'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aabbcc??\") == \"aabbccde\"\n assert candidate(s = \"abcabcabc???\") == \"abcabcabcdef\"\n assert candidate(s = \"a????b\") == \"acdefb\"\n assert candidate(s = \"a\") == \"a\"\n assert candidate(s = \"????????\") == \"abcdefgh\"\n assert candidate(s = \"abacabadabacaba\") == \"abacabadabacaba\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz?\") == \"abcdefghijklmnopqrstuvwxyza\"\n assert candidate(s = \"abc?de?\") == \"abcfdeg\"\n assert candidate(s = \"zzzz????\") == \"zzzzabcd\"\n assert candidate(s = \"a?????\") == \"abcdef\"\n assert candidate(s = \"??????????\") == \"abcdefghij\"\n assert candidate(s = \"aabbcc?\") == \"aabbccd\"\n assert candidate(s = \"???\") == \"abc\"\n assert candidate(s = \"????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????\") == \"aaaaaaaaabbbbbbbbbcccccccccdddddddddeeeeeeeeefffffffffggggggggghhhhhhhhhiiiiiiiiijjjjjjjjjkkkkkkkkklllllllllmmmmmmmmmnnnnnnnnnooooooooopppppppppqqqqqqqqqrrrrrrrrrssssssssstttttttttuuuuuuuuvvvvvvvvwwwwwwwwxxxxxxxxyyyyyyyyzzzzzzzz\"\n assert candidate(s = \"a????b????c????\") == \"adefgbhijkclmno\"\n assert candidate(s = \"a?a?\") == \"abac\"\n assert candidate(s = \"abc??\") == \"abcde\"\n assert candidate(s = \"z?y?x?w?v?u?t?s?r?q?p?o?n?m?l?k?j?i?h?g?f?e?d?c?b?a\") == \"zaybxcwdveuftgshriqjpkolnmmnlokpjqirhsgtfuevdwcxbya\"\n assert candidate(s = \"?????abc?????def?????ghi?????jkl?????mno?????pqr?????stu?????vwx?????yz?????\") == \"aabbcabccddeedefffgghghihiijjjklkkllmmnomnnoopqrppqqrsturssttvwxuuvvwyzwxxyz\"\n assert candidate(s = \"abc?def?ghi?\") == \"abcjdefkghil\"\n assert candidate(s = \"????????????????????????????????????????\") == \"aabbccddeeffgghhiijjkkllmmnnopqrstuvwxyz\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzz???\") == \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzzabc\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba????????\") == \"zyxwvutsrqponmlkjihgfedcbaabcdefgh\"\n assert candidate(s = \"a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t?u?v?w?x?y?z?\") == \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc???\") == \"abcabcabcabcabcabcabcabcabcabcdef\"\n assert candidate(s = \"xyz?xyz?xyz?\") == \"xyzaxyzbxyzc\"\n assert candidate(s = \"a?????b?????c?????d?????e?????f?????g?????h?????i?????j?????k?????l?????m?????n?????o?????p?????q?????r?????s?????t?????u?????v?????w?????x?????y?????z?????\") == \"aaaaaabbbbbbccccccddddddeeeeeeffffffgggggghhhhhhiiiiiijjjjjjkkkkkkllllllmmmmmmnnnnnnooooooppppppqqqqqqrrrrrrssssssttttttuuuuuuvvvvvvwwwwwwxxxxxxyyyyyyzzzzzz\"\n assert candidate(s = \"abc?????def?????ghi?????\") == \"abcjklmndefopqrsghituvwx\"\n assert candidate(s = \"a?b?c?d?e?fa?b?c?d?e?fa?b?c?d?e?fa?b?c?d?e?fa?b?c?d?e?fa?b?c?d?e?fa?b?c?d?e?fa?b?c?d?e?fa?b?c?d?e?f\") == \"agbgcgdhehfahbicidiejfajbjckdkekfalblcmdmenfanbocodpepfaqbqcrdresfasbtctdueufavbvcwdwexfaxbycydzezf\"\n assert candidate(s = \"aaaabbbbccccdddd????\") == \"aaaabbbbccccddddefgh\"\n assert candidate(s = \"aaaa?bbbb?cccc?dddd?eeee?ffff?gggg?hhhh?iiii?jjjj?kkkk?llll?mmmm?nnnn?oooo?pppp?qqqq?rrrr?ssss?tttt?uuuu?vvvv?wwww?xxxx?yyyy?zzzz?\") == \"aaaaabbbbbcccccdddddeeeeefffffggggghhhhhiiiiijjjjjkkkkklllllmmmmmnnnnnooooopppppqqqqqrrrrrssssstttttuuuuuvvvvvwwwwwxxxxxyyyyyzzzzz\"\n assert candidate(s = \"abacabadabacabadabacabadabacabad?\") == \"abacabadabacabadabacabadabacabade\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz???\") == \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzabc\"\n assert candidate(s = \"zzzzzzzzzz???\") == \"zzzzzzzzzzabc\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc???\") == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcdef\"\n assert candidate(s = \"zzzzzzzzzzzz????????????\") == \"zzzzzzzzzzzzabcdefghijkl\"\n assert candidate(s = \"???????????\") == \"abcdefghijk\"\n assert candidate(s = \"abcd?efg?hijk?lmn?opq?rstuvwxyz\") == \"abcdaefgbhijkclmndopqerstuvwxyz\"\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().minimizeStringValue", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string minimizeStringValue(string s) {", "container": "Solution", "callable": "minimizeStringValue", "parameters": [{"name": "s", "type": "string"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3082, "task_id": "find-the-sum-of-the-power-of-all-subsequences", "difficulty": "Hard", "problem_description": "You are given an integer array nums of length n and a positive integer k.\nThe power of an array of integers is defined as the number of subsequences with their sum equal to k.\nReturn the sum of power of all subsequences of nums.\nSince the answer may be very large, return it modulo 109 + 7.\n \nExample 1:\n\nInput: nums = [1,2,3], k = 3 \nOutput: 6 \nExplanation:\nThere are 5 subsequences of nums with non-zero power:\n\nThe subsequence [1,2,3] has 2 subsequences with sum == 3: [1,2,3] and [1,2,3].\nThe subsequence [1,2,3] has 1 subsequence with sum == 3: [1,2,3].\nThe subsequence [1,2,3] has 1 subsequence with sum == 3: [1,2,3].\nThe subsequence [1,2,3] has 1 subsequence with sum == 3: [1,2,3].\nThe subsequence [1,2,3] has 1 subsequence with sum == 3: [1,2,3].\n\nHence the answer is 2 + 1 + 1 + 1 + 1 = 6.\n\nExample 2:\n\nInput: nums = [2,3,3], k = 5 \nOutput: 4 \nExplanation:\nThere are 3 subsequences of nums with non-zero power:\n\nThe subsequence [2,3,3] has 2 subsequences with sum == 5: [2,3,3] and [2,3,3].\nThe subsequence [2,3,3] has 1 subsequence with sum == 5: [2,3,3].\nThe subsequence [2,3,3] has 1 subsequence with sum == 5: [2,3,3].\n\nHence the answer is 2 + 1 + 1 = 4.\n\nExample 3:\n\nInput: nums = [1,2,3], k = 7 \nOutput: 0 \nExplanation: There exists no subsequence with sum 7. Hence all subsequences of nums have power = 0.\n\n \nConstraints:\n\n1 <= n <= 100\n1 <= nums[i] <= 104\n1 <= k <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 1, 1, 1, 1],k = 3) == 40\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 15) == 8064\n assert candidate(nums = [1, 2, 4, 8, 16],k = 31) == 1\n assert candidate(nums = [10, 20, 30],k = 60) == 1\n assert candidate(nums = [10, 20, 30, 40, 50],k = 90) == 16\n assert candidate(nums = [100, 200, 300],k = 100) == 4\n assert candidate(nums = [10, 20, 30, 40],k = 50) == 8\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 800\n assert candidate(nums = [100, 200, 300],k = 600) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 8064\n assert candidate(nums = [1],k = 1) == 1\n assert candidate(nums = [1, 3, 5, 7, 9],k = 15) == 8\n assert candidate(nums = [2, 3, 3],k = 5) == 4\n assert candidate(nums = [1, 1, 1, 1],k = 2) == 24\n assert candidate(nums = [5, 5, 5, 5],k = 10) == 24\n assert candidate(nums = [10, 20, 30, 40, 50],k = 100) == 10\n assert candidate(nums = [5, 5, 5, 5, 5],k = 15) == 40\n assert candidate(nums = [2, 4, 6, 8, 10],k = 20) == 10\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4],k = 8) == 592\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4],k = 6) == 256\n assert candidate(nums = [1, 2, 3],k = 7) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 100) == 512\n assert candidate(nums = [3, 6, 9, 12, 15],k = 21) == 20\n assert candidate(nums = [100, 200, 300, 400],k = 1000) == 1\n assert candidate(nums = [1, 2, 3],k = 3) == 6\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105],k = 105) == 136192\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 25) == 508035072\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10],k = 25) == 991480774\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 20) == 52105216\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6],k = 15) == 137887744\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],k = 40) == 239616\n assert candidate(nums = [4, 6, 8, 10, 12, 14, 16, 18, 20, 22],k = 60) == 1584\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 508035072\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 300) == 1136\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 20) == 52105216\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 50) == 6717440\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32],k = 150) == 214918269\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 45) == 508035072\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 1500) == 2464\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 21) == 617366278\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 6],k = 9) == 168\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 1500) == 2464\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 508035072\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 250) == 252416\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10],k = 30) == 126471695\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81],k = 900) == 5217280\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 30) == 2464\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 15) == 219464424\n assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],k = 20) == 508035072\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],k = 80) == 29962240\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 50) == 545703072\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 49807360\n assert candidate(nums = [4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048],k = 1024) == 512\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 55) == 1984\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 15) == 2464\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 10) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 50) == 43079680\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 10) == 4608\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 10) == 12845056\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 40) == 185344\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],k = 50) == 313344\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 100) == 23942144\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 853234987\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 150) == 2464\n assert candidate(nums = [10, 20, 30, 40, 50],k = 60) == 20\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 12) == 17907712\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 150) == 2464\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55],k = 78) == 112\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 100) == 2272\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71],k = 100) == 7432192\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 25) == 508035072\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 100) == 23942144\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],k = 105) == 2464\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],k = 50) == 11681792\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 2500) == 1808\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 50) == 43079680\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 50) == 138240\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 180) == 2464\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10],k = 15) == 624381870\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42],k = 210) == 508035072\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 150) == 287787439\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023],k = 1023) == 512\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 20) == 317521920\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 500) == 26176512\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 30) == 1136\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 200) == 2272\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],k = 4500) == 310464\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 500) == 43079680\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 3000) == 1136\n assert candidate(nums = [5, 7, 1, 3, 9, 2, 8],k = 10) == 128\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125],k = 125) == 432537600\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 100) == 879122432\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 100) == 26176512\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 40) == 4882432\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 600) == 160800\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8],k = 30) == 394056145\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60],k = 180) == 51891200\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 100) == 399689153\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 15) == 707853125\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 25) == 1184\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],k = 50) == 768\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 100) == 26176512\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 15) == 407836790\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().sumOfPower", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int sumOfPower(vector& nums, int k) {", "container": "Solution", "callable": "sumOfPower", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3083, "task_id": "existence-of-a-substring-in-a-string-and-its-reverse", "difficulty": "Easy", "problem_description": "Given a string s, find any substring of length 2 which is also present in the reverse of s.\nReturn true if such a substring exists, and false otherwise.\n \nExample 1:\n\nInput: s = \"leetcode\"\nOutput: true\nExplanation: Substring \"ee\" is of length 2 which is also present in reverse(s) == \"edocteel\".\n\nExample 2:\n\nInput: s = \"abcba\"\nOutput: true\nExplanation: All of the substrings of length 2 \"ab\", \"bc\", \"cb\", \"ba\" are also present in reverse(s) == \"abcba\".\n\nExample 3:\n\nInput: s = \"abcd\"\nOutput: false\nExplanation: There is no substring of length 2 in s, which is also present in the reverse of s.\n\n \nConstraints:\n\n1 <= s.length <= 100\ns consists only of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcba\") == True\n assert candidate(s = \"deified\") == True\n assert candidate(s = \"abab\") == True\n assert candidate(s = \"ab\") == False\n assert candidate(s = \"mnopqr\") == False\n assert candidate(s = \"aa\") == True\n assert candidate(s = \"rotor\") == True\n assert candidate(s = \"zzz\") == True\n assert candidate(s = \"leetcode\") == True\n assert candidate(s = \"racecar\") == True\n assert candidate(s = \"aabb\") == True\n assert candidate(s = \"gfedcba\") == False\n assert candidate(s = \"world\") == False\n assert candidate(s = \"noon\") == True\n assert candidate(s = \"reviled\") == False\n assert candidate(s = \"abcd\") == False\n assert candidate(s = \"hello\") == True\n assert candidate(s = \"aabbcc\") == True\n assert candidate(s = \"level\") == True\n assert candidate(s = \"abcdefg\") == False\n assert candidate(s = \"xyzzxyzzxyzz\") == True\n assert candidate(s = \"detartrateddetartrated\") == True\n assert candidate(s = \"repaperrepaper\") == True\n assert candidate(s = \"xyzzyxxyzzyx\") == True\n assert candidate(s = \"referrefer\") == True\n assert candidate(s = \"rotorrotor\") == True\n assert candidate(s = \"abracadabra\") == True\n assert candidate(s = \"noonnoon\") == True\n assert candidate(s = \"reviverreviver\") == True\n assert candidate(s = \"deifieddeifieddeified\") == True\n assert candidate(s = \"abacaxabacax\") == True\n assert candidate(s = \"palindromemordnilap\") == True\n assert candidate(s = \"stepikiktepset\") == True\n assert candidate(s = \"qwertyuiopoiuytrewq\") == True\n assert candidate(s = \"algorithm\") == False\n assert candidate(s = \"abccbaabccba\") == True\n assert candidate(s = \"redder\") == True\n assert candidate(s = \"repelrepel\") == True\n assert candidate(s = \"noonnoonnoonnoon\") == True\n assert candidate(s = \"xyzzyx\") == True\n assert candidate(s = \"peep\") == True\n assert candidate(s = \"abacaba\") == True\n assert candidate(s = \"tamelephant\") == True\n assert candidate(s = \"rotavator\") == True\n assert candidate(s = \"revolver\") == True\n assert candidate(s = \"qwertyuioplkjhgfdsazxcvbnmnbvcxzgfdsahjklpoiuytrewq\") == True\n assert candidate(s = \"helloolleh\") == True\n assert candidate(s = \"palindrome\") == False\n assert candidate(s = \"dessertsstressed\") == True\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == False\n assert candidate(s = \"kayak\") == True\n assert candidate(s = \"abccbaabccbaabccba\") == True\n assert candidate(s = \"levelup\") == True\n assert candidate(s = \"deedeed\") == True\n assert candidate(s = \"sagassagasagasag\") == True\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(s = \"semordnilap\") == False\n assert candidate(s = \"reviler\") == True\n assert candidate(s = \"nursesrun\") == True\n assert candidate(s = \"abcdeffedcba\") == True\n assert candidate(s = \"wasitacaroracatisaw\") == True\n assert candidate(s = \"levellevel\") == True\n assert candidate(s = \"aibohphobia\") == True\n assert candidate(s = \"stepontostep\") == False\n assert candidate(s = \"programming\") == True\n assert candidate(s = \"aabbccdd\") == True\n assert candidate(s = \"madam\") == True\n assert candidate(s = \"desserts\") == True\n assert candidate(s = \"refer\") == True\n assert candidate(s = \"radar\") == True\n assert candidate(s = \"abcdefgihgfedcba\") == True\n assert candidate(s = \"xyzyx\") == True\n assert candidate(s = \"repelrepelrepel\") == True\n assert candidate(s = \"step on no pets\") == True\n assert candidate(s = \"redivider\") == True\n assert candidate(s = \"redderredder\") == True\n assert candidate(s = \"racecarabc\") == True\n assert candidate(s = \"abcdabcddcbaabcd\") == True\n assert candidate(s = \"abba\") == True\n assert candidate(s = \"abcdefgfedcba\") == True\n assert candidate(s = \"banana\") == True\n assert candidate(s = \"abcdefghijutsavajihgfedcba\") == True\n assert candidate(s = \"ananab\") == True\n assert candidate(s = \"aabbccddeeffgg\") == True\n assert candidate(s = \"detartrated\") == True\n assert candidate(s = \"civiccivic\") == True\n assert candidate(s = \"abccba\") == True\n assert candidate(s = \"aabbccddeeff\") == True\n assert candidate(s = \"xyzzyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(s = \"xyzyzyzyx\") == True\n assert candidate(s = \"reviver\") == True\n assert candidate(s = \"madamimadam\") == True\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == True\n assert candidate(s = \"aabbccddeeffgghhiijj\") == True\n assert candidate(s = \"zxcvbnmlkjhgfdsapoiuytrewq\") == False\n assert candidate(s = \"amanaplanacanalpanama\") == True\n assert candidate(s = \"sagasagasag\") == True\n assert candidate(s = \"racecarracecar\") == True\n assert candidate(s = \"noonnoonnoon\") == True\n assert candidate(s = \"repaper\") == True\n assert candidate(s = \"abcdedcba\") == True\n assert candidate(s = \"hellokayak\") == True\n assert candidate(s = \"stressed\") == True\n assert candidate(s = \"ababababab\") == True\n assert candidate(s = \"deifieddeified\") == True\n assert candidate(s = \"elephanttame\") == True\n assert candidate(s = \"civic\") == True\n assert candidate(s = \"abcdefghihgfedcba\") == True\n assert candidate(s = \"xyzyxzyxzyx\") == True\n assert candidate(s = \"xyxzyx\") == True\n assert candidate(s = \"abacaxa\") == True\n assert candidate(s = \"pneumonoultramicroscopicsilicovolcanoconiosis\") == True\n assert candidate(s = \"abacabadaba\") == True\n assert candidate(s = \"xyzyxzyx\") == True\n assert candidate(s = \"tacocat\") == True\n assert candidate(s = \"thisisatest\") == True\n assert candidate(s = \"mississippi\") == True\n assert candidate(s = \"xyzyxyzyx\") == True\n assert candidate(s = \"testset\") == True\n assert candidate(s = \"deed\") == True\n assert candidate(s = \"abacaxaba\") == True\n assert candidate(s = \"asdfghjklkljhgfdsa\") == True\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().isSubstringPresent", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool isSubstringPresent(string s) {", "container": "Solution", "callable": "isSubstringPresent", "parameters": [{"name": "s", "type": "string"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3084, "task_id": "count-substrings-starting-and-ending-with-given-character", "difficulty": "Medium", "problem_description": "You are given a string s and a character c. Return the total number of substrings of s that start and end with c.\n \nExample 1:\n\nInput: s = \"abada\", c = \"a\"\nOutput: 6\nExplanation: Substrings starting and ending with \"a\" are: \"abada\", \"abada\", \"abada\", \"abada\", \"abada\", \"abada\".\n\nExample 2:\n\nInput: s = \"zzz\", c = \"z\"\nOutput: 6\nExplanation: There are a total of 6 substrings in s and all start and end with \"z\".\n\n \nConstraints:\n\n1 <= s.length <= 105\ns and c consist only of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"zzz\",c = \"z\") == 6\n assert candidate(s = \"abcabcabc\",c = \"b\") == 6\n assert candidate(s = \"abcdefg\",c = \"f\") == 1\n assert candidate(s = \"\",c = \"a\") == 0\n assert candidate(s = \"abcabcabc\",c = \"a\") == 6\n assert candidate(s = \"hello\",c = \"l\") == 3\n assert candidate(s = \"xyz\",c = \"a\") == 0\n assert candidate(s = \"aaaaa\",c = \"a\") == 15\n assert candidate(s = \"abc\",c = \"a\") == 1\n assert candidate(s = \"abcabcabc\",c = \"c\") == 6\n assert candidate(s = \"aaa\",c = \"a\") == 6\n assert candidate(s = \"abada\",c = \"a\") == 6\n assert candidate(s = \"mississippi\",c = \"i\") == 10\n assert candidate(s = \"lalalalalalalala\",c = \"l\") == 36\n assert candidate(s = \"aabaaacaaadaaae\",c = \"e\") == 1\n assert candidate(s = \"bcbcbcbcb\",c = \"b\") == 15\n assert candidate(s = \"aabbccddeeff\",c = \"f\") == 3\n assert candidate(s = \"lkjkljkljkljklj\",c = \"k\") == 15\n assert candidate(s = \"repeatedcharactersrepeatedcharacters\",c = \"r\") == 21\n assert candidate(s = \"abcbcbcbc\",c = \"b\") == 10\n assert candidate(s = \"acbacbacbacbacbac\",c = \"a\") == 21\n assert candidate(s = \"racecar\",c = \"r\") == 3\n assert candidate(s = \"abababababa\",c = \"b\") == 15\n assert candidate(s = \"xyzzyxzyzxzyz\",c = \"z\") == 21\n assert candidate(s = \"pppppppppppp\",c = \"p\") == 78\n assert candidate(s = \"abcdefghijk\",c = \"j\") == 1\n assert candidate(s = \"pqrsrqpqrsrqpqrs\",c = \"r\") == 15\n assert candidate(s = \"bookkeeper\",c = \"e\") == 6\n assert candidate(s = \"aaaabbbcccddd\",c = \"b\") == 6\n assert candidate(s = \"noonnoonnoon\",c = \"n\") == 21\n assert candidate(s = \"xyxzyxzyxzyxzyx\",c = \"y\") == 15\n assert candidate(s = \"aaaaabaaaa\",c = \"a\") == 45\n assert candidate(s = \"aabbccddeeffgg\",c = \"g\") == 3\n assert candidate(s = \"banana\",c = \"a\") == 6\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",c = \"z\") == 990\n assert candidate(s = \"bbaabbaabbaa\",c = \"b\") == 21\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnm\",c = \"m\") == 3\n assert candidate(s = \"bananabananabanana\",c = \"a\") == 45\n assert candidate(s = \"aabbccddeeffgg\",c = \"b\") == 3\n assert candidate(s = \"abacabadabacaba\",c = \"a\") == 36\n assert candidate(s = \"aaaaabaaa\",c = \"a\") == 36\n assert candidate(s = \"qwertyuiop\",c = \"q\") == 1\n assert candidate(s = \"ababababab\",c = \"b\") == 15\n assert candidate(s = \"xyxzyxzyx\",c = \"x\") == 10\n assert candidate(s = \"abcdefghij\",c = \"a\") == 1\n assert candidate(s = \"zzzzzzzzzzzzzzzzz\",c = \"z\") == 153\n assert candidate(s = \"hellohellohello\",c = \"o\") == 6\n assert candidate(s = \"hello\",c = \"o\") == 1\n assert candidate(s = \"abcdefgabcdefgabcdefg\",c = \"d\") == 6\n assert candidate(s = \"qqwweerrttyyuuiioopp\",c = \"q\") == 3\n assert candidate(s = \"aabacabaa\",c = \"a\") == 21\n assert candidate(s = \"lkjlkjlkjlkj\",c = \"l\") == 10\n assert candidate(s = \"aaabaaaabaaaa\",c = \"a\") == 66\n assert candidate(s = \"aabbccddeeff\",c = \"d\") == 3\n assert candidate(s = \"aabbccddeeff\",c = \"c\") == 3\n assert candidate(s = \"abcdabcde\",c = \"d\") == 3\n assert candidate(s = \"aaaaabbbbbb\",c = \"b\") == 21\n assert candidate(s = \"ananananananananana\",c = \"n\") == 45\n assert candidate(s = \"abcababcabcab\",c = \"b\") == 15\n assert candidate(s = \"abacaba\",c = \"a\") == 10\n assert candidate(s = \"xyxzxyxzyzx\",c = \"x\") == 15\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaa\",c = \"a\") == 351\n assert candidate(s = \"hellohellobyehello\",c = \"o\") == 6\n assert candidate(s = \"zzzzzzzzzzzzz\",c = \"z\") == 91\n assert candidate(s = \"aninterestingproblem\",c = \"n\") == 6\n assert candidate(s = \"abcdefghijabcdefghijabcdefghij\",c = \"i\") == 6\n assert candidate(s = \"llllllllllllllllllllllllll\",c = \"l\") == 351\n assert candidate(s = \"bcbcbcbcbcb\",c = \"b\") == 21\n assert candidate(s = \"bababababababa\",c = \"b\") == 28\n assert candidate(s = \"abcdefghefghijklmnopqrstuvwxyz\",c = \"a\") == 1\n assert candidate(s = \"abcdefghi\",c = \"a\") == 1\n assert candidate(s = \"aaaaabaaaaa\",c = \"a\") == 55\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmqwertyuiop\",c = \"q\") == 3\n assert candidate(s = \"abcdefghij\",c = \"j\") == 1\n assert candidate(s = \"thisisaverylongstringwithseveralcharacters\",c = \"t\") == 10\n assert candidate(s = \"abcdefghigklmnopqrstuvwxyz\",c = \"a\") == 1\n assert candidate(s = \"xyzzzyzxzyzxzyz\",c = \"z\") == 36\n assert candidate(s = \"zzzzzzzzzz\",c = \"z\") == 55\n assert candidate(s = \"xyzyxzyzxzyzx\",c = \"x\") == 10\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",c = \"z\") == 3\n assert candidate(s = \"xyzxyzxyzxyz\",c = \"x\") == 10\n assert candidate(s = \"abacabadaba\",c = \"a\") == 21\n assert candidate(s = \"programming\",c = \"m\") == 3\n assert candidate(s = \"aaabaaa\",c = \"a\") == 21\n assert candidate(s = \"anananananan\",c = \"a\") == 21\n assert candidate(s = \"cccccccccc\",c = \"c\") == 55\n assert candidate(s = \"cccccccccccccccccc\",c = \"c\") == 171\n assert candidate(s = \"xyzxyzxyz\",c = \"z\") == 6\n assert candidate(s = \"zazazazazaz\",c = \"z\") == 21\n assert candidate(s = \"abcdefghigklmnopqrstuvwxyz\",c = \"z\") == 1\n assert candidate(s = \"aabaaacaaadaaae\",c = \"a\") == 66\n assert candidate(s = \"bcbcbcbc\",c = \"b\") == 10\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",c = \"a\") == 0\n assert candidate(s = \"aabbccddeeffaabbccddeeff\",c = \"d\") == 10\n assert candidate(s = \"abcdefabcdefabcdef\",c = \"f\") == 6\n assert candidate(s = \"abracadabra\",c = \"a\") == 15\n assert candidate(s = \"aaaaaaaaaaaaaa\",c = \"a\") == 105\n assert candidate(s = \"popcornpopcorn\",c = \"p\") == 10\n assert candidate(s = \"xyxxyxyxy\",c = \"x\") == 15\n assert candidate(s = \"bbbbbbbbbb\",c = \"b\") == 55\n assert candidate(s = \"abcdefg\",c = \"g\") == 1\n assert candidate(s = \"hellohellohellohello\",c = \"l\") == 36\n assert candidate(s = \"abcdeabcdeabcde\",c = \"a\") == 6\n assert candidate(s = \"abcdefhijklmnopqrstuvwxyz\",c = \"z\") == 1\n assert candidate(s = \"aabbccddeeff\",c = \"b\") == 3\n"}, "metadata": {"canonical_parameter_names": ["s", "c"], "leetcode_dataset_entry_point": "Solution().countSubstrings", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "long long countSubstrings(string s, char c) {", "container": "Solution", "callable": "countSubstrings", "parameters": [{"name": "s", "type": "string"}, {"name": "c", "type": "char"}], "return_type": "long long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3085, "task_id": "minimum-deletions-to-make-string-k-special", "difficulty": "Medium", "problem_description": "You are given a string word and an integer k.\nWe consider word to be k-special if |freq(word[i]) - freq(word[j])| <= k for all indices i and j in the string.\nHere, freq(x) denotes the frequency of the character x in word, and |y| denotes the absolute value of y.\nReturn the minimum number of characters you need to delete to make word k-special.\n \nExample 1:\n\nInput: word = \"aabcaba\", k = 0\nOutput: 3\nExplanation: We can make word 0-special by deleting 2 occurrences of \"a\" and 1 occurrence of \"c\". Therefore, word becomes equal to \"baba\" where freq('a') == freq('b') == 2.\n\nExample 2:\n\nInput: word = \"dabdcbdcdcd\", k = 2\nOutput: 2\nExplanation: We can make word 2-special by deleting 1 occurrence of \"a\" and 1 occurrence of \"d\". Therefore, word becomes equal to \"bdcbdcdcd\" where freq('b') == 2, freq('c') == 3, and freq('d') == 4.\n\nExample 3:\n\nInput: word = \"aaabaaa\", k = 2\nOutput: 1\nExplanation: We can make word 2-special by deleting 1 occurrence of \"b\". Therefore, word becomes equal to \"aaaaaa\" where each letter's frequency is now uniformly 6.\n\n \nConstraints:\n\n1 <= word.length <= 105\n0 <= k <= 105\nword consists only of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word = \"abacabadaba\",k = 2) == 3\n assert candidate(word = \"abacabadabacaba\",k = 3) == 4\n assert candidate(word = \"xyz\",k = 0) == 0\n assert candidate(word = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 10) == 0\n assert candidate(word = \"abcabcabc\",k = 1) == 0\n assert candidate(word = \"mnbvcxzlkjhgfdsapoiuytrewq\",k = 5) == 0\n assert candidate(word = \"aabcaba\",k = 0) == 3\n assert candidate(word = \"dabdcbdcdcd\",k = 2) == 2\n assert candidate(word = \"zzzzz\",k = 0) == 0\n assert candidate(word = \"aaabaaa\",k = 2) == 1\n assert candidate(word = \"abcdabcdabcd\",k = 1) == 0\n assert candidate(word = \"aaaaa\",k = 0) == 0\n assert candidate(word = \"xyz\",k = 1) == 0\n assert candidate(word = \"abcde\",k = 3) == 0\n assert candidate(word = \"abacabadabacaba\",k = 1) == 6\n assert candidate(word = \"qqwweerrttyyuuiioopp\",k = 2) == 0\n assert candidate(word = \"aabcccdddd\",k = 1) == 2\n assert candidate(word = \"xyxxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy\",k = 2) == 0\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 0) == 0\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 10) == 0\n assert candidate(word = \"lkjghwertyuiopasdfghjklzxcvbnmlkjhgfdwsazxcvbnmlkjhgfdwsazxcvbnmlkjhgfdwsa\",k = 15) == 0\n assert candidate(word = \"zzzzzyyyyyxxxxxwwwwvvvvuttttssssrrrrqqqqppppooooonnnnmmmmmllllkkkkjjjjiiiihhhhggggffffffeeeeee\",k = 5) == 0\n assert candidate(word = \"xyzzzzzzzzzyxyzzzzzzzzzyxyzzzzzzzzzy\",k = 5) == 9\n assert candidate(word = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 3) == 0\n assert candidate(word = \"mnbvcxzlkjhgfdsapoiuytrewqmnbvcxzlkjhgfdsapoiuytrewqmnbvcxzlkjhgfdsapoiuytrewq\",k = 8) == 0\n assert candidate(word = \"aaabbbcccddddeeeffffffgggggggg\",k = 4) == 1\n assert candidate(word = \"thisisanexamplestringwithvariousfrequencies\",k = 3) == 4\n assert candidate(word = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 5) == 0\n assert candidate(word = \"almosteveryletterisusedbutnotallabcdefghijklmnopqrstuvwxyzzzzzzzzzzz\",k = 2) == 17\n assert candidate(word = \"thisisaverylongwordthatcontainsmanycharactersandneedscomplexprocessing\",k = 10) == 0\n assert candidate(word = \"aaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbcccccccccccccccc\",k = 2) == 0\n assert candidate(word = \"aaaaaaaaaaabbbbbbbbbbbccccccccccdddddddddd\",k = 5) == 0\n assert candidate(word = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 25) == 0\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzz\",k = 0) == 0\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyz\",k = 0) == 0\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyzzzzzzzzzz\",k = 5) == 4\n assert candidate(word = \"aaaaaaaaaabbbbbbbbccccccccddddddddeeeeeeeffffffffggggggghhhhhhhhiiiiiiiiii\",k = 3) == 0\n assert candidate(word = \"unevenfrequenciesaxbxcxdxeuxyvxuyvyvxvyvxvyvxvyvxvyvxvyvxyvxyvxyvxyvxyvxyvxyvxyvxyvxyvxyvxy\",k = 10) == 23\n assert candidate(word = \"aaaaaabbbccccdddddeeeeeffffffffggggghhhhhiiiiijjjjjkkkkklllllmmmmmnnnnnooooo\",k = 5) == 0\n assert candidate(word = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzz\",k = 1) == 17\n assert candidate(word = \"abcdefghij\",k = 0) == 0\n assert candidate(word = \"ppppppppppqqqqqqqqqqrrrrrrrrrrssssssssssttttttttttuuuuuuuuuuvvvvvvvvvvwwwwwwwwwwxxxxxxxxxxxyyyyyyyyyyzzzzzzzzzz\",k = 10) == 0\n assert candidate(word = \"qwertyuiopasdfghjklzxcvbnm\",k = 10) == 0\n assert candidate(word = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\",k = 10) == 0\n assert candidate(word = \"verylongstringwithrepeatingcharactersaaaaaaaaaabbbbbbbbbbcccccccccc\",k = 4) == 20\n assert candidate(word = \"ppppppppppppppppppppppppppppppppppppppppppppppppppppp\",k = 0) == 0\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 1) == 0\n assert candidate(word = \"abcdeabcdabcdeabcdeabcdeabcdeabcde\",k = 2) == 0\n assert candidate(word = \"ppppqqqqrrrsssttttuuuuvvvvwwwwxxxxxyyyyyzzzzzaaaaabbbbccccddddeeeeffffgggghhhhiiii\",k = 5) == 0\n assert candidate(word = \"aabbaaccddccbbbaaadddcccbbaaa\",k = 1) == 6\n assert candidate(word = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 0) == 0\n assert candidate(word = \"abcabcabcabcabcabcabcabcabcabc\",k = 1) == 0\n assert candidate(word = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzqqqqqqqqqq\",k = 4) == 6\n"}, "metadata": {"canonical_parameter_names": ["word", "k"], "leetcode_dataset_entry_point": "Solution().minimumDeletions", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumDeletions(string word, int k) {", "container": "Solution", "callable": "minimumDeletions", "parameters": [{"name": "word", "type": "string"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3086, "task_id": "minimum-moves-to-pick-k-ones", "difficulty": "Hard", "problem_description": "You are given a binary array nums of length n, a positive integer k and a non-negative integer maxChanges.\nAlice plays a game, where the goal is for Alice to pick up k ones from nums using the minimum number of moves. When the game starts, Alice picks up any index aliceIndex in the range [0, n - 1] and stands there. If nums[aliceIndex] == 1 , Alice picks up the one and nums[aliceIndex] becomes 0(this does not count as a move). After this, Alice can make any number of moves (including zero) where in each move Alice must perform exactly one of the following actions:\n\nSelect any index j != aliceIndex such that nums[j] == 0 and set nums[j] = 1. This action can be performed at most maxChanges times.\nSelect any two adjacent indices x and y (|x - y| == 1) such that nums[x] == 1, nums[y] == 0, then swap their values (set nums[y] = 1 and nums[x] = 0). If y == aliceIndex, Alice picks up the one after this move and nums[y] becomes 0.\n\nReturn the minimum number of moves required by Alice to pick exactly k ones.\n \nExample 1:\n\nInput: nums = [1,1,0,0,0,1,1,0,0,1], k = 3, maxChanges = 1\nOutput: 3\nExplanation: Alice can pick up 3 ones in 3 moves, if Alice performs the following actions in each move when standing at aliceIndex == 1:\n\nAt the start of the game Alice picks up the one and nums[1] becomes 0. nums becomes [1,0,0,0,0,1,1,0,0,1].\nSelect j == 2 and perform an action of the first type. nums becomes [1,0,1,0,0,1,1,0,0,1]\nSelect x == 2 and y == 1, and perform an action of the second type. nums becomes [1,1,0,0,0,1,1,0,0,1]. As y == aliceIndex, Alice picks up the one and nums becomes [1,0,0,0,0,1,1,0,0,1].\nSelect x == 0 and y == 1, and perform an action of the second type. nums becomes [0,1,0,0,0,1,1,0,0,1]. As y == aliceIndex, Alice picks up the one and nums becomes [0,0,0,0,0,1,1,0,0,1].\n\nNote that it may be possible for Alice to pick up 3 ones using some other sequence of 3 moves.\n\nExample 2:\n\nInput: nums = [0,0,0,0], k = 2, maxChanges = 3\nOutput: 4\nExplanation: Alice can pick up 2 ones in 4 moves, if Alice performs the following actions in each move when standing at aliceIndex == 0:\n\nSelect j == 1 and perform an action of the first type. nums becomes [0,1,0,0].\nSelect x == 1 and y == 0, and perform an action of the second type. nums becomes [1,0,0,0]. As y == aliceIndex, Alice picks up the one and nums becomes [0,0,0,0].\nSelect j == 1 again and perform an action of the first type. nums becomes [0,1,0,0].\nSelect x == 1 and y == 0 again, and perform an action of the second type. nums becomes [1,0,0,0]. As y == aliceIndex, Alice picks up the one and nums becomes [0,0,0,0].\n\n\n \nConstraints:\n\n2 <= n <= 105\n0 <= nums[i] <= 1\n1 <= k <= 105\n0 <= maxChanges <= 105\nmaxChanges + sum(nums) >= k\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 5,maxChanges = 5) == 8\n assert candidate(nums = [1, 1, 0, 0, 0, 0, 0, 0, 0, 1],k = 3,maxChanges = 2) == 3\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 2,maxChanges = 1) == 2\n assert candidate(nums = [0, 0, 1, 0, 0, 0, 0, 0, 1, 0],k = 2,maxChanges = 1) == 2\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 1,maxChanges = 0) == 0\n assert candidate(nums = [0, 0, 0, 0],k = 2,maxChanges = 3) == 4\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 4,maxChanges = 0) == 8\n assert candidate(nums = [1, 1, 0, 0, 0, 1, 1, 0, 0, 1],k = 3,maxChanges = 1) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5,maxChanges = 3) == 6\n assert candidate(nums = [1, 1, 1, 1, 1, 0, 0, 0, 0, 0],k = 5,maxChanges = 5) == 6\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 5,maxChanges = 0) == 12\n assert candidate(nums = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1],k = 5,maxChanges = 5) == 6\n assert candidate(nums = [0, 0, 1, 0, 0, 0, 0, 1, 0, 0],k = 2,maxChanges = 1) == 2\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 5,maxChanges = 2) == 8\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5,maxChanges = 0) == 6\n assert candidate(nums = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0],k = 12,maxChanges = 7) == 26\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 2,maxChanges = 1) == 2\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0],k = 15,maxChanges = 20) == 28\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 10,maxChanges = 5) == 22\n assert candidate(nums = [1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1],k = 7,maxChanges = 3) == 13\n assert candidate(nums = [1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1],k = 6,maxChanges = 3) == 8\n assert candidate(nums = [0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0],k = 4,maxChanges = 2) == 9\n assert candidate(nums = [1, 1, 1, 1, 0, 0, 0, 0, 0, 0],k = 4,maxChanges = 2) == 4\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 10,maxChanges = 5) == 22\n assert candidate(nums = [1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1],k = 5,maxChanges = 3) == 6\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 7,maxChanges = 10) == 10\n assert candidate(nums = [1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1],k = 4,maxChanges = 0) == 12\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0],k = 5,maxChanges = 5) == 8\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 20,maxChanges = 15) == 42\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1],k = 15,maxChanges = 5) == 85\n assert candidate(nums = [1, 1, 0, 0, 1, 0, 1, 0, 1, 0],k = 4,maxChanges = 0) == 9\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1],k = 4,maxChanges = 10) == 4\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 10,maxChanges = 5) == 22\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1],k = 2,maxChanges = 0) == 1\n assert candidate(nums = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0],k = 6,maxChanges = 2) == 12\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 15,maxChanges = 5) == 35\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 7,maxChanges = 2) == 16\n assert candidate(nums = [1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 4,maxChanges = 5) == 4\n assert candidate(nums = [1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0],k = 10,maxChanges = 5) == 22\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0],k = 3,maxChanges = 2) == 4\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 4,maxChanges = 2) == 6\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 5,maxChanges = 3) == 8\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1],k = 5,maxChanges = 5) == 8\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0],k = 6,maxChanges = 3) == 8\n assert candidate(nums = [0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 5,maxChanges = 25) == 8\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1],k = 2,maxChanges = 5) == 1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 2,maxChanges = 2) == 2\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 3,maxChanges = 0) == 19\n assert candidate(nums = [0, 1, 1, 0, 0, 1, 0, 0, 1, 0],k = 3,maxChanges = 2) == 3\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 1, 0, 0, 1],k = 3,maxChanges = 1) == 5\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 4,maxChanges = 1) == 6\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 1,maxChanges = 0) == 0\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1],k = 2,maxChanges = 0) == 1\n assert candidate(nums = [1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 3,maxChanges = 0) == 2\n assert candidate(nums = [0, 0, 0, 1, 0, 0, 0, 0, 1, 0],k = 2,maxChanges = 2) == 2\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 1, 1, 1],k = 3,maxChanges = 0) == 2\n assert candidate(nums = [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0],k = 3,maxChanges = 3) == 4\n assert candidate(nums = [1, 1, 1, 0, 0, 0, 0, 0, 1, 1],k = 4,maxChanges = 2) == 4\n assert candidate(nums = [0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0],k = 4,maxChanges = 2) == 7\n assert candidate(nums = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0],k = 5,maxChanges = 1) == 6\n assert candidate(nums = [0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0],k = 4,maxChanges = 3) == 6\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 2,maxChanges = 0) == 60\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1],k = 4,maxChanges = 0) == 12\n assert candidate(nums = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 3,maxChanges = 0) == 2\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 4,maxChanges = 2) == 6\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 3,maxChanges = 1) == 4\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 1, 1],k = 2,maxChanges = 1) == 1\n assert candidate(nums = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0],k = 4,maxChanges = 1) == 6\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 1,maxChanges = 1) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 25,maxChanges = 10) == 76\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 6,maxChanges = 4) == 10\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0],k = 4,maxChanges = 2) == 8\n assert candidate(nums = [1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1],k = 4,maxChanges = 2) == 5\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 1,maxChanges = 10) == 0\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 3,maxChanges = 1) == 4\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 6,maxChanges = 4) == 10\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1],k = 6,maxChanges = 0) == 27\n assert candidate(nums = [0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1],k = 5,maxChanges = 3) == 7\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 10,maxChanges = 0) == 50\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5,maxChanges = 10) == 6\n assert candidate(nums = [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 2,maxChanges = 1) == 1\n assert candidate(nums = [0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0],k = 3,maxChanges = 1) == 7\n assert candidate(nums = [1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1],k = 8,maxChanges = 4) == 12\n assert candidate(nums = [1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 4,maxChanges = 0) == 4\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 1,maxChanges = 5) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 5,maxChanges = 10) == 6\n assert candidate(nums = [0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0],k = 5,maxChanges = 10) == 8\n assert candidate(nums = [1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0],k = 25,maxChanges = 30) == 47\n assert candidate(nums = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],k = 3,maxChanges = 2) == 4\n assert candidate(nums = [1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1],k = 5,maxChanges = 1) == 15\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 10,maxChanges = 3) == 30\n assert candidate(nums = [1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1],k = 7,maxChanges = 5) == 11\n assert candidate(nums = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1],k = 5,maxChanges = 0) == 12\n assert candidate(nums = [1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0],k = 8,maxChanges = 3) == 22\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 3,maxChanges = 2) == 4\n"}, "metadata": {"canonical_parameter_names": ["nums", "k", "maxChanges"], "leetcode_dataset_entry_point": "Solution().minimumMoves", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "long long minimumMoves(vector& nums, int k, int maxChanges) {", "container": "Solution", "callable": "minimumMoves", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "k", "type": "int"}, {"name": "maxChanges", "type": "int"}], "return_type": "long long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3090, "task_id": "maximum-length-substring-with-two-occurrences", "difficulty": "Easy", "problem_description": "Given a string s, return the maximum length of a substring such that it contains at most two occurrences of each character.\n \nExample 1:\n\nInput: s = \"bcbbbcba\"\nOutput: 4\nExplanation:\nThe following substring has a length of 4 and contains at most two occurrences of each character: \"bcbbbcba\".\nExample 2:\n\nInput: s = \"aaaa\"\nOutput: 2\nExplanation:\nThe following substring has a length of 2 and contains at most two occurrences of each character: \"aaaa\".\n \nConstraints:\n\n2 <= s.length <= 100\ns consists only of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"zzzzzzzzz\") == 2\n assert candidate(s = \"aaabbbccc\") == 4\n assert candidate(s = \"aabbaa\") == 4\n assert candidate(s = \"abababab\") == 4\n assert candidate(s = \"aabacbebebe\") == 6\n assert candidate(s = \"abacabadabacaba\") == 5\n assert candidate(s = \"abab\") == 4\n assert candidate(s = \"abcabcabc\") == 6\n assert candidate(s = \"aabbc\") == 5\n assert candidate(s = \"aabacbacbac\") == 6\n assert candidate(s = \"ababababab\") == 4\n assert candidate(s = \"abcabc\") == 6\n assert candidate(s = \"aabb\") == 4\n assert candidate(s = \"zzzzyyxx\") == 6\n assert candidate(s = \"xyzxyzxyz\") == 6\n assert candidate(s = \"bcbbbcba\") == 4\n assert candidate(s = \"zzzzzzzzzz\") == 2\n assert candidate(s = \"zzzzzzzzzzzz\") == 2\n assert candidate(s = \"abacabad\") == 5\n assert candidate(s = \"abababababab\") == 4\n assert candidate(s = \"aabbccddeeffgg\") == 14\n assert candidate(s = \"aaabbb\") == 4\n assert candidate(s = \"aaaa\") == 2\n assert candidate(s = \"aabbccddeeffgghh\") == 16\n assert candidate(s = \"aabbccddeeff\") == 12\n assert candidate(s = \"abcdeabcde\") == 10\n assert candidate(s = \"aabbcc\") == 6\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 52\n assert candidate(s = \"aabbccddeeffgghhiijj\") == 20\n assert candidate(s = \"abacaba\") == 5\n assert candidate(s = \"abcdefg\") == 7\n assert candidate(s = \"aaabbbaaabbbaaabbbaaabbbaaabbbaaabbbaaabbbaaabbbaaabbbaaabbbaaabbbaaabbbaaabbb\") == 4\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzz\") == 52\n assert candidate(s = \"aabbaaabbbaaaabbbaaaa\") == 4\n assert candidate(s = \"abacabadabacabadabacaba\") == 5\n assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcdefghij\") == 20\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 6\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 6\n assert candidate(s = \"aaaabbbbccccaaaabbbbccccaaaabbbbccccaaaabbbbccccaaaabbbbcccc\") == 4\n assert candidate(s = \"mnopqrsmnopqrsmnopqrsmnopqrsmnopqrsmnopqrsmnopqrsmnopqrsmnopqrs\") == 14\n assert candidate(s = \"abcdabcdeabcdabcdeabcdabcdeabcdabcdeabcdabcdeabcdabcdeabcdabcdeabcdabcdabcdabcd\") == 10\n assert candidate(s = \"aaabbbcccdddeeefffggghhhiiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz\") == 4\n assert candidate(s = \"aabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabb\") == 4\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\") == 6\n assert candidate(s = \"aabbaabbaabbaabbaabbaabbaabbaabb\") == 4\n assert candidate(s = \"abcdefghijklaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 52\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 52\n assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\") == 20\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzyxwvutsrqponmlkjihgfedcba\") == 52\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 6\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\") == 2\n assert candidate(s = \"aabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabb\") == 4\n assert candidate(s = \"xyzzzyxyzzzyxyzzzyxyzzzyxyzzzyxyzzzyxyzzzyxyzzzyxyzzzyxyzzzyxyzzzyxyzzz\") == 5\n assert candidate(s = \"abacabadabacabadabacabadabacabadabacabad\") == 5\n assert candidate(s = \"aaabbbcccdddeeefffggghhhiiijjjkkklllmmmnnnoooppqqrrrsssttuuvvwwxxyyzz\") == 16\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzzzzzzzzzzzzzzzzzzz\") == 27\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 52\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzz\") == 52\n assert candidate(s = \"zzzzzyzyzyzyzyzyzy\") == 4\n assert candidate(s = \"abcabcbacbacbabcabcabcabcabcabcabc\") == 6\n assert candidate(s = \"abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef\") == 12\n assert candidate(s = \"abcabcabcabcabcabc\") == 6\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 2\n assert candidate(s = \"aabbaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzz\") == 52\n assert candidate(s = \"aabccddeeffaabbccddeeffaabbccddeeff\") == 12\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzyyxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaa\") == 52\n assert candidate(s = \"abcdefghijklmnopqrstuvabcdefghijklmnopqrstuv\") == 44\n assert candidate(s = \"aabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabba\") == 4\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzz\") == 52\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzz\") == 52\n assert candidate(s = \"aabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabb\") == 4\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 8\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 6\n assert candidate(s = \"abcabcabcabcabc\") == 6\n assert candidate(s = \"abcdaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzz\") == 52\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 8\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 6\n assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\") == 20\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().maximumLengthSubstring", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maximumLengthSubstring(string s) {", "container": "Solution", "callable": "maximumLengthSubstring", "parameters": [{"name": "s", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3091, "task_id": "apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k", "difficulty": "Medium", "problem_description": "You are given a positive integer k. Initially, you have an array nums = [1].\nYou can perform any of the following operations on the array any number of times (possibly zero):\n\nChoose any element in the array and increase its value by 1.\nDuplicate any element in the array and add it to the end of the array.\n\nReturn the minimum number of operations required to make the sum of elements of the final array greater than or equal to k.\n \nExample 1:\n\nInput: k = 11\nOutput: 5\nExplanation:\nWe can do the following operations on the array nums = [1]:\n\nIncrease the element by 1 three times. The resulting array is nums = [4].\nDuplicate the element two times. The resulting array is nums = [4,4,4].\n\nThe sum of the final array is 4 + 4 + 4 = 12 which is greater than or equal to k = 11.\nThe total number of operations performed is 3 + 2 = 5.\n\nExample 2:\n\nInput: k = 1\nOutput: 0\nExplanation:\nThe sum of the original array is already greater than or equal to 1, so no operations are needed.\n\n \nConstraints:\n\n1 <= k <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(k = 100) == 18\n assert candidate(k = 20) == 7\n assert candidate(k = 1) == 0\n assert candidate(k = 15) == 6\n assert candidate(k = 11) == 5\n assert candidate(k = 3) == 2\n assert candidate(k = 100000) == 631\n assert candidate(k = 5) == 3\n assert candidate(k = 10) == 5\n assert candidate(k = 29) == 9\n assert candidate(k = 30) == 9\n assert candidate(k = 101) == 19\n assert candidate(k = 2048) == 89\n assert candidate(k = 1024) == 62\n assert candidate(k = 9999) == 198\n assert candidate(k = 999) == 62\n assert candidate(k = 500) == 43\n assert candidate(k = 49) == 12\n assert candidate(k = 8192) == 180\n assert candidate(k = 50) == 13\n assert candidate(k = 127) == 21\n assert candidate(k = 64) == 14\n assert candidate(k = 17) == 7\n assert candidate(k = 6) == 3\n assert candidate(k = 63) == 14\n assert candidate(k = 7) == 4\n assert candidate(k = 99) == 18\n assert candidate(k = 31) == 10\n assert candidate(k = 13) == 6\n assert candidate(k = 65536) == 510\n assert candidate(k = 16384) == 254\n assert candidate(k = 2) == 1\n assert candidate(k = 12345) == 221\n assert candidate(k = 42) == 11\n assert candidate(k = 67890) == 520\n assert candidate(k = 200) == 27\n assert candidate(k = 99999) == 631\n assert candidate(k = 250) == 30\n assert candidate(k = 87500) == 590\n assert candidate(k = 37) == 11\n assert candidate(k = 255) == 30\n assert candidate(k = 256) == 30\n assert candidate(k = 512) == 44\n assert candidate(k = 85) == 17\n assert candidate(k = 32768) == 361\n assert candidate(k = 62500) == 498\n assert candidate(k = 1023) == 62\n assert candidate(k = 75000) == 546\n assert candidate(k = 23) == 8\n assert candidate(k = 4096) == 126\n assert candidate(k = 10000) == 198\n assert candidate(k = 511) == 44\n assert candidate(k = 28) == 9\n assert candidate(k = 1000) == 62\n assert candidate(k = 19) == 7\n assert candidate(k = 32) == 10\n assert candidate(k = 128) == 21\n assert candidate(k = 50000) == 446\n"}, "metadata": {"canonical_parameter_names": ["k"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minOperations(int k) {", "container": "Solution", "callable": "minOperations", "parameters": [{"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3092, "task_id": "most-frequent-ids", "difficulty": "Medium", "problem_description": "The problem involves tracking the frequency of IDs in a collection that changes over time. You have two integer arrays, nums and freq, of equal length n. Each element in nums represents an ID, and the corresponding element in freq indicates how many times that ID should be added to or removed from the collection at each step.\n\nAddition of IDs: If freq[i] is positive, it means freq[i] IDs with the value nums[i] are added to the collection at step i.\nRemoval of IDs: If freq[i] is negative, it means -freq[i] IDs with the value nums[i] are removed from the collection at step i.\n\nReturn an array ans of length n, where ans[i] represents the count of the most frequent ID in the collection after the ith step. If the collection is empty at any step, ans[i] should be 0 for that step.\n \nExample 1:\n\nInput: nums = [2,3,2,1], freq = [3,2,-3,1]\nOutput: [3,3,2,2]\nExplanation:\nAfter step 0, we have 3 IDs with the value of 2. So ans[0] = 3.\nAfter step 1, we have 3 IDs with the value of 2 and 2 IDs with the value of 3. So ans[1] = 3.\nAfter step 2, we have 2 IDs with the value of 3. So ans[2] = 2.\nAfter step 3, we have 2 IDs with the value of 3 and 1 ID with the value of 1. So ans[3] = 2.\n\nExample 2:\n\nInput: nums = [5,5,3], freq = [2,-2,1]\nOutput: [2,0,1]\nExplanation:\nAfter step 0, we have 2 IDs with the value of 5. So ans[0] = 2.\nAfter step 1, there are no IDs. So ans[1] = 0.\nAfter step 2, we have 1 ID with the value of 3. So ans[2] = 1.\n\n \nConstraints:\n\n1 <= nums.length == freq.length <= 105\n1 <= nums[i] <= 105\n-105 <= freq[i] <= 105\nfreq[i] != 0\nThe input is generated such that the occurrences of an ID will not be negative in any step.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 2, 3, 3, 3],freq = [1, 1, 1, -1, -1, -1]) == [1, 1, 2, 2, 2, 2]\n assert candidate(nums = [1, 1, 1, 1, 1],freq = [-1, -1, -1, -1, -1]) == [-1, -2, -3, -4, -5]\n assert candidate(nums = [2, 3, 2, 1],freq = [3, 2, -3, 1]) == [3, 3, 2, 2]\n assert candidate(nums = [1, 2, 3, 4, 5],freq = [1, 1, 1, 1, 1]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [10, 10, 10, 10, 10],freq = [5, -2, 3, -6, 2]) == [5, 3, 6, 0, 2]\n assert candidate(nums = [5, 5, 3],freq = [2, -2, 1]) == [2, 0, 1]\n assert candidate(nums = [1, 2, 2, 3, 3, 3],freq = [1, 1, -1, 1, -1, 1]) == [1, 1, 1, 1, 1, 1]\n assert candidate(nums = [10, 10, 10, 10, 10],freq = [5, -1, -1, -1, -3]) == [5, 4, 3, 2, -1]\n assert candidate(nums = [1, 2, 2, 3, 3, 3],freq = [1, 2, 1, -1, -2, 3]) == [1, 2, 3, 3, 3, 3]\n assert candidate(nums = [1, 1, 1, 2, 2, 3],freq = [1, 1, -2, 1, 1, 1]) == [1, 2, 0, 1, 2, 2]\n assert candidate(nums = [1, 1, 2, 2, 3, 3],freq = [2, -1, 2, -1, 2, -1]) == [2, 1, 2, 1, 2, 1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],freq = [1, 1, 1, 1, 1, 1, 1, 1, 1, -10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, -1]\n assert candidate(nums = [10, 20, 10, 30, 20, 30],freq = [1, 1, -1, 1, -1, 1]) == [1, 1, 1, 1, 1, 2]\n assert candidate(nums = [100000, 100000, 100000, 100000],freq = [100000, -50000, -50000, 1]) == [100000, 50000, 0, 1]\n assert candidate(nums = [1, 2, 1, 3, 2, 1, 4, 3, 2, 1],freq = [1, 1, -1, 1, -1, -1, 1, -1, -1, -1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],freq = [1, 1, 1, 1, 1, -1, -1, -1, -1, -1]) == [1, 2, 3, 4, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],freq = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == [1, 0, 2, 0, 3, 0, 4, 0, 5, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],freq = [-100, -200, -300, -400, -500, -600, -700, -800, -900, -1000]) == [-100, -100, -100, -100, -100, -100, -100, -100, -100, -100]\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2],freq = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5]) == [1, 3, 6, 10, 15, 15, 15, 15, 15, 15]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],freq = [10, -5, 20, -10, 30, -15, 40, -20, 50, -25]) == [10, 10, 20, 20, 30, 30, 40, 40, 50, 50]\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4],freq = [1, 1, -2, 1, 1, -2, 1, 1, -2, 1, 1, -2]) == [1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0]\n assert candidate(nums = [1, 3, 5, 7, 9],freq = [1, -1, 1, -1, 1]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3],freq = [1, -1, 1, 1, -1, 1, 1, 1, -3]) == [1, 0, 1, 2, 1, 1, 2, 3, 1]\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 3],freq = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [10, 30, 60, 60, 90, 150, 150, 150, 240, 340]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],freq = [10, -9, 8, -7, 6, -5, 4, -3, 2, -1]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],freq = [10, 20, 30, 40, 50, -10, -20, -30, -40, -50]) == [10, 20, 30, 40, 50, 50, 50, 50, 50, 50]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],freq = [10, 10, 10, 10, 10, -5, -5, -5, -5, -5]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],freq = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10]) == [-1, 2, 2, 4, 4, 6, 6, 8, 8, 10]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],freq = [-10, 20, -30, 40, -50, 60, -70, 80, -90, 100]) == [-10, 20, 20, 40, 40, 60, 60, 80, 80, 100]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],freq = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],freq = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996],freq = [100000, -100000, 100000, -100000, 100000]) == [100000, 100000, 100000, 100000, 100000]\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7],freq = [1, -1, 2, -2, 3, -3, 4]) == [1, 0, 2, 0, 3, 0, 4]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],freq = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],freq = [1, 2, 3, 4, 5, -6, -7, -8, -9, -10]) == [1, 2, 3, 4, 5, 5, 5, 5, 5, 5]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],freq = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],freq = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [5, 4, 3, 2, 1],freq = [-1, -2, -3, -4, -5]) == [-1, -1, -1, -1, -1]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],freq = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [5, 10, 15, 20, 25, 30],freq = [100, -50, 200, -100, 300, -150]) == [100, 100, 200, 200, 300, 300]\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5],freq = [1, 1, 1, 1, 1, -1, -1, -1, -1, -1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5],freq = [1, 1, 1, 1, 1, -1, -1, -1, -1]) == [1, 2, 3, 4, 5, 4, 3, 2, 1]\n assert candidate(nums = [100000, 50000, 25000, 12500, 6250],freq = [1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],freq = [1, 1, 1, 1, 1, -1, -1, -1, -1, -1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],freq = [1, 2, 3, 4, 5, -5, -4, -3, -2, -1]) == [1, 2, 3, 4, 5, 5, 5, 5, 5, 5]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],freq = [2, -2, 3, -3, 4, -4, 5, -5, 6, -6]) == [2, 0, 3, 0, 4, 0, 5, 0, 6, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],freq = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10]) == [1, 1, 3, 3, 5, 5, 7, 7, 9, 9]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],freq = [1, 1, 1, 1, 1, -1, -1, -1, -1, -1]) == [1, 2, 3, 4, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],freq = [1, 1, -1, 1, 1, -2, 1, 1, 1, -3]) == [1, 1, 1, 1, 2, 1, 1, 2, 3, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],freq = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1],freq = [10, 20, 30, -5, -10, -15, 5, 10, 15, -25]) == [10, 20, 30, 30, 30, 15, 15, 20, 30, 30]\n assert candidate(nums = [1, 2, 3, 4, 5],freq = [1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],freq = [-1, -2, -3, -4, -5, 5, 4, 3, 2, 1]) == [-1, -1, -1, -1, -1, 5, 5, 5, 5, 5]\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4],freq = [10, -5, 7, -3, 2, 8, -2, 4, -1, 6, -4, 3, -2, 1]) == [10, 5, 7, 5, 6, 8, 6, 10, 9, 9, 9, 9, 9, 9]\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2],freq = [100, -50, 50, -25, 25, -12, -6, -3, -1, 1]) == [100, 100, 150, 150, 175, 175, 169, 169, 168, 168]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],freq = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],freq = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],freq = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],freq = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5],freq = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],freq = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5]) == [1, 2, 3, 4, 5, 5, 5, 5, 5, 5]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],freq = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],freq = [100000, -50000, 100000, -50000, 100000, -50000, 100000, -50000, 100000, -50000]) == [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000],freq = [100000, -50000, 50000, -25000, 25000]) == [100000, 50000, 100000, 75000, 100000]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],freq = [10, -2, 5, -3, 7, -1, 4, -6, 2, -8]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],freq = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],freq = [1000, 1000, 1000, 1000, 1000, -1000, -1000, -1000, -1000, -1000]) == [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]\n assert candidate(nums = [10, 20, 30, 40, 50],freq = [1000, 2000, 3000, 4000, 5000]) == [1000, 2000, 3000, 4000, 5000]\n assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50],freq = [1, 1, 1, 1, 1, -1, -1, -1, -1, -1]) == [1, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],freq = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [100, 200, 300, 400, 500, 100, 200, 300, 400, 500],freq = [1, 1, 1, 1, 1, -1, -1, -1, -1, -1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],freq = [100000, -50000, 50000, -25000, 25000, -12500, 12500, -6250, 6250, -3125]) == [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],freq = [100, -50, 200, -100, 300, -150, 400, -200, 500, -250]) == [100, 100, 200, 200, 300, 300, 400, 400, 500, 500]\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2],freq = [1, 2, 3, 4, 5, -5, -4, -3, -2, -1]) == [1, 3, 6, 10, 15, 15, 15, 15, 15, 15]\n assert candidate(nums = [100, 200, 300, 100, 200, 300, 100, 200, 300, 100],freq = [10, -5, 20, -10, 15, -20, 25, -15, 30, -30]) == [10, 10, 20, 20, 20, 10, 25, 25, 30, 30]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],freq = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1]) == [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1]\n assert candidate(nums = [100, 200, 300, 400, 500],freq = [1000, -500, 1500, -2000, 2500]) == [1000, 1000, 1500, 1500, 2500]\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996],freq = [50000, -50000, 30000, -30000, 20000]) == [50000, 50000, 50000, 50000, 50000]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],freq = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [1, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],freq = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5],freq = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, -2, -3, -4, -5]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],freq = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]\n assert candidate(nums = [5, 10, 15, 20, 25],freq = [2, 2, 2, 2, 2]) == [2, 2, 2, 2, 2]\n assert candidate(nums = [1, 2, 3, 4, 5],freq = [1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],freq = [50000, -25000, 12500, -6250, 3125, -1562, 781, -390, 195, -97]) == [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000]\n assert candidate(nums = [2, 2, 2, 3, 3, 3, 4, 4, 4],freq = [2, 2, 2, -1, -1, -1, 1, 1, 1]) == [2, 4, 6, 6, 6, 6, 6, 6, 6]\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3],freq = [100, -100, 50, 200, -200, 100, 300, -300, 150]) == [100, 0, 50, 200, 50, 100, 300, 100, 150]\n assert candidate(nums = [10, 20, 30, 40, 50],freq = [10, -10, 20, -20, 30]) == [10, 10, 20, 20, 30]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],freq = [1, 1, 1, 1, 1, -1, -1, -1, -1, -1]) == [1, 2, 3, 4, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3],freq = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == [1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],freq = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500]) == [100, 100, 200, 200, 300, 300, 400, 400, 500, 500]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],freq = [100, -10, -10, -10, -10, -10, -10, -10, -10, -100]) == [100, 90, 80, 70, 60, 50, 40, 30, 20, -80]\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],freq = [1, 1, 1, 1, 1, -1, -1, -1, -1, -1]) == [1, 2, 3, 4, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3],freq = [1, 2, 3, 1, 2, 3, 1, 2, 3]) == [1, 2, 3, 3, 4, 6, 6, 6, 9]\n assert candidate(nums = [100, 200, 300, 400, 500],freq = [50, 100, -50, -100, 50]) == [50, 100, 100, 100, 100]\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4],freq = [10, 20, -30, 15, 25, -40, 20, 30, -50, 10, 20, -30]) == [10, 30, 0, 15, 40, 0, 20, 50, 0, 10, 30, 0]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],freq = [1, 1, 1, 1, 1, -1, -1, -1, -1, -1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [100, 200, 300, 400, 500],freq = [-1, -2, -3, -4, -5]) == [-1, -1, -1, -1, -1]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],freq = [10, 20, 30, -10, -20, -30, 40, 50, -40, -50]) == [10, 30, 60, 50, 30, 0, 40, 90, 50, 0]\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1],freq = [1, -1, 1, -1, 1, -1, 1]) == [1, 1, 2, 2, 3, 3, 4]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],freq = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3],freq = [1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1]) == [1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],freq = [10, -10, 10, -10, 10, -10, 10, -10, 10, -10]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],freq = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [10, 30, 30, 70, 70, 110, 110, 150, 150, 190]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],freq = [-10, 9, -8, 7, -6, 5, -4, 3, -2, 1]) == [-10, 9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],freq = [1, 1, 1, 1, 1, 1, 1, 1, 1, -5]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996],freq = [100000, 99999, 99998, 99997, 99996]) == [100000, 100000, 100000, 100000, 100000]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],freq = [1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n"}, "metadata": {"canonical_parameter_names": ["nums", "freq"], "leetcode_dataset_entry_point": "Solution().mostFrequentIDs", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector mostFrequentIDs(vector& nums, vector& freq) {", "container": "Solution", "callable": "mostFrequentIDs", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "freq", "type": "vector&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3093, "task_id": "longest-common-suffix-queries", "difficulty": "Hard", "problem_description": "You are given two arrays of strings wordsContainer and wordsQuery.\nFor each wordsQuery[i], you need to find a string from wordsContainer that has the longest common suffix with wordsQuery[i]. If there are two or more strings in wordsContainer that share the longest common suffix, find the string that is the smallest in length. If there are two or more such strings that have the same smallest length, find the one that occurred earlier in wordsContainer.\nReturn an array of integers ans, where ans[i] is the index of the string in wordsContainer that has the longest common suffix with wordsQuery[i].\n \nExample 1:\n\nInput: wordsContainer = [\"abcd\",\"bcd\",\"xbcd\"], wordsQuery = [\"cd\",\"bcd\",\"xyz\"]\nOutput: [1,1,1]\nExplanation:\nLet's look at each wordsQuery[i] separately:\n\nFor wordsQuery[0] = \"cd\", strings from wordsContainer that share the longest common suffix \"cd\" are at indices 0, 1, and 2. Among these, the answer is the string at index 1 because it has the shortest length of 3.\nFor wordsQuery[1] = \"bcd\", strings from wordsContainer that share the longest common suffix \"bcd\" are at indices 0, 1, and 2. Among these, the answer is the string at index 1 because it has the shortest length of 3.\nFor wordsQuery[2] = \"xyz\", there is no string from wordsContainer that shares a common suffix. Hence the longest common suffix is \"\", that is shared with strings at index 0, 1, and 2. Among these, the answer is the string at index 1 because it has the shortest length of 3.\n\n\nExample 2:\n\nInput: wordsContainer = [\"abcdefgh\",\"poiuygh\",\"ghghgh\"], wordsQuery = [\"gh\",\"acbfgh\",\"acbfegh\"]\nOutput: [2,0,2]\nExplanation:\nLet's look at each wordsQuery[i] separately:\n\nFor wordsQuery[0] = \"gh\", strings from wordsContainer that share the longest common suffix \"gh\" are at indices 0, 1, and 2. Among these, the answer is the string at index 2 because it has the shortest length of 6.\nFor wordsQuery[1] = \"acbfgh\", only the string at index 0 shares the longest common suffix \"fgh\". Hence it is the answer, even though the string at index 2 is shorter.\nFor wordsQuery[2] = \"acbfegh\", strings from wordsContainer that share the longest common suffix \"gh\" are at indices 0, 1, and 2. Among these, the answer is the string at index 2 because it has the shortest length of 6.\n\n\n \nConstraints:\n\n1 <= wordsContainer.length, wordsQuery.length <= 104\n1 <= wordsContainer[i].length <= 5 * 103\n1 <= wordsQuery[i].length <= 5 * 103\nwordsContainer[i] consists only of lowercase English letters.\nwordsQuery[i] consists only of lowercase English letters.\nSum of wordsContainer[i].length is at most 5 * 105.\nSum of wordsQuery[i].length is at most 5 * 105.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(wordsContainer = ['banana', 'mango', 'papaya'],wordsQuery = ['ana', 'ango', 'aya']) == [0, 1, 2]\n assert candidate(wordsContainer = ['abcde', 'bcde', 'cde', 'de', 'e'],wordsQuery = ['cde', 'de', 'e', 'a', 'b']) == [2, 3, 4, 4, 4]\n assert candidate(wordsContainer = ['xyz', 'zyx', 'zxy'],wordsQuery = ['x', 'y', 'z']) == [1, 2, 0]\n assert candidate(wordsContainer = ['zzzzz', 'zzzz', 'zzz', 'zz', 'z'],wordsQuery = ['zzzz', 'zzz', 'zz', 'z', 'a']) == [1, 2, 3, 4, 4]\n assert candidate(wordsContainer = ['a', 'ab', 'abc'],wordsQuery = ['a', 'ab', 'abc']) == [0, 1, 2]\n assert candidate(wordsContainer = ['unique', 'suffix', 'words'],wordsQuery = ['fix', 'ffix', 'uffix']) == [1, 1, 1]\n assert candidate(wordsContainer = ['abcd', 'bcd', 'xbcd'],wordsQuery = ['cd', 'bcd', 'xyz']) == [1, 1, 1]\n assert candidate(wordsContainer = ['hello', 'world', 'python'],wordsQuery = ['lo', 'rld', 'on']) == [0, 1, 2]\n assert candidate(wordsContainer = ['a', 'b', 'c'],wordsQuery = ['d', 'e', 'f']) == [0, 0, 0]\n assert candidate(wordsContainer = ['abcdefgh', 'poiuygh', 'ghghgh'],wordsQuery = ['gh', 'acbfgh', 'acbfegh']) == [2, 0, 2]\n assert candidate(wordsContainer = ['abcde', 'bcde', 'cde'],wordsQuery = ['cde', 'de', 'e']) == [2, 2, 2]\n assert candidate(wordsContainer = ['same', 'same', 'same'],wordsQuery = ['same', 'same', 'same']) == [0, 0, 0]\n assert candidate(wordsContainer = ['longestword', 'short', 'word'],wordsQuery = ['word', 'short', 'longestword']) == [2, 1, 0]\n assert candidate(wordsContainer = ['apple', 'maple', 'orange'],wordsQuery = ['le', 'ple', 'range']) == [0, 0, 2]\n assert candidate(wordsContainer = ['a', 'b', 'c'],wordsQuery = ['a', 'b', 'c']) == [0, 1, 2]\n assert candidate(wordsContainer = ['abc', 'def', 'ghi'],wordsQuery = ['abc', 'def', 'ghi']) == [0, 1, 2]\n assert candidate(wordsContainer = ['a', 'b', 'c', 'd'],wordsQuery = ['a', 'b', 'c', 'd']) == [0, 1, 2, 3]\n assert candidate(wordsContainer = ['aaaaa', 'bbbbb', 'ccccc', 'abcde', 'bcdef', 'cdefg'],wordsQuery = ['abcde', 'bcdef', 'cdefg', 'de', 'ef', 'f']) == [3, 4, 5, 3, 4, 4]\n assert candidate(wordsContainer = ['abcdef', 'defabc', 'abc', 'def', 'efg', 'fg', 'g'],wordsQuery = ['abc', 'def', 'efg', 'fg', 'g', 'a', 'bcd', 'cde']) == [2, 3, 4, 5, 6, 6, 6, 6]\n assert candidate(wordsContainer = ['abcdefghijk', 'ghijklmno', 'ijklmnopq', 'jklmnopqr', 'klmnopqrs', 'lmnopqrst'],wordsQuery = ['ijkl', 'mnop', 'nopq', 'opqr', 'pqrs', 'qrstu', 'rstuv', 'stuvw', 'tuvwx', 'uvwxy', 'vwxyz', 'wxyz', 'xyz', 'yz', 'z']) == [1, 1, 2, 3, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(wordsContainer = ['aabbcc', 'bbcc', 'bcc', 'cc', 'c', 'aabbccdd', 'bbccdd', 'bccdd', 'ccdd', 'cdd', 'dd', 'd'],wordsQuery = ['cc', 'dd', 'cdd', 'bcc', 'bbcc', 'aabbcc', 'xyz', 'abc', 'd', 'ccdd', 'aabbccdd']) == [3, 10, 9, 2, 1, 0, 4, 4, 11, 8, 5]\n assert candidate(wordsContainer = ['zzzzzzzzzzzzzzzz', 'zzzzzzzzzzzzzzz', 'zzzzzzzzzzzzzz', 'zzzzzzzzzzzzz', 'zzzzzzzzzzzz', 'zzzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzz', 'zzzzzzzz', 'zzzzzzz', 'zzzzzz', 'zzzzz', 'zzzz', 'zzz', 'zz', 'z', ''],wordsQuery = ['zzzzzzzzzzzzzzzz', 'zzzzzzzzzzzzzzz', 'zzzzzzzzzzzzzz', 'zzzzzzzzzzzzz', 'zzzzzzzzzzzz', 'zzzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzz', 'zzzzzzzz', 'zzzzzzz', 'zzzzzz', 'zzzzz', 'zzzz', 'zzz', 'zz', 'z', '', 'abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz']) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15]\n assert candidate(wordsContainer = ['aaaaa', 'aaabaaa', 'aaacaaa', 'aaad', 'aa', 'a', 'aaeaaa'],wordsQuery = ['aa', 'aaa', 'aaaa', 'aaaaa', 'aaab', 'aaac', 'aaad', 'aae']) == [4, 0, 0, 0, 5, 5, 3, 5]\n assert candidate(wordsContainer = ['apple', 'pple', 'ple', 'le', 'e', 'orange', 'range', 'ange', 'nge', 'ge', 'e'],wordsQuery = ['ple', 'le', 'e', 'apple', 'orange', 'range', 'nge', 'ge']) == [2, 3, 4, 0, 5, 6, 8, 9]\n assert candidate(wordsContainer = ['abcd', 'bcd', 'cd', 'd', ''],wordsQuery = ['abcd', 'bcd', 'cd', 'd', '', 'a', 'b', 'c']) == [0, 1, 2, 3, 4, 4, 4, 4]\n assert candidate(wordsContainer = ['ababab', 'bababa', 'abab', 'bab', 'ab', 'b', 'a'],wordsQuery = ['ab', 'bab', 'abab', 'bababa', 'ababab', 'ba', 'a']) == [4, 3, 2, 1, 0, 1, 6]\n assert candidate(wordsContainer = ['longestword', 'longest', 'long', 'lo', 'l'],wordsQuery = ['word', 'st', 'ng', 'g', 'o', 'wordd', 'ngggg']) == [0, 1, 2, 2, 3, 0, 2]\n assert candidate(wordsContainer = ['abcd', 'bcd', 'bcd', 'cd', 'cd', 'd'],wordsQuery = ['cd', 'bcd', 'd', 'a', 'ab', 'abcd']) == [3, 1, 5, 5, 5, 0]\n assert candidate(wordsContainer = ['a', 'aa', 'aaa', 'aaaa', 'aaaaa'],wordsQuery = ['a', 'aa', 'aaa', 'aaaa', 'aaaaa', 'aaaaaa', 'aaaaaaa']) == [0, 1, 2, 3, 4, 4, 4]\n assert candidate(wordsContainer = ['prefix', 'prefixx', 'prefixxx', 'prefixxxx'],wordsQuery = ['fix', 'xfix', 'xxfix', 'xxxfix', 'xxxxfix', 'prefix']) == [0, 0, 0, 0, 0, 0]\n assert candidate(wordsContainer = ['abcd', 'bcd', 'cd', 'd', 'abcdabcd', 'bcdbcd', 'cdcd', 'dd', 'abcdabcde'],wordsQuery = ['abcd', 'bcd', 'cd', 'd', 'abcdabcd', 'bcdbcd', 'cdcd', 'dd', 'e', 'abcdabcde', 'de', 'cde', 'bcde']) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 8, 8, 8]\n assert candidate(wordsContainer = ['abcdexyz', 'bcdexyz', 'cdexyz', 'dexyz', 'exyz', 'xyz'],wordsQuery = ['xyz', 'exyz', 'dexyz', 'cdexyz', 'bcdexyz', 'abcdexyz', 'z']) == [5, 4, 3, 2, 1, 0, 5]\n assert candidate(wordsContainer = ['abcdexyz', 'bcdexyz', 'xbcdexyz', 'abcdexyz'],wordsQuery = ['cdexyz', 'bcdexyz', 'xyz', 'abcdexyz']) == [1, 1, 1, 0]\n assert candidate(wordsContainer = ['hello', 'world', 'hello_world', 'world_hello', 'hold', 'old', 'ld', 'd'],wordsQuery = ['hello', 'world', 'hello_world', 'hold', 'old', 'ld', 'd', 'o']) == [0, 1, 2, 4, 5, 6, 7, 0]\n assert candidate(wordsContainer = ['apple', 'orange', 'banana', 'grape', 'pineapple'],wordsQuery = ['apple', 'orange', 'banana', 'grape', 'pineapple', 'pe', 'e']) == [0, 1, 2, 3, 4, 3, 0]\n assert candidate(wordsContainer = ['xyz', 'yz', 'z', 'wxyz', 'vwxyz'],wordsQuery = ['z', 'yz', 'xyz', 'wxyz', 'vwxyz', 'wxyzz']) == [2, 1, 0, 3, 4, 2]\n assert candidate(wordsContainer = ['aaaa', 'aaab', 'aaac', 'aaba', 'aabb', 'aabc', 'aaca', 'aacc', 'abaa', 'abab', 'abac', 'abba', 'abbb', 'abbc', 'abca', 'abcb', 'abcc', 'acaa', 'acab', 'acac', 'acba', 'acbb', 'acbc', 'acca', 'accb', 'accc'],wordsQuery = ['aaa', 'aab', 'aac', 'aba', 'abb', 'abc', 'aca', 'acc', 'baa', 'bab', 'bac', 'bba', 'bbb', 'bbc', 'bca', 'bcb', 'bcc', 'caa', 'cab', 'cac', 'cba', 'cbb', 'cbc', 'cca', 'ccb', 'ccc', 'a', 'b', 'c', 'aa', 'ab', 'ac', 'ba', 'bb', 'bc', 'ca', 'cb', 'cc']) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0, 1, 2, 0, 1, 2, 3, 4, 5, 6, 15, 7]\n assert candidate(wordsContainer = ['example', 'samples', 'examples', 'sampless'],wordsQuery = ['ple', 'les', 'ample', 'sample', 'samples', 'examples', 'sampless']) == [0, 1, 0, 0, 1, 2, 3]\n assert candidate(wordsContainer = ['abcdefghij', 'abcdefghijk', 'abcdefgh', 'abcdefg', 'abcde', 'abcd'],wordsQuery = ['defg', 'efgh', 'fghi', 'ghij', 'hijk', 'ijkl']) == [3, 2, 5, 0, 1, 5]\n assert candidate(wordsContainer = ['abcdefghij', 'bcdefghij', 'cdefghij', 'defghij', 'efghij', 'fghij', 'ghij', 'hij', 'ij', 'j'],wordsQuery = ['ghij', 'hij', 'ij', 'j', 'k', 'abcdefghij', 'bcdefghij', 'cdefghij', 'defghij']) == [6, 7, 8, 9, 9, 0, 1, 2, 3]\n assert candidate(wordsContainer = ['aabbcc', 'bbaacc', 'ccaabb', 'aabb', 'bbaa', 'ccaac', 'aac', 'ac', 'c'],wordsQuery = ['aabbcc', 'bbaacc', 'ccaabb', 'aabb', 'bbaa', 'ccaac', 'aac', 'ac', 'c', 'aa', 'bb', 'cc']) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 4, 3, 0]\n assert candidate(wordsContainer = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],wordsQuery = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(wordsContainer = ['banana', 'anana', 'nana', 'ana', 'na', 'a'],wordsQuery = ['ana', 'na', 'a', 'anana', 'nana', 'banana', 'bana', 'ananaa']) == [3, 4, 5, 1, 2, 0, 3, 5]\n assert candidate(wordsContainer = ['abcdefg', 'defg', 'efg', 'fg', 'g'],wordsQuery = ['defg', 'efg', 'fg', 'g', 'abcdefg']) == [1, 2, 3, 4, 0]\n assert candidate(wordsContainer = ['repeated', 'repeatedword', 'repeat', 'rep', 're', 'r'],wordsQuery = ['repeated', 'repeatedword', 'repeat', 'rep', 're', 'r', 'ed', 'at', 't', 'e', '']) == [0, 1, 2, 3, 4, 5, 0, 2, 2, 4, 5]\n assert candidate(wordsContainer = ['suffix', 'fix', 'suffixfix', 'suffixsuffix', 'ffix', 'fixfix', 'suffixfixfix'],wordsQuery = ['suffix', 'fix', 'suffixfix', 'suffixsuffix', 'ffix', 'fixfix', 'suffixfixfix', 'ff', 'ix', 'x']) == [0, 1, 2, 3, 4, 5, 6, 1, 1, 1]\n assert candidate(wordsContainer = ['abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba', 'abcdefghijk', 'lmnopqr', 'stuvwxyz'],wordsQuery = ['mnopqr', 'lmnopqr', 'stuv', 'xyz', 'pqrs']) == [3, 3, 3, 4, 3]\n assert candidate(wordsContainer = ['unique', 'uniq', 'un', 'u'],wordsQuery = ['ue', 'iq', 'n', 'u', 'uniq', 'unique', 'nique']) == [0, 1, 2, 3, 1, 0, 0]\n assert candidate(wordsContainer = ['short', 'shorter', 'shortest', 'shortestest'],wordsQuery = ['est', 'test', 'st', 'rtest', 'shortestestest', 'shorter', 'shortest']) == [2, 2, 2, 2, 3, 1, 2]\n assert candidate(wordsContainer = ['hello', 'world', 'programming', 'worldwide', 'program'],wordsQuery = ['gram', 'ing', 'world', 'hello', 'pro', 'gramming']) == [4, 2, 1, 0, 0, 2]\n assert candidate(wordsContainer = ['suffix', 'prefix', 'suffixprefix', 'prefixsuffix'],wordsQuery = ['fix', 'fixx', 'suffix', 'prefix', 'uffix', 'frefix', 'sufix']) == [0, 0, 0, 1, 0, 1, 0]\n assert candidate(wordsContainer = ['xyz', 'zyx', 'yxz', 'zxz', 'xzy', 'zyy'],wordsQuery = ['xyz', 'zyx', 'yz', 'zx', 'xz', 'yy']) == [0, 1, 0, 1, 2, 5]\n assert candidate(wordsContainer = ['aaaa', 'aaa', 'aa', 'a', ''],wordsQuery = ['aaaa', 'aaa', 'aa', 'a', '', 'b']) == [0, 1, 2, 3, 4, 4]\n assert candidate(wordsContainer = ['a', 'aa', 'aaa', 'aaaa', 'aaaaa'],wordsQuery = ['a', 'aa', 'aaa', 'aaaa', 'aaaaa', 'aaaaaa']) == [0, 1, 2, 3, 4, 4]\n assert candidate(wordsContainer = ['abcdefg', 'defghij', 'efghijk', 'fghijkl', 'ghijklm'],wordsQuery = ['fgh', 'ghijk', 'ijkl', 'jklm', 'mnop']) == [0, 2, 3, 4, 0]\n assert candidate(wordsContainer = ['suffix', 'suffixx', 'suffixxx', 'suffixxxx'],wordsQuery = ['ffix', 'xffix', 'xxffix', 'xxxffix', 'xxxxffix', 'suffix']) == [0, 0, 0, 0, 0, 0]\n assert candidate(wordsContainer = ['abcdefghij', 'bcdefghij', 'cdefghij', 'defghij', 'efghij', 'fghij', 'ghij', 'hij', 'ij', 'j'],wordsQuery = (['abcdefghij', 'efghij', 'fghij', 'ghij', 'hij', 'ij', 'j', 'abcdefghijk', 'defghijk', 'fghijk', 'ghijk', 'hijk', 'ijk', 'jk', 'k'],)) == [9]\n assert candidate(wordsContainer = ['sameprefixsame', 'sameprefix', 'same', 'different'],wordsQuery = ['sameprefixsame', 'sameprefix', 'same', 'different', 'sameprefixsame', 'sameprefix', 'same', 'different']) == [0, 1, 2, 3, 0, 1, 2, 3]\n assert candidate(wordsContainer = ['suffix', 'suffixes', 'suffices', 'suffixing', 'suffixied'],wordsQuery = ['fix', 'fixes', 'fices', 'fixing', 'fixied', 'suffix', 'suffixes']) == [0, 1, 2, 3, 4, 0, 1]\n assert candidate(wordsContainer = ['longestword', 'longword', 'long', 'lon', 'lo', 'l'],wordsQuery = ['ongestword', 'ongword', 'ong', 'on', 'o', 'l', 'x']) == [0, 1, 2, 3, 4, 5, 5]\n assert candidate(wordsContainer = ['one', 'two', 'three', 'four', 'five'],wordsQuery = ['ne', 'wo', 'ree', 'our', 'ive', 'ven', 'on']) == [0, 1, 2, 3, 4, 0, 0]\n assert candidate(wordsContainer = ['abcabcabc', 'bcabcabc', 'cabcabc', 'abcabc', 'bcabc', 'cabc', 'abc', 'bc', 'c', 'a', 'b', 'c'],wordsQuery = ['abc', 'bc', 'c', 'a', 'b', 'c', 'abcabc', 'bcabc', 'cabc', 'abcabcabc', 'xyz', 'zzz', 'aaaaa', 'bbbbb', 'ccccc', 'dddd', 'eeeee', 'ffffff', 'gggg', 'hhhhh', 'iiiii', 'jjjjj', 'kkkkk', 'lllll', 'mmmmm', 'nnnnn', 'ooooo', 'ppppp', 'qqqqq', 'rrrrr', 'sssss', 'ttttt', 'uuuuu', 'vvvvv', 'wwwww', 'xxxxx', 'yyyyy', 'zzzzz']) == [6, 7, 8, 9, 10, 8, 3, 4, 5, 0, 8, 8, 9, 10, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]\n assert candidate(wordsContainer = ['aabbcc', 'bbcc', 'bcc', 'cc', 'c'],wordsQuery = ['aabbcc', 'bbcc', 'bcc', 'cc', 'c', 'd', 'e', 'f']) == [0, 1, 2, 3, 4, 4, 4, 4]\n assert candidate(wordsContainer = ['apple', 'banana', 'grape', 'pineapple', 'orange'],wordsQuery = ['apple', 'banana', 'grape', 'pineapple', 'orange', 'le', 'ane', 'e']) == [0, 1, 2, 3, 4, 0, 0, 0]\n assert candidate(wordsContainer = ['longstring', 'longstr', 'longs', 'long', 'lo', 'l'],wordsQuery = ['longstr', 'longs', 'long', 'lo', 'l', 'o', 'ongstr', 'ngstr', 'gstr', 'str']) == [1, 2, 3, 4, 5, 4, 1, 1, 1, 1]\n assert candidate(wordsContainer = ['xyzabc', 'yabc', 'xabc', 'abc', 'bc', 'c'],wordsQuery = ['abc', 'c', 'bc', 'xyzabc', 'yabc', 'xabc']) == [3, 5, 4, 0, 1, 2]\n assert candidate(wordsContainer = ['aabbcc', 'bbaa', 'ccaa', 'aab', 'bb', 'cc'],wordsQuery = ['aabbcc', 'bbaa', 'ccaa', 'aab', 'bb', 'cc', 'aabb', 'bbcc', 'aa', 'b', 'c']) == [0, 1, 2, 3, 4, 5, 4, 0, 1, 4, 5]\n assert candidate(wordsContainer = ['abcdefghij', 'bcdefghij', 'cdefghij', 'defghij', 'efghij', 'fghij', 'ghij', 'hij', 'ij', 'j'],wordsQuery = ['ij', 'fghij', 'ghij', 'hij', 'ij', 'j', 'abcdef', 'xyz', 'zzz', 'abcdefghij']) == [8, 5, 6, 7, 8, 9, 9, 9, 9, 0]\n assert candidate(wordsContainer = ['abcabcabcabc', 'bcabcabcabc', 'cabcabcabc', 'abcabcabc', 'bcabcabc', 'cabcabc', 'abcabc', 'bcabc', 'cabc', 'abc', 'bc', 'c'],wordsQuery = ['abcabcabcabc', 'bcabcabcabc', 'cabcabcabc', 'abcabcabc', 'bcabcabc', 'cabcabc', 'abcabc', 'bcabc', 'cabc', 'abc', 'bc', 'c', 'd', 'e', 'f']) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11, 11, 11]\n assert candidate(wordsContainer = ['suffix', 'suffixmatch', 'suffixmatchlong', 'suffixmatchlongest'],wordsQuery = ['suffix', 'match', 'long', 'longest', 'suffixmatch', 'suffixmatchlong', 'suffixmatchlongest']) == [0, 1, 2, 3, 1, 2, 3]\n assert candidate(wordsContainer = ['racecar', 'civic', 'level', 'rotor', 'deified'],wordsQuery = ['car', 'civic', 'vel', 'rotor', 'deified', 'cara', 'ivic']) == [0, 1, 2, 3, 4, 1, 1]\n assert candidate(wordsContainer = ['abcdefgh', 'abcdefg', 'abcde', 'abcd', 'abc', 'ab', 'a'],wordsQuery = ['abcd', 'abc', 'ab', 'a', 'z', 'bcd', 'cde']) == [3, 4, 5, 6, 6, 3, 2]\n assert candidate(wordsContainer = ['xyzabc', 'yzabc', 'zabc', 'abc', 'c'],wordsQuery = ['zabc', 'abc', 'c', 'xyzabc', 'y']) == [2, 3, 4, 0, 4]\n assert candidate(wordsContainer = ['abcdexyz', 'bcdexyz', 'cdexyz', 'dexyz', 'exyz', 'xyz', 'yz', 'z'],wordsQuery = ['abcdexyz', 'bcdexyz', 'cdexyz', 'dexyz', 'exyz', 'xyz', 'yz', 'z', 'xyz', 'exyz', 'dexyz', 'cdexyz', 'bcdexyz', 'abcdexyz']) == [0, 1, 2, 3, 4, 5, 6, 7, 5, 4, 3, 2, 1, 0]\n assert candidate(wordsContainer = ['apple', 'bpple', 'cppla', 'dppla', 'epple'],wordsQuery = ['pple', 'apple', 'bpple', 'cppla', 'dppla', 'epple']) == [0, 0, 1, 2, 3, 4]\n assert candidate(wordsContainer = ['aaaa', 'bbbb', 'cccc', 'dddd', 'eeee'],wordsQuery = ['aaaa', 'bbbb', 'cccc', 'dddd', 'eeee', 'aaa', 'bbb', 'ccc', 'ddd', 'eee', 'aa', 'bb', 'cc', 'dd', 'ee', 'a', 'b', 'c', 'd', 'e']) == [0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4]\n assert candidate(wordsContainer = ['abcd', 'bcd', 'cd', 'd'],wordsQuery = ['abcd', 'bcd', 'cd', 'd', 'abcd', 'bcd', 'cd', 'd']) == [0, 1, 2, 3, 0, 1, 2, 3]\n assert candidate(wordsContainer = ['zzzzz', 'zzzz', 'zzz', 'zz', 'z'],wordsQuery = ['zzzzz', 'zzzz', 'zzz', 'zz', 'z', 'a', 'b', 'c']) == [0, 1, 2, 3, 4, 4, 4, 4]\n assert candidate(wordsContainer = ['thisisatest', 'isisatest', 'sisatest', 'isatest', 'satest', 'atest', 'test', 'est', 'st', 't'],wordsQuery = ['test', 'est', 'st', 't', 'a', 'b', 'c', 'd', 'e', 'f']) == [6, 7, 8, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(wordsContainer = ['longword', 'longerword', 'longestword', 'shortword', 'tinyword'],wordsQuery = ['word', 'longword', 'longerword', 'longestword', 'shortword', 'tinyword', 'long', 'longer', 'longest', 'short', 'tiny', 'o', 'r', 't', 'w', 'd']) == [0, 0, 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(wordsContainer = ['unique', 'distinct', 'separate', 'different', 'uniquely'],wordsQuery = ['unique', 'distinct', 'separate', 'different', 'uniquely', 'un']) == [0, 1, 2, 3, 4, 0]\n assert candidate(wordsContainer = ['longwordwithsuffix', 'wordwithsuffix', 'withsuffix', 'suffix', 'fix', 'ix', 'x'],wordsQuery = ['suffix', 'fix', 'ix', 'x', 'y', 'z', 'wordwithsuffix', 'longwordwithsuffix']) == [3, 4, 5, 6, 6, 6, 1, 0]\n assert candidate(wordsContainer = ['longestword', 'longest', 'long', 'lon', 'lo', 'l'],wordsQuery = ['longestword', 'longest', 'longestword', 'lon', 'lo', 'xyz']) == [0, 1, 0, 3, 4, 5]\n assert candidate(wordsContainer = ['uniqueword', 'anotherword', 'commonword', 'similarword', 'dissimilarword'],wordsQuery = ['word', 'similar', 'dissimilar', 'unique', 'another', 'common']) == [0, 0, 0, 0, 0, 0]\n"}, "metadata": {"canonical_parameter_names": ["wordsContainer", "wordsQuery"], "leetcode_dataset_entry_point": "Solution().stringIndices", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector stringIndices(vector& wordsContainer, vector& wordsQuery) {", "container": "Solution", "callable": "stringIndices", "parameters": [{"name": "wordsContainer", "type": "vector&"}, {"name": "wordsQuery", "type": "vector&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3095, "task_id": "shortest-subarray-with-or-at-least-k-i", "difficulty": "Easy", "problem_description": "You are given an array nums of non-negative integers and an integer k.\nAn array is called special if the bitwise OR of all of its elements is at least k.\nReturn the length of the shortest special non-empty subarray of nums, or return -1 if no special subarray exists.\n \nExample 1:\n\nInput: nums = [1,2,3], k = 2\nOutput: 1\nExplanation:\nThe subarray [3] has OR value of 3. Hence, we return 1.\nNote that [2] is also a special subarray.\n\nExample 2:\n\nInput: nums = [2,1,8], k = 10\nOutput: 3\nExplanation:\nThe subarray [2,1,8] has OR value of 11. Hence, we return 3.\n\nExample 3:\n\nInput: nums = [1,2], k = 0\nOutput: 1\nExplanation:\nThe subarray [1] has OR value of 1. Hence, we return 1.\n\n \nConstraints:\n\n1 <= nums.length <= 50\n0 <= nums[i] <= 50\n0 <= k < 64\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [0, 0, 0],k = 1) == -1\n assert candidate(nums = [5, 5, 5, 5],k = 5) == 1\n assert candidate(nums = [1, 2],k = 0) == 1\n assert candidate(nums = [4, 5, 6, 7],k = 12) == -1\n assert candidate(nums = [1, 2, 3],k = 2) == 1\n assert candidate(nums = [30, 1, 4, 3, 2, 5],k = 6) == 1\n assert candidate(nums = [7, 14, 21, 28, 35],k = 21) == 1\n assert candidate(nums = [1, 3, 5, 7, 9],k = 15) == 2\n assert candidate(nums = [30, 1, 4, 3],k = 7) == 1\n assert candidate(nums = [3, 3, 3, 3, 3],k = 2) == 1\n assert candidate(nums = [10, 20, 30, 40, 50],k = 100) == -1\n assert candidate(nums = [0, 0, 0, 0],k = 1) == -1\n assert candidate(nums = [32, 16, 8, 4, 2, 1],k = 31) == 1\n assert candidate(nums = [2, 1, 8],k = 10) == 3\n assert candidate(nums = [30, 40, 10, 50],k = 70) == -1\n assert candidate(nums = [30, 1, 4, 2],k = 31) == 2\n assert candidate(nums = [42, 24, 8, 16],k = 48) == 2\n assert candidate(nums = [2, 4, 6, 8, 10],k = 30) == -1\n assert candidate(nums = [42, 21, 17, 8, 2],k = 42) == 1\n assert candidate(nums = [31, 31, 31, 31],k = 31) == 1\n assert candidate(nums = [16, 8, 4, 2, 1],k = 31) == 5\n assert candidate(nums = [31, 15, 7, 3, 1],k = 31) == 1\n assert candidate(nums = [15, 31, 63, 127, 255, 511, 1023, 2047],k = 1024) == 1\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13],k = 15) == 2\n assert candidate(nums = [5, 13, 7, 2, 8],k = 20) == -1\n assert candidate(nums = [5, 3, 1, 4, 2, 8, 16, 32],k = 31) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 1\n assert candidate(nums = [25, 12, 6, 3, 1, 0],k = 25) == 1\n assert candidate(nums = [25, 50, 75, 100, 125, 150, 175, 200, 225, 250],k = 255) == 2\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],k = 1023) == 10\n assert candidate(nums = [32, 16, 8, 4, 2, 1],k = 63) == 6\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15],k = 15) == 1\n assert candidate(nums = [42, 15, 28, 24, 21, 49, 56, 7, 35, 32, 63, 1, 8, 64, 16, 128, 3, 2, 4, 8, 16],k = 255) == 6\n assert candidate(nums = [48, 24, 12, 6, 3, 1],k = 50) == 2\n assert candidate(nums = [4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0],k = 4095) == 1\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 31) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 1\n assert candidate(nums = [3, 5, 6, 9, 12, 15, 18],k = 30) == 2\n assert candidate(nums = [42, 21, 10, 5, 2, 1],k = 42) == 1\n assert candidate(nums = [48, 49, 50, 51, 52, 53, 54, 55, 56, 57],k = 60) == 2\n assert candidate(nums = [50, 25, 12, 6, 3, 1],k = 80) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0],k = 0) == 1\n assert candidate(nums = [3, 6, 12, 24, 48, 96, 192, 384, 512],k = 513) == 2\n assert candidate(nums = [32, 16, 8, 4, 2, 1],k = 31) == 1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],k = 1048575) == 20\n assert candidate(nums = [31, 14, 7, 3, 1],k = 30) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 1\n assert candidate(nums = [5, 7, 11, 13, 17, 19, 23, 29],k = 40) == -1\n assert candidate(nums = [10, 20, 30, 40, 50],k = 120) == -1\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575],k = 1048575) == 1\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 55) == 2\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],k = 511) == 1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],k = 1024) == -1\n assert candidate(nums = [5, 10, 15, 20, 25, 30],k = 45) == -1\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 60) == 2\n assert candidate(nums = [6, 12, 18, 24, 30],k = 30) == 1\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 50) == -1\n assert candidate(nums = [50, 25, 12, 6, 3, 1],k = 49) == 1\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21],k = 60) == -1\n assert candidate(nums = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31],k = 31) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80],k = 150) == -1\n assert candidate(nums = [3, 5, 7, 9, 11, 13],k = 13) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 1\n assert candidate(nums = [31, 14, 7, 3, 1],k = 31) == 1\n assert candidate(nums = [7, 14, 21, 28, 35],k = 35) == 1\n assert candidate(nums = [63, 31, 15, 7, 3, 1, 0],k = 63) == 1\n assert candidate(nums = [31, 31, 31, 31, 31],k = 15) == 1\n assert candidate(nums = [1, 3, 7, 15, 31, 63],k = 63) == 1\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 31) == -1\n assert candidate(nums = [33, 66, 132, 264, 528, 1056, 2112, 4224, 8448, 16896],k = 8000) == 1\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023],k = 512) == 1\n assert candidate(nums = [128, 64, 32, 16, 8, 4, 2, 1],k = 255) == 8\n assert candidate(nums = [7, 14, 21, 28, 35, 42],k = 42) == 1\n assert candidate(nums = [45, 35, 25, 15, 5],k = 60) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1],k = 1) == 1\n assert candidate(nums = [31, 31, 31, 31, 31, 31, 31, 31, 31, 31],k = 31) == 1\n assert candidate(nums = [16, 8, 4, 2, 1, 32, 64, 128, 256, 512, 1024],k = 1536) == 2\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41],k = 60) == 2\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096],k = 8192) == -1\n assert candidate(nums = [1, 3, 7, 15, 31, 63],k = 62) == 1\n assert candidate(nums = [7, 14, 28, 56, 112, 224, 448, 896],k = 1000) == 4\n assert candidate(nums = [31, 15, 7, 3, 1, 0, 0, 0, 0, 0, 1, 3, 7, 15, 31],k = 31) == 1\n assert candidate(nums = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765],k = 6765) == 1\n assert candidate(nums = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40],k = 44) == 2\n assert candidate(nums = [4, 8, 12, 16, 20, 24, 28, 32],k = 31) == 1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64],k = 64) == 1\n assert candidate(nums = [2, 6, 18, 54, 162],k = 242) == -1\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80],k = 96) == 2\n assert candidate(nums = [10, 20, 30, 40, 50],k = 70) == -1\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 1023) == -1\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127],k = 127) == 1\n assert candidate(nums = [45, 35, 25, 15, 5],k = 40) == 1\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],k = 70) == 1\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31],k = 31) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 0) == 1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64],k = 127) == 7\n assert candidate(nums = [5, 10, 15, 20, 25, 30],k = 40) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 15) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 1\n assert candidate(nums = [31, 14, 7, 3, 1, 0, 0, 0, 0, 0],k = 31) == 1\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36],k = 50) == 1\n assert candidate(nums = [16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576],k = 1048576) == 1\n assert candidate(nums = [29, 15, 7, 3, 1],k = 31) == 2\n assert candidate(nums = [63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32],k = 63) == 1\n assert candidate(nums = [4, 6, 8, 10, 12, 14],k = 14) == 1\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35],k = 35) == 1\n assert candidate(nums = [5, 10, 15, 20, 25, 30],k = 30) == 1\n assert candidate(nums = [31, 14, 7, 3, 1, 0, 15, 28, 16],k = 31) == 1\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().minimumSubarrayLength", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumSubarrayLength(vector& nums, int k) {", "container": "Solution", "callable": "minimumSubarrayLength", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3096, "task_id": "minimum-levels-to-gain-more-points", "difficulty": "Medium", "problem_description": "You are given a binary array possible of length n.\nAlice and Bob are playing a game that consists of n levels. Some of the levels in the game are impossible to clear while others can always be cleared. In particular, if possible[i] == 0, then the ith level is impossible to clear for both the players. A player gains 1 point on clearing a level and loses 1 point if the player fails to clear it.\nAt the start of the game, Alice will play some levels in the given order starting from the 0th level, after which Bob will play for the rest of the levels.\nAlice wants to know the minimum number of levels she should play to gain more points than Bob, if both players play optimally to maximize their points.\nReturn the minimum number of levels Alice should play to gain more points. If this is not possible, return -1.\nNote that each player must play at least 1 level.\n \nExample 1:\n\nInput: possible = [1,0,1,0]\nOutput: 1\nExplanation:\nLet's look at all the levels that Alice can play up to:\n\nIf Alice plays only level 0 and Bob plays the rest of the levels, Alice has 1 point, while Bob has -1 + 1 - 1 = -1 point.\nIf Alice plays till level 1 and Bob plays the rest of the levels, Alice has 1 - 1 = 0 points, while Bob has 1 - 1 = 0 points.\nIf Alice plays till level 2 and Bob plays the rest of the levels, Alice has 1 - 1 + 1 = 1 point, while Bob has -1 point.\n\nAlice must play a minimum of 1 level to gain more points.\n\nExample 2:\n\nInput: possible = [1,1,1,1,1]\nOutput: 3\nExplanation:\nLet's look at all the levels that Alice can play up to:\n\nIf Alice plays only level 0 and Bob plays the rest of the levels, Alice has 1 point, while Bob has 4 points.\nIf Alice plays till level 1 and Bob plays the rest of the levels, Alice has 2 points, while Bob has 3 points.\nIf Alice plays till level 2 and Bob plays the rest of the levels, Alice has 3 points, while Bob has 2 points.\nIf Alice plays till level 3 and Bob plays the rest of the levels, Alice has 4 points, while Bob has 1 point.\n\nAlice must play a minimum of 3 levels to gain more points.\n\nExample 3:\n\nInput: possible = [0,0]\nOutput: -1\nExplanation:\nThe only possible way is for both players to play 1 level each. Alice plays level 0 and loses 1 point. Bob plays level 1 and loses 1 point. As both players have equal points, Alice can't gain more points than Bob.\n\n \nConstraints:\n\n2 <= n == possible.length <= 105\npossible[i] is either 0 or 1.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(possible = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1\n assert candidate(possible = [0, 0, 0, 0, 1, 1, 1, 1]) == -1\n assert candidate(possible = [1, 1, 1, 1, 1, 1, 1, 1]) == 5\n assert candidate(possible = [0, 0, 0, 0, 0, 0, 0, 0]) == 1\n assert candidate(possible = [1, 0, 1, 0]) == 1\n assert candidate(possible = [0, 1, 0, 1, 0, 1]) == -1\n assert candidate(possible = [0, 0]) == -1\n assert candidate(possible = [1, 1, 0, 1, 0, 1, 0, 1, 0]) == 1\n assert candidate(possible = [1, 1, 0, 0, 1, 1]) == 2\n assert candidate(possible = [1, 0, 0, 0, 0, 0, 1]) == 1\n assert candidate(possible = [1, 1, 1, 1, 1]) == 3\n assert candidate(possible = [1, 1, 1, 0, 0, 0, 1]) == 1\n assert candidate(possible = [1, 1, 1, 0, 0, 0, 1, 1, 1]) == 2\n assert candidate(possible = [1, 1, 1, 1, 0, 0, 0, 0]) == 1\n assert candidate(possible = [1, 0, 1, 0, 1, 0, 1, 0]) == 1\n assert candidate(possible = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == -1\n assert candidate(possible = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 6\n assert candidate(possible = [0, 1, 0, 1, 0, 1, 0, 1]) == -1\n assert candidate(possible = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1\n assert candidate(possible = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 1\n assert candidate(possible = [0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0]) == 9\n assert candidate(possible = [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(possible = [1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1]) == 2\n assert candidate(possible = [1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == 1\n assert candidate(possible = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 16\n assert candidate(possible = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0]) == 1\n assert candidate(possible = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 1\n assert candidate(possible = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1\n assert candidate(possible = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 1\n assert candidate(possible = [0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1]) == 2\n assert candidate(possible = [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1\n assert candidate(possible = [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(possible = [0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 3\n assert candidate(possible = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 1\n assert candidate(possible = [1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 2\n assert candidate(possible = [1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1]) == 2\n assert candidate(possible = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1\n assert candidate(possible = [1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 2\n assert candidate(possible = [1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0]) == 1\n assert candidate(possible = [1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0]) == 10\n assert candidate(possible = [1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1]) == 1\n assert candidate(possible = [1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1]) == 1\n assert candidate(possible = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0]) == 1\n assert candidate(possible = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == -1\n assert candidate(possible = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == -1\n assert candidate(possible = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1\n assert candidate(possible = [1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0]) == 1\n assert candidate(possible = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1]) == 2\n assert candidate(possible = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == 1\n assert candidate(possible = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == -1\n assert candidate(possible = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0]) == 3\n assert candidate(possible = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0]) == 1\n assert candidate(possible = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 2\n assert candidate(possible = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 1\n assert candidate(possible = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 11\n assert candidate(possible = [0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1]) == -1\n assert candidate(possible = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 23\n assert candidate(possible = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(possible = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1\n assert candidate(possible = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 14\n assert candidate(possible = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 2\n assert candidate(possible = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == 1\n assert candidate(possible = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1]) == 2\n assert candidate(possible = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1]) == 1\n assert candidate(possible = [1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0]) == 1\n assert candidate(possible = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 1\n assert candidate(possible = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1]) == 1\n assert candidate(possible = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0]) == 1\n assert candidate(possible = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(possible = [0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 10\n assert candidate(possible = [0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1]) == 6\n assert candidate(possible = [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 14\n assert candidate(possible = [1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(possible = [0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1]) == 18\n assert candidate(possible = [1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1\n assert candidate(possible = [1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 1\n assert candidate(possible = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 1\n assert candidate(possible = [1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1\n assert candidate(possible = [0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0]) == 6\n assert candidate(possible = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 1\n assert candidate(possible = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 2\n assert candidate(possible = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 6\n assert candidate(possible = [0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1]) == -1\n assert candidate(possible = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1]) == 2\n assert candidate(possible = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == -1\n assert candidate(possible = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 12\n assert candidate(possible = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1]) == -1\n assert candidate(possible = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == -1\n assert candidate(possible = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 40\n assert candidate(possible = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 16\n assert candidate(possible = [1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1]) == 12\n assert candidate(possible = [1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 2\n assert candidate(possible = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 1\n assert candidate(possible = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 1\n assert candidate(possible = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1\n assert candidate(possible = [1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0]) == 8\n assert candidate(possible = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 13\n assert candidate(possible = [1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1\n assert candidate(possible = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0]) == 1\n assert candidate(possible = [1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 1\n assert candidate(possible = [0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0]) == 22\n assert candidate(possible = [1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0]) == 1\n assert candidate(possible = [0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0]) == 10\n assert candidate(possible = [1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1]) == 1\n assert candidate(possible = [1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0]) == 1\n assert candidate(possible = [1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1]) == 3\n assert candidate(possible = [1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0]) == 1\n assert candidate(possible = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == 1\n assert candidate(possible = [1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1]) == 3\n assert candidate(possible = [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1]) == 1\n assert candidate(possible = [1, 1, 0, 0, 1, 1, 1, 0, 1, 0]) == 2\n assert candidate(possible = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 1\n assert candidate(possible = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == -1\n assert candidate(possible = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 1\n"}, "metadata": {"canonical_parameter_names": ["possible"], "leetcode_dataset_entry_point": "Solution().minimumLevels", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumLevels(vector& possible) {", "container": "Solution", "callable": "minimumLevels", "parameters": [{"name": "possible", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3097, "task_id": "shortest-subarray-with-or-at-least-k-ii", "difficulty": "Medium", "problem_description": "You are given an array nums of non-negative integers and an integer k.\nAn array is called special if the bitwise OR of all of its elements is at least k.\nReturn the length of the shortest special non-empty subarray of nums, or return -1 if no special subarray exists.\n \nExample 1:\n\nInput: nums = [1,2,3], k = 2\nOutput: 1\nExplanation:\nThe subarray [3] has OR value of 3. Hence, we return 1.\n\nExample 2:\n\nInput: nums = [2,1,8], k = 10\nOutput: 3\nExplanation:\nThe subarray [2,1,8] has OR value of 11. Hence, we return 3.\n\nExample 3:\n\nInput: nums = [1,2], k = 0\nOutput: 1\nExplanation:\nThe subarray [1] has OR value of 1. Hence, we return 1.\n\n \nConstraints:\n\n1 <= nums.length <= 2 * 105\n0 <= nums[i] <= 109\n0 <= k <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 5, 5, 5, 5],k = 5) == 1\n assert candidate(nums = [0, 0, 0],k = 1) == -1\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 10) == 2\n assert candidate(nums = [5, 5, 5, 5],k = 5) == 1\n assert candidate(nums = [5, 3, 1, 1, 1],k = 8) == -1\n assert candidate(nums = [1, 2],k = 0) == 1\n assert candidate(nums = [1, 2, 3],k = 2) == 1\n assert candidate(nums = [3, 5, 7, 9],k = 15) == 2\n assert candidate(nums = [1, 0, 1, 0, 1],k = 1) == 1\n assert candidate(nums = [1000000000, 500000000, 250000000],k = 1500000000) == -1\n assert candidate(nums = [1, 3, 7, 15, 31],k = 31) == 1\n assert candidate(nums = [7, 10, 4, 3, 15],k = 14) == 1\n assert candidate(nums = [1, 1, 1, 1],k = 1) == 1\n assert candidate(nums = [3, 3, 3, 3],k = 3) == 1\n assert candidate(nums = [5, 9, 1, 8],k = 15) == -1\n assert candidate(nums = [4, 7, 1, 9, 3, 8],k = 11) == 2\n assert candidate(nums = [1, 3, 4, 8, 16],k = 15) == 1\n assert candidate(nums = [1000000000],k = 1000000000) == 1\n assert candidate(nums = [30, 1, 4, 3],k = 31) == 2\n assert candidate(nums = [0, 0, 0, 0],k = 1) == -1\n assert candidate(nums = [2, 1, 8],k = 10) == 3\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 7) == 1\n assert candidate(nums = [1073741824],k = 1073741824) == 1\n assert candidate(nums = [1, 1, 1, 1, 1],k = 1) == 1\n assert candidate(nums = [1024, 512, 256],k = 1024) == 1\n assert candidate(nums = [3, 5, 7, 9, 11],k = 15) == 2\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 1023) == -1\n assert candidate(nums = [31, 15, 7, 3, 1],k = 31) == 1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],k = 1048575) == 20\n assert candidate(nums = [31, 15, 7, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 31) == 1\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 1) == 1\n assert candidate(nums = [255, 127, 63, 31, 15, 7, 3, 1, 0, 0, 0, 0, 0, 0, 0],k = 255) == 1\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023],k = 511) == 1\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 45) == 1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],k = 32767) == 15\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023],k = 512) == 1\n assert candidate(nums = [128, 64, 32, 16, 8, 4, 2, 1],k = 255) == 8\n assert candidate(nums = [987654321, 876543210, 765432109, 654321098, 543210987, 432109876, 321098765, 210987654, 109876543, 98765432],k = 987654321) == 1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],k = 16383) == 1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],k = 1023) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 0) == 1\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575],k = 1048575) == 1\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 1) == 1\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048],k = 2047) == 1\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996],k = 1000000000) == 1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 1) == 1\n assert candidate(nums = [8, 4, 2, 1, 16, 8, 4, 2, 1, 32, 16, 8, 4, 2, 1],k = 31) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 20) == 1\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71],k = 100) == 2\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000],k = 15625000) == 1\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 30) == 2\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],k = 2047) == 11\n assert candidate(nums = [1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048],k = 2097151) == -1\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],k = 1023) == 1\n assert candidate(nums = [2147483647, 1073741823, 536870911, 268435455, 134217727],k = 4000000000) == -1\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125],k = 1000000000) == 1\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000],k = 1000000000) == 1\n assert candidate(nums = [31, 15, 7, 3, 1, 63, 127, 255, 511, 1023],k = 1023) == 1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],k = 1023) == 10\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125],k = 1953125) == 1\n assert candidate(nums = [1023, 1023, 1023, 1023, 1023],k = 1023) == 1\n assert candidate(nums = [123456789, 987654321, 111111111, 222222222, 333333333],k = 123456789) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 1\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767],k = 32767) == 1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 1) == 1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 1) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2147483647],k = 2147483647) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1023) == -1\n assert candidate(nums = [256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072],k = 262143) == -1\n assert candidate(nums = [9, 5, 3, 7, 11, 13, 17, 19, 23, 29],k = 50) == -1\n assert candidate(nums = [31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1],k = 31) == 1\n assert candidate(nums = [128, 64, 32, 16, 8, 4, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 255) == 8\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],k = 1048576) == -1\n assert candidate(nums = [1048575, 524287, 262143, 131071, 65535, 32767, 16383, 8191, 4095, 2047],k = 1048575) == 1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],k = 2047) == 11\n assert candidate(nums = [500000000, 500000000, 500000000, 500000000, 500000000, 500000000, 500000000],k = 500000000) == 1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048],k = 2048) == 1\n assert candidate(nums = [255, 255, 255, 255, 255, 255, 255, 255, 255, 255],k = 255) == 1\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],k = 1000000000) == 1\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],k = 1023) == 1\n assert candidate(nums = [2147483647, 2147483647, 2147483647, 2147483647, 2147483647],k = 2147483647) == 1\n assert candidate(nums = [31, 15, 7, 3, 1, 0, 0, 0, 0, 0],k = 31) == 1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 1) == -1\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047],k = 2047) == 1\n assert candidate(nums = [128, 64, 32, 16, 8, 4, 2, 1, 256, 128, 64, 32, 16, 8, 4, 2, 1, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],k = 1023) == 10\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 1) == 1\n assert candidate(nums = [256, 128, 64, 32, 16, 8, 4, 2, 1],k = 511) == 9\n assert candidate(nums = [31, 15, 7, 3, 1],k = 31) == 1\n assert candidate(nums = [1000000000, 1000000000, 1000000000],k = 1000000000) == 1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 1) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 500) == -1\n assert candidate(nums = [31, 7, 5, 9, 20, 15, 8, 2],k = 25) == 1\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 2) == 1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0],k = 1) == -1\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().minimumSubarrayLength", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumSubarrayLength(vector& nums, int k) {", "container": "Solution", "callable": "minimumSubarrayLength", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3098, "task_id": "find-the-sum-of-subsequence-powers", "difficulty": "Hard", "problem_description": "You are given an integer array nums of length n, and a positive integer k.\nThe power of a subsequence is defined as the minimum absolute difference between any two elements in the subsequence.\nReturn the sum of powers of all subsequences of nums which have length equal to k.\nSince the answer may be large, return it modulo 109 + 7.\n \nExample 1:\n\nInput: nums = [1,2,3,4], k = 3\nOutput: 4\nExplanation:\nThere are 4 subsequences in nums which have length 3: [1,2,3], [1,3,4], [1,2,4], and [2,3,4]. The sum of powers is |2 - 3| + |3 - 4| + |2 - 1| + |3 - 4| = 4.\n\nExample 2:\n\nInput: nums = [2,2], k = 2\nOutput: 0\nExplanation:\nThe only subsequence in nums which has length 2 is [2,2]. The sum of powers is |2 - 2| = 0.\n\nExample 3:\n\nInput: nums = [4,3,-1], k = 2\nOutput: 10\nExplanation:\nThere are 3 subsequences in nums which have length 2: [4,3], [4,-1], and [3,-1]. The sum of powers is |4 - 3| + |4 - (-1)| + |3 - (-1)| = 10.\n\n \nConstraints:\n\n2 <= n == nums.length <= 50\n-108 <= nums[i] <= 108 \n2 <= k <= n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [-10, -20, -30, -40, -50],k = 3) == 110\n assert candidate(nums = [100, 200, 300, 400, 500, 600],k = 6) == 100\n assert candidate(nums = [1, 2, 3, 4],k = 3) == 4\n assert candidate(nums = [1, 1, 1, 1, 1],k = 3) == 0\n assert candidate(nums = [1, 3, 6, 10, 15],k = 5) == 2\n assert candidate(nums = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5],k = 6) == 463\n assert candidate(nums = [100, -100, 200, -200],k = 2) == 1400\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 25) == 0\n assert candidate(nums = [-100000000, -200000000, -300000000, -400000000, -500000000],k = 4) == 500000000\n assert candidate(nums = [100000000, -100000000, 50000000, -50000000],k = 3) == 200000000\n assert candidate(nums = [-10, -5, 0, 5, 10],k = 3) == 55\n assert candidate(nums = [4, 3, -1],k = 2) == 10\n assert candidate(nums = [0, 0, 0, 0, 0],k = 2) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11],k = 5) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 258\n assert candidate(nums = [1, 3, 5, 7, 9],k = 3) == 22\n assert candidate(nums = [2, 2],k = 2) == 0\n assert candidate(nums = [1, 1, 1, 1, 1],k = 2) == 0\n assert candidate(nums = [1, 5, 9, 13, 17],k = 4) == 20\n assert candidate(nums = [10, 20, 30, 40, 50],k = 5) == 10\n assert candidate(nums = [5, 5, 5, 5, 5, 5],k = 3) == 0\n assert candidate(nums = [5, 5, 5, 5, 5],k = 2) == 0\n assert candidate(nums = [10, 20, 30, 40, 50],k = 4) == 50\n assert candidate(nums = [1, 5, 8, 10, 12],k = 4) == 11\n assert candidate(nums = [-10, -5, 0, 5, 10],k = 4) == 25\n assert candidate(nums = [100000000, 200000000, -100000000, -200000000],k = 3) == 400000000\n assert candidate(nums = [10, 20, 30, 40, 50],k = 3) == 110\n assert candidate(nums = [-3, -2, -1, 0, 1, 2, 3],k = 5) == 21\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],k = 15) == 310235072\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 2580\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4) == 246\n assert candidate(nums = [100000000, 200000000, 300000000, 400000000, 500000000],k = 3) == 99999993\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3],k = 3) == 27\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 6) == 2100\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],k = 10) == 184792\n assert candidate(nums = [-100, -50, 0, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600],k = 8) == 321800\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],k = 3) == 946502064\n assert candidate(nums = [-100, -90, -80, -70, -60, -50, -40, -30, -20, -10],k = 7) == 1200\n assert candidate(nums = [-100000000, -99999999, -99999998, -99999997, -99999996, -99999995, -99999994, -99999993, -99999992],k = 5) == 127\n assert candidate(nums = [-100, -99, -98, -97, -96, -95, -94, -93, -92, -91, -90, -89, -88, -87, -86, -85, -84, -83, -82, -81],k = 15) == 15504\n assert candidate(nums = [100000000, 100000001, 100000002, 100000003, 100000004],k = 4) == 5\n assert candidate(nums = [100000000, 99999999, 99999998, 99999997, 99999996],k = 4) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 12) == 125970\n assert candidate(nums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 11) == 352717\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],k = 4) == 2460\n assert candidate(nums = [-50, -40, -30, -20, -10, 0, 10, 20, 30, 40, 50],k = 6) == 4630\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89],k = 5) == 753\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 7) == 1200\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100, -110, -120, -130, -140, -150, -160, -170, -180, -190, -200],k = 15) == 155040\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130],k = 15) == 300540331\n assert candidate(nums = [5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5],k = 7) == 330\n assert candidate(nums = [-100000000, -99999999, -99999998, -99999997, -99999996],k = 3) == 11\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],k = 10) == 60795594\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 20) == 53130\n assert candidate(nums = [0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9],k = 10) == 92379\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],k = 5) == 2580\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],k = 10) == 300300\n assert candidate(nums = [10000, 10001, 10002, 10003, 10004, 10005, 10006, 10007, 10008, 10009, 10010, 10011, 10012, 10013, 10014],k = 12) == 455\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],k = 6) == 2100\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000],k = 5) == 677430\n assert candidate(nums = [100000000, 50000000, 25000000, 12500000, 6250000, 3125000, 1562500, 781250, 390625, 195312],k = 5) == 370703188\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130],k = 7) == 17170\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 10) == 44999097\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 4) == 2460\n assert candidate(nums = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 15) == 7726160\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 15) == 155040\n assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50, 60, 60, 70, 70, 80, 80, 90, 90, 100, 100],k = 7) == 153600\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 20) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 7) == 120\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 25) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 25) == 0\n assert candidate(nums = [-50000000, -25000000, 0, 25000000, 50000000, 75000000, 100000000],k = 5) == 525000000\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 10) == 30030\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],k = 6) == 874\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29],k = 20) == 30045015\n assert candidate(nums = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140],k = 8) == 64360\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 18) == 86493225\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 7) == 6471\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 25) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 15) == 155117536\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 10) == 1024\n assert candidate(nums = [-50, -49, -48, -47, -46, -45, -44, -43, -42, -41, -40, -39, -38, -37, -36, -35, -34, -33, -32, -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10],k = 20) == 128935568\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35],k = 15) == 16\n assert candidate(nums = [1, 5, 10, 20, 30, 50, 70, 100, 150, 200, 300, 500, 700, 1000, 1500, 2000, 3000, 5000, 7000, 10000],k = 10) == 2513422\n assert candidate(nums = [-100, -90, -80, -70, -60, -50, -40, -30, -20, -10],k = 4) == 2460\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],k = 18) == 19000\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 0\n assert candidate(nums = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 7) == 1524\n assert candidate(nums = [100000000, 50000000, 0, -50000000, -100000000, 25000000, 75000000],k = 4) == 74999993\n assert candidate(nums = [100000000, 50000000, 25000000, 12500000, 6250000, 3125000, 1562500],k = 4) == 218750000\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 12) == 629850\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97],k = 10) == 7286383\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24],k = 15) == 15504\n assert candidate(nums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 16) == 20349\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14, 15],k = 8) == 22673\n assert candidate(nums = [-5, -10, -15, -20, -25, -30, -35, -40, -45, -50, -55, -60, -65, -70, -75, -80, -85, -90, -95, -100],k = 10) == 923835\n assert candidate(nums = [100000000, 90000000, 80000000, 70000000, 60000000, 50000000, 40000000, 30000000, 20000000, 10000000],k = 5) == 579999986\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 258\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41],k = 15) == 108528\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89],k = 6) == 430\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2],k = 25) == 0\n assert candidate(nums = [-100000000, -99999999, -99999998, -99999997, -99999996, -99999995, -99999994, -99999993, -99999992, -99999991],k = 7) == 120\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 20) == 30045015\n assert candidate(nums = [9, 1, 8, 2, 7, 3, 6, 4, 5, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 12) == 125970\n assert candidate(nums = [100000000, 99999999, 99999998, 99999997, 99999996, 99999995, 99999994, 99999993, 99999992, 99999991],k = 8) == 45\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],k = 9) == 3865518\n assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50, 60, 60, 70, 70, 80, 80, 90, 90, 100, 100],k = 10) == 10240\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 184767\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],k = 25) == 605552908\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 10) == 3003\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],k = 11) == 167960\n assert candidate(nums = [100000000, 99999999, 99999998, 99999997, 99999996, 99999995, 99999994],k = 5) == 21\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20],k = 7) == 3162380\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 8) == 0\n assert candidate(nums = [100000000, -100000000, 0, 50000000, -50000000],k = 3) == 550000000\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71],k = 20) == 30045015\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 8) == 64360\n assert candidate(nums = [100000000, 100000000, 99999999, 99999998, 99999997],k = 3) == 7\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],k = 8) == 127867\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 15) == 77520\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().sumOfPowers", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int sumOfPowers(vector& nums, int k) {", "container": "Solution", "callable": "sumOfPowers", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3099, "task_id": "harshad-number", "difficulty": "Easy", "problem_description": "An integer divisible by the sum of its digits is said to be a Harshad number. You are given an integer x. Return the sum of the digits of x if x is a Harshad number, otherwise, return -1.\n \nExample 1:\n\nInput: x = 18\nOutput: 9\nExplanation:\nThe sum of digits of x is 9. 18 is divisible by 9. So 18 is a Harshad number and the answer is 9.\n\nExample 2:\n\nInput: x = 23\nOutput: -1\nExplanation:\nThe sum of digits of x is 5. 23 is not divisible by 5. So 23 is not a Harshad number and the answer is -1.\n\n \nConstraints:\n\n1 <= x <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(x = 50) == 5\n assert candidate(x = 23) == -1\n assert candidate(x = 10) == 1\n assert candidate(x = 18) == 9\n assert candidate(x = 1) == 1\n assert candidate(x = 90) == 9\n assert candidate(x = 57) == -1\n assert candidate(x = 99) == -1\n assert candidate(x = 81) == 9\n assert candidate(x = 45) == 9\n assert candidate(x = 13) == -1\n assert candidate(x = 100) == 1\n assert candidate(x = 12) == 3\n assert candidate(x = 54) == 9\n assert candidate(x = 234) == 9\n assert candidate(x = 621) == 9\n assert candidate(x = 111) == 3\n assert candidate(x = 72) == 9\n assert candidate(x = 42) == 6\n assert candidate(x = 153) == 9\n assert candidate(x = 216) == 9\n assert candidate(x = 990) == 18\n assert candidate(x = 135) == 9\n assert candidate(x = 132) == 6\n assert candidate(x = 201) == 3\n assert candidate(x = 27) == 9\n assert candidate(x = 729) == -1\n assert candidate(x = 303) == -1\n assert candidate(x = 513) == 9\n assert candidate(x = 981) == -1\n assert candidate(x = 450) == 9\n assert candidate(x = 70) == 7\n assert candidate(x = 270) == 9\n assert candidate(x = 999) == 27\n assert candidate(x = 108) == 9\n assert candidate(x = 36) == 9\n assert candidate(x = 200) == 2\n assert candidate(x = 756) == 18\n assert candidate(x = 801) == 9\n assert candidate(x = 342) == 9\n assert candidate(x = 49) == -1\n assert candidate(x = 144) == 9\n assert candidate(x = 810) == 9\n assert candidate(x = 405) == 9\n assert candidate(x = 300) == 3\n assert candidate(x = 504) == 9\n assert candidate(x = 180) == 9\n assert candidate(x = 369) == -1\n assert candidate(x = 75) == -1\n assert candidate(x = 900) == 9\n assert candidate(x = 123) == -1\n assert candidate(x = 198) == 18\n assert candidate(x = 63) == 9\n"}, "metadata": {"canonical_parameter_names": ["x"], "leetcode_dataset_entry_point": "Solution().sumOfTheDigitsOfHarshadNumber", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int sumOfTheDigitsOfHarshadNumber(int x) {", "container": "Solution", "callable": "sumOfTheDigitsOfHarshadNumber", "parameters": [{"name": "x", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3100, "task_id": "water-bottles-ii", "difficulty": "Medium", "problem_description": "You are given two integers numBottles and numExchange.\nnumBottles represents the number of full water bottles that you initially have. In one operation, you can perform one of the following operations:\n\nDrink any number of full water bottles turning them into empty bottles.\nExchange numExchange empty bottles with one full water bottle. Then, increase numExchange by one.\n\nNote that you cannot exchange multiple batches of empty bottles for the same value of numExchange. For example, if numBottles == 3 and numExchange == 1, you cannot exchange 3 empty water bottles for 3 full bottles.\nReturn the maximum number of water bottles you can drink.\n \nExample 1:\n\n\nInput: numBottles = 13, numExchange = 6\nOutput: 15\nExplanation: The table above shows the number of full water bottles, empty water bottles, the value of numExchange, and the number of bottles drunk.\n\nExample 2:\n\n\nInput: numBottles = 10, numExchange = 3\nOutput: 13\nExplanation: The table above shows the number of full water bottles, empty water bottles, the value of numExchange, and the number of bottles drunk.\n\n \nConstraints:\n\n1 <= numBottles <= 100 \n1 <= numExchange <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(numBottles = 10,numExchange = 3) == 13\n assert candidate(numBottles = 2,numExchange = 3) == 2\n assert candidate(numBottles = 13,numExchange = 6) == 15\n assert candidate(numBottles = 100,numExchange = 1) == 114\n assert candidate(numBottles = 5,numExchange = 5) == 6\n assert candidate(numBottles = 1,numExchange = 1) == 2\n assert candidate(numBottles = 20,numExchange = 4) == 24\n assert candidate(numBottles = 50,numExchange = 10) == 54\n assert candidate(numBottles = 1,numExchange = 100) == 1\n assert candidate(numBottles = 1,numExchange = 10) == 1\n assert candidate(numBottles = 99,numExchange = 2) == 112\n assert candidate(numBottles = 70,numExchange = 6) == 78\n assert candidate(numBottles = 60,numExchange = 2) == 70\n assert candidate(numBottles = 45,numExchange = 20) == 47\n assert candidate(numBottles = 60,numExchange = 8) == 66\n assert candidate(numBottles = 90,numExchange = 9) == 97\n assert candidate(numBottles = 80,numExchange = 8) == 87\n assert candidate(numBottles = 90,numExchange = 18) == 94\n assert candidate(numBottles = 75,numExchange = 15) == 79\n assert candidate(numBottles = 40,numExchange = 50) == 40\n assert candidate(numBottles = 30,numExchange = 2) == 37\n assert candidate(numBottles = 90,numExchange = 5) == 100\n assert candidate(numBottles = 55,numExchange = 8) == 60\n assert candidate(numBottles = 15,numExchange = 15) == 16\n assert candidate(numBottles = 40,numExchange = 7) == 44\n assert candidate(numBottles = 55,numExchange = 6) == 61\n assert candidate(numBottles = 80,numExchange = 3) == 91\n assert candidate(numBottles = 60,numExchange = 15) == 63\n assert candidate(numBottles = 60,numExchange = 7) == 66\n assert candidate(numBottles = 30,numExchange = 5) == 34\n assert candidate(numBottles = 80,numExchange = 10) == 86\n assert candidate(numBottles = 80,numExchange = 20) == 83\n assert candidate(numBottles = 95,numExchange = 5) == 105\n assert candidate(numBottles = 40,numExchange = 12) == 43\n assert candidate(numBottles = 40,numExchange = 25) == 41\n assert candidate(numBottles = 50,numExchange = 5) == 57\n assert candidate(numBottles = 85,numExchange = 4) == 95\n assert candidate(numBottles = 45,numExchange = 12) == 48\n assert candidate(numBottles = 25,numExchange = 3) == 30\n assert candidate(numBottles = 80,numExchange = 5) == 89\n assert candidate(numBottles = 45,numExchange = 6) == 50\n assert candidate(numBottles = 30,numExchange = 7) == 33\n assert candidate(numBottles = 7,numExchange = 8) == 7\n assert candidate(numBottles = 70,numExchange = 8) == 76\n assert candidate(numBottles = 75,numExchange = 5) == 84\n assert candidate(numBottles = 75,numExchange = 7) == 82\n assert candidate(numBottles = 85,numExchange = 5) == 94\n assert candidate(numBottles = 45,numExchange = 10) == 49\n assert candidate(numBottles = 30,numExchange = 30) == 31\n assert candidate(numBottles = 90,numExchange = 4) == 101\n assert candidate(numBottles = 40,numExchange = 30) == 41\n assert candidate(numBottles = 75,numExchange = 10) == 81\n assert candidate(numBottles = 100,numExchange = 2) == 113\n assert candidate(numBottles = 35,numExchange = 18) == 36\n assert candidate(numBottles = 55,numExchange = 12) == 59\n assert candidate(numBottles = 100,numExchange = 50) == 102\n assert candidate(numBottles = 8,numExchange = 4) == 10\n assert candidate(numBottles = 80,numExchange = 15) == 84\n assert candidate(numBottles = 60,numExchange = 20) == 62\n assert candidate(numBottles = 99,numExchange = 3) == 111\n assert candidate(numBottles = 99,numExchange = 20) == 103\n assert candidate(numBottles = 100,numExchange = 20) == 104\n assert candidate(numBottles = 3,numExchange = 3) == 4\n assert candidate(numBottles = 50,numExchange = 1) == 60\n assert candidate(numBottles = 70,numExchange = 25) == 72\n assert candidate(numBottles = 6,numExchange = 6) == 7\n assert candidate(numBottles = 65,numExchange = 12) == 69\n assert candidate(numBottles = 55,numExchange = 20) == 57\n assert candidate(numBottles = 25,numExchange = 2) == 31\n assert candidate(numBottles = 95,numExchange = 7) == 104\n assert candidate(numBottles = 45,numExchange = 2) == 53\n assert candidate(numBottles = 90,numExchange = 25) == 93\n assert candidate(numBottles = 95,numExchange = 15) == 100\n assert candidate(numBottles = 45,numExchange = 4) == 52\n assert candidate(numBottles = 99,numExchange = 9) == 107\n assert candidate(numBottles = 25,numExchange = 7) == 28\n assert candidate(numBottles = 30,numExchange = 3) == 36\n assert candidate(numBottles = 5,numExchange = 2) == 7\n assert candidate(numBottles = 60,numExchange = 3) == 69\n assert candidate(numBottles = 45,numExchange = 3) == 53\n assert candidate(numBottles = 25,numExchange = 9) == 27\n assert candidate(numBottles = 90,numExchange = 6) == 99\n assert candidate(numBottles = 90,numExchange = 10) == 97\n assert candidate(numBottles = 70,numExchange = 7) == 77\n assert candidate(numBottles = 90,numExchange = 15) == 95\n assert candidate(numBottles = 50,numExchange = 2) == 59\n"}, "metadata": {"canonical_parameter_names": ["numBottles", "numExchange"], "leetcode_dataset_entry_point": "Solution().maxBottlesDrunk", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxBottlesDrunk(int numBottles, int numExchange) {", "container": "Solution", "callable": "maxBottlesDrunk", "parameters": [{"name": "numBottles", "type": "int"}, {"name": "numExchange", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3101, "task_id": "count-alternating-subarrays", "difficulty": "Medium", "problem_description": "You are given a binary array nums.\nWe call a subarray alternating if no two adjacent elements in the subarray have the same value.\nReturn the number of alternating subarrays in nums.\n \nExample 1:\n\nInput: nums = [0,1,1,1]\nOutput: 5\nExplanation:\nThe following subarrays are alternating: [0], [1], [1], [1], and [0,1].\n\nExample 2:\n\nInput: nums = [1,0,1,0]\nOutput: 10\nExplanation:\nEvery subarray of the array is alternating. There are 10 possible subarrays that we can choose.\n\n \nConstraints:\n\n1 <= nums.length <= 105\nnums[i] is either 0 or 1.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [0, 0, 1, 1, 0, 0]) == 8\n assert candidate(nums = [0, 1, 0, 1, 0, 1]) == 21\n assert candidate(nums = [1, 0, 1, 0, 1]) == 15\n assert candidate(nums = [1, 1, 1, 1]) == 4\n assert candidate(nums = [1, 0, 0, 1, 0, 1, 1, 0]) == 16\n assert candidate(nums = [0, 1, 0, 1, 0]) == 15\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [0, 1]) == 3\n assert candidate(nums = [0, 0, 0, 0, 0]) == 5\n assert candidate(nums = [0, 1, 1, 1]) == 5\n assert candidate(nums = [1, 0]) == 3\n assert candidate(nums = [1, 0, 0, 1, 0, 1]) == 13\n assert candidate(nums = [1, 1, 0, 1, 0, 1]) == 16\n assert candidate(nums = [1, 1, 1, 1, 1]) == 5\n assert candidate(nums = [0]) == 1\n assert candidate(nums = [1, 0, 1, 0, 1, 0]) == 21\n assert candidate(nums = [0, 0, 0, 0]) == 4\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1]) == 36\n assert candidate(nums = [1, 1, 0, 0, 1, 1]) == 8\n assert candidate(nums = [0, 1, 1, 0, 1, 0]) == 13\n assert candidate(nums = [0, 0, 1, 0, 1, 0]) == 16\n assert candidate(nums = [1, 0, 1, 0]) == 10\n assert candidate(nums = [0, 1, 1, 0, 0, 1]) == 9\n assert candidate(nums = [1, 0, 0, 1, 1, 0, 0, 1, 1, 0]) == 15\n assert candidate(nums = [0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1]) == 33\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 66\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 120\n assert candidate(nums = [0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1]) == 27\n assert candidate(nums = [0, 1, 1, 0, 1, 1, 0, 1, 1, 0]) == 18\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0]) == 17\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 16\n assert candidate(nums = [1, 1, 0, 1, 0, 1, 0, 1, 1, 0]) == 32\n assert candidate(nums = [0, 1, 0, 1, 1, 0, 1, 0, 1]) == 25\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 91\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 16\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 253\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1]) == 29\n assert candidate(nums = [1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1]) == 19\n assert candidate(nums = [1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1]) == 34\n assert candidate(nums = [1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1]) == 14\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 22\n assert candidate(nums = [1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 84\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 19\n assert candidate(nums = [1, 1, 0, 0, 1, 0, 1, 1, 0]) == 17\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1]) == 28\n assert candidate(nums = [1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1]) == 18\n assert candidate(nums = [1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0]) == 18\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 105\n assert candidate(nums = [1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 106\n assert candidate(nums = [1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1]) == 48\n assert candidate(nums = [0, 1, 1, 0, 0, 1, 1, 0, 0, 1]) == 15\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 1, 0, 1, 0]) == 31\n assert candidate(nums = [0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 121\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 190\n assert candidate(nums = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == 29\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1]) == 15\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 528\n assert candidate(nums = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1]) == 11\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 0, 1, 0, 1]) == 31\n assert candidate(nums = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == 41\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 136\n assert candidate(nums = [0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1]) == 44\n assert candidate(nums = [1, 0, 1, 0, 0, 1, 0, 1, 0, 0]) == 26\n assert candidate(nums = [1, 1, 1, 1, 0, 0, 0, 0, 1, 1]) == 12\n assert candidate(nums = [1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 51\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 22\n assert candidate(nums = [1, 0, 1, 1, 0, 1, 0, 1, 0, 1]) == 34\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0]) == 19\n assert candidate(nums = [1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1]) == 46\n assert candidate(nums = [0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1]) == 48\n assert candidate(nums = [0, 1, 0, 1, 1, 0, 1, 0, 1, 1]) == 26\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 0, 0, 0, 1]) == 13\n assert candidate(nums = [1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1]) == 34\n assert candidate(nums = [1, 1, 0, 0, 1, 1, 0, 0]) == 11\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 136\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1]) == 49\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 210\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 55\n assert candidate(nums = [1, 1, 1, 1, 1, 0, 0, 0, 0, 0]) == 11\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 78\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 171\n assert candidate(nums = [1, 1, 1, 0, 0, 0, 1, 1, 1, 0]) == 13\n assert candidate(nums = [0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1]) == 35\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1]) == 33\n assert candidate(nums = [0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == 46\n assert candidate(nums = [1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1]) == 38\n assert candidate(nums = [0, 1, 0, 0, 1, 0, 1, 0, 0, 1]) == 24\n assert candidate(nums = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1]) == 14\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1]) == 19\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1]) == 18\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 351\n assert candidate(nums = [1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0]) == 52\n assert candidate(nums = [0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == 19\n assert candidate(nums = [0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0]) == 38\n assert candidate(nums = [0, 0, 1, 1, 1, 0, 1, 0, 0, 1]) == 18\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 325\n assert candidate(nums = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == 23\n assert candidate(nums = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0]) == 17\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 595\n assert candidate(nums = [0, 1, 1, 0, 1, 0, 1, 1, 0, 0]) == 22\n assert candidate(nums = [1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1]) == 19\n assert candidate(nums = [1, 1, 0, 0, 1, 1, 0, 0, 1]) == 13\n assert candidate(nums = [1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0]) == 15\n assert candidate(nums = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0]) == 19\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 55\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 210\n assert candidate(nums = [0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0]) == 44\n assert candidate(nums = [1, 0, 1, 1, 0, 1, 0, 0, 1, 0]) == 22\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0]) == 45\n assert candidate(nums = [0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1]) == 49\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().countAlternatingSubarrays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "long long countAlternatingSubarrays(vector& nums) {", "container": "Solution", "callable": "countAlternatingSubarrays", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "long long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3102, "task_id": "minimize-manhattan-distances", "difficulty": "Hard", "problem_description": "You are given an array points representing integer coordinates of some points on a 2D plane, where points[i] = [xi, yi].\nThe distance between two points is defined as their Manhattan distance.\nReturn the minimum possible value for maximum distance between any two points by removing exactly one point.\n \nExample 1:\n\nInput: points = [[3,10],[5,15],[10,2],[4,4]]\nOutput: 12\nExplanation:\nThe maximum distance after removing each point is the following:\n\nAfter removing the 0th point the maximum distance is between points (5, 15) and (10, 2), which is |5 - 10| + |15 - 2| = 18.\nAfter removing the 1st point the maximum distance is between points (3, 10) and (10, 2), which is |3 - 10| + |10 - 2| = 15.\nAfter removing the 2nd point the maximum distance is between points (5, 15) and (4, 4), which is |5 - 4| + |15 - 4| = 12.\nAfter removing the 3rd point the maximum distance is between points (5, 15) and (10, 2), which is |5 - 10| + |15 - 2| = 18.\n\n12 is the minimum possible maximum distance between any two points after removing exactly one point.\n\nExample 2:\n\nInput: points = [[1,1],[1,1],[1,1]]\nOutput: 0\nExplanation:\nRemoving any of the points results in the maximum distance between any two points of 0.\n\n \nConstraints:\n\n3 <= points.length <= 105\npoints[i].length == 2\n1 <= points[i][0], points[i][1] <= 108\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(points = [[1, 2], [2, 3], [3, 4], [4, 5]]) == 4\n assert candidate(points = [[1, 9], [9, 1], [2, 8], [8, 2], [3, 7], [7, 3], [4, 6], [6, 4], [5, 5]]) == 14\n assert candidate(points = [[1, 2], [4, 6], [8, 10], [15, 18]]) == 15\n assert candidate(points = [[1, 3], [2, 2], [3, 1], [6, 6], [7, 7], [8, 8]]) == 10\n assert candidate(points = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == 6\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 14\n assert candidate(points = [[1, 100000000], [100000000, 1], [1, 1], [100000000, 100000000]]) == 199999998\n assert candidate(points = [[1, 2], [4, 6], [8, 8], [7, 1]]) == 8\n assert candidate(points = [[100000000, 100000000], [200000000, 200000000], [300000000, 300000000]]) == 200000000\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]]) == 60\n assert candidate(points = [[1, 1], [1, 1], [1, 1]]) == 0\n assert candidate(points = [[1, 2], [4, 6], [8, 8], [7, 7], [3, 3], [5, 5]]) == 10\n assert candidate(points = [[3, 10], [5, 15], [10, 2], [4, 4]]) == 12\n assert candidate(points = [[1, 1], [10, 10], [1, 10], [10, 1], [1, 5], [5, 1], [5, 5], [2, 2], [8, 8], [3, 3], [7, 7], [4, 4], [6, 6], [9, 9], [2, 9], [8, 2], [3, 7], [7, 3], [4, 6], [6, 4]]) == 18\n assert candidate(points = [[10, 20], [30, 40], [50, 60], [70, 80], [90, 100], [110, 120], [130, 140], [150, 160]]) == 240\n assert candidate(points = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]]) == 0\n assert candidate(points = [[1, 1], [10, 1], [1, 10], [10, 10], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [2, 2], [3, 3], [4, 4]]) == 18\n assert candidate(points = [[1, 1], [1, 100000000], [100000000, 1], [100000000, 100000000], [50000000, 50000000], [50000000, 49999999], [50000000, 50000001], [49999999, 50000000], [50000001, 50000000]]) == 199999998\n assert candidate(points = [[1, 1], [10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100], [110, 110], [120, 120]]) == 218\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [100, 100], [200, 200], [300, 300], [400, 400], [500, 500]]) == 798\n assert candidate(points = [[50000000, 50000000], [1, 1], [100000000, 1], [1, 100000000], [100000000, 100000000]]) == 199999998\n assert candidate(points = [[1, 1], [100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [600, 600], [700, 700], [800, 800], [900, 900], [1000, 1000], [1, 1000], [1000, 1], [500, 500], [500, 1], [1, 500], [1000, 500], [500, 1000], [500, 1], [500, 1000]]) == 1998\n assert candidate(points = [[1, 1], [100000000, 1], [100000000, 100000000], [1, 100000000], [50000000, 50000000]]) == 199999998\n assert candidate(points = [[1, 1], [1, 100000000], [100000000, 1], [100000000, 100000000], [2, 2], [99999999, 99999999]]) == 199999998\n assert candidate(points = [[1, 100000000], [100000000, 1], [100000000, 100000000], [1, 1], [50000000, 50000000], [25000000, 25000000], [75000000, 75000000], [50000000, 1], [1, 50000000], [1, 75000000], [50000000, 100000000], [75000000, 100000000], [100000000, 50000000], [100000000, 25000000], [75000000, 25000000], [25000000, 50000000], [25000000, 75000000], [50000000, 25000000], [50000000, 75000000], [75000000, 50000000]]) == 199999998\n assert candidate(points = [[1, 2], [4, 6], [8, 8], [7, 7], [3, 3], [5, 5], [9, 11], [12, 14], [15, 15], [18, 18]]) == 27\n assert candidate(points = [[1, 100000000], [2, 100000000], [3, 100000000], [4, 100000000], [5, 100000000], [6, 100000000], [7, 100000000], [8, 100000000], [9, 100000000], [10, 100000000]]) == 8\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2], [8, 2], [9, 2], [10, 2]]) == 10\n assert candidate(points = [[1, 100000000], [100000000, 1], [1, 1], [100000000, 100000000], [50000000, 50000000], [60000000, 60000000], [40000000, 40000000]]) == 199999998\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [1, 10], [10, 1], [5, 5], [1, 5], [5, 1], [10, 10]]) == 18\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 16\n assert candidate(points = [[10, 10], [20, 10], [10, 20], [20, 20], [15, 15], [12, 12], [18, 18], [12, 18], [18, 12], [15, 20], [20, 15]]) == 20\n assert candidate(points = [[1, 100000000], [2, 99999999], [3, 99999998], [4, 99999997], [5, 99999996], [6, 99999995], [7, 99999994], [8, 99999993], [9, 99999992], [10, 99999991], [50, 95000001], [90, 91000001], [15, 98500001], [30, 97500001], [45, 96500001], [60, 95500001], [75, 94500001], [85, 93500001], [95, 92500001]]) == 7500093\n assert candidate(points = [[1, 1], [100000000, 1], [1, 100000000], [100000000, 100000000], [2, 2], [99999999, 2], [2, 99999999], [99999999, 99999999]]) == 199999998\n assert candidate(points = [[3, 3], [6, 6], [9, 9], [12, 12], [15, 15], [18, 18], [21, 21], [24, 24], [27, 27], [30, 30]]) == 48\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]) == 17\n assert candidate(points = [[100000000, 100000000], [50000000, 50000000], [25000000, 25000000], [12500000, 12500000], [6250000, 6250000], [3125000, 3125000], [1562500, 1562500], [781250, 781250], [390625, 390625], [195312, 195312]]) == 99609376\n assert candidate(points = [[1, 100000000], [100000000, 1], [50000000, 50000000], [25000000, 75000000], [75000000, 25000000], [100000000, 100000000], [1, 1], [100000000, 100000000], [1, 100000000], [100000000, 1]]) == 199999998\n assert candidate(points = [[1, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]]) == 160\n assert candidate(points = [[1, 99999999], [99999999, 1], [50000000, 50000000], [1, 50000000], [50000000, 1], [99999999, 50000000], [50000000, 99999999], [1, 1], [99999999, 99999999], [50000000, 50000000]]) == 199999996\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [1, 20], [1, 21], [1, 22], [1, 23], [1, 24], [1, 25], [1, 26], [1, 27], [1, 28], [1, 29], [1, 30], [1, 31], [1, 32], [1, 33], [1, 34], [1, 35], [1, 36], [1, 37], [1, 38], [1, 39], [1, 40], [1, 41], [1, 42], [1, 43], [1, 44], [1, 45], [1, 46], [1, 47], [1, 48], [1, 49], [1, 50], [100000000, 100000000]]) == 49\n assert candidate(points = [[1, 1], [10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]]) == 178\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]]) == 26\n assert candidate(points = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20], [21, 22], [23, 24], [25, 26], [27, 28], [29, 30], [31, 32], [33, 34], [35, 36], [37, 38], [39, 40], [41, 42], [43, 44], [45, 46], [47, 48], [49, 50], [51, 52], [53, 54], [55, 56], [57, 58], [59, 60], [61, 62], [63, 64], [65, 66], [67, 68], [69, 70]]) == 132\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5]]) == 6\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [1, 20]]) == 18\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [50, 50], [90, 90], [15, 15], [30, 30], [45, 45], [60, 60], [75, 75], [85, 85], [95, 95]]) == 178\n assert candidate(points = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]]) == 0\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20], [21, 21], [22, 22], [23, 23], [24, 24], [25, 25]]) == 46\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5]]) == 6\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 5], [5, 1], [3, 1], [1, 3], [3, 5], [5, 3]]) == 8\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20], [100, 100]]) == 38\n assert candidate(points = [[50000000, 1], [50000000, 2], [50000000, 3], [50000000, 4], [50000000, 5], [50000000, 6], [50000000, 7], [50000000, 8], [50000000, 9], [50000000, 10]]) == 8\n assert candidate(points = [[1, 1], [100000000, 100000000], [50000000, 50000000], [50000001, 50000001], [49999999, 49999999], [100000000, 100000001], [100000001, 100000000], [100000001, 100000001]]) == 100000004\n assert candidate(points = [[1, 1], [100000000, 1], [1, 100000000], [100000000, 100000000], [50000000, 50000000]]) == 199999998\n assert candidate(points = [[1, 1], [1, 2], [2, 1], [2, 2], [1, 3], [2, 3], [3, 1], [3, 2], [1, 4], [2, 4], [3, 4], [4, 1], [4, 2], [4, 3], [4, 4], [1, 5], [2, 5], [3, 5], [4, 5], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5]]) == 8\n assert candidate(points = [[1, 1], [1, 10], [10, 1], [10, 10], [5, 5], [5, 1], [1, 5], [10, 5], [5, 10], [5, 1]]) == 18\n assert candidate(points = [[1, 1], [1, 2], [2, 1], [2, 2], [1, 3], [3, 1], [2, 3], [3, 2], [1, 4], [4, 1], [2, 4], [4, 2], [3, 3], [1, 5], [5, 1], [2, 5], [5, 2], [3, 4], [4, 3], [3, 5], [5, 3], [4, 4], [4, 5], [5, 4]]) == 7\n assert candidate(points = [[1, 100], [2, 200], [3, 300], [4, 400], [5, 500], [6, 600], [7, 700], [8, 800], [9, 900], [10, 1000]]) == 808\n assert candidate(points = [[1, 1], [100000000, 100000000], [50000000, 50000000], [25000000, 25000000], [75000000, 75000000]]) == 149999998\n assert candidate(points = [[1, 1], [1, 100000000], [100000000, 1], [100000000, 100000000], [50000000, 50000000]]) == 199999998\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90]]) == 140\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3], [10, 10], [10, 11], [11, 10], [11, 11]]) == 19\n assert candidate(points = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16]]) == 26\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20]]) == 36\n assert candidate(points = [[1, 1], [1, 10], [1, 100], [1, 1000], [1, 10000], [1, 100000], [1, 1000000], [1, 10000000], [1, 100000000], [1, 1000000000]]) == 99999999\n assert candidate(points = [[1, 1], [100000000, 100000000], [50000000, 50000000], [25000000, 25000000], [75000000, 75000000], [12500000, 12500000], [87500000, 87500000], [99999999, 99999999], [1, 99999999], [99999999, 1]]) == 199999996\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20]]) == 36\n assert candidate(points = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [1, 1], [10, 10], [20, 20], [30, 30], [40, 40], [50, 50]]) == 90\n assert candidate(points = [[1, 1], [100000000, 100000000], [50000000, 50000000], [25000000, 25000000], [75000000, 75000000], [12500000, 12500000], [87500000, 87500000]]) == 174999998\n assert candidate(points = [[2, 3], [5, 7], [11, 15], [14, 17], [18, 21], [22, 25], [26, 29], [30, 33], [34, 37], [38, 41]]) == 66\n assert candidate(points = [[1, 2], [2, 1], [3, 4], [4, 3], [5, 6], [6, 5], [7, 8], [8, 7], [9, 10], [10, 9], [11, 12], [12, 11]]) == 20\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [10, 10], [10, 1], [10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8], [10, 9]]) == 18\n assert candidate(points = [[100000000, 1], [1, 100000000], [50000000, 50000000], [1, 1], [100000000, 100000000], [2, 2], [99999999, 99999999]]) == 199999998\n assert candidate(points = [[1, 1], [100000000, 1], [1, 100000000], [100000000, 100000000], [50000000, 50000000], [60000000, 60000000], [70000000, 70000000], [80000000, 80000000], [90000000, 90000000]]) == 199999998\n assert candidate(points = [[1, 2], [2, 4], [3, 6], [4, 8], [5, 10], [6, 12], [7, 14], [8, 16], [9, 18], [10, 20], [11, 22], [12, 24], [13, 26], [14, 28], [15, 30], [16, 32], [17, 34], [18, 36], [19, 38], [20, 40], [21, 42], [22, 44], [23, 46], [24, 48], [25, 50], [26, 52], [27, 54], [28, 56], [29, 58], [30, 60], [31, 62], [32, 64], [33, 66], [34, 68], [35, 70], [36, 72], [37, 74], [38, 76], [39, 78], [40, 80], [41, 82], [42, 84], [43, 86], [44, 88], [45, 90], [46, 92], [47, 94], [48, 96], [49, 98], [50, 100]]) == 144\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]) == 8\n assert candidate(points = [[3, 3], [6, 6], [9, 9], [12, 12], [15, 15], [18, 18], [21, 21], [24, 24], [27, 27], [30, 30], [33, 33], [36, 36], [39, 39], [42, 42], [45, 45], [48, 48], [51, 51], [54, 54], [57, 57], [60, 60]]) == 108\n assert candidate(points = [[1, 1], [100000000, 1], [1, 100000000], [100000000, 100000000], [50000000, 50000000], [25000000, 25000000], [75000000, 75000000], [37500000, 37500000], [62500000, 62500000], [87500000, 87500000]]) == 199999998\n assert candidate(points = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]]) == 0\n assert candidate(points = [[5, 5], [10, 10], [15, 15], [20, 20], [25, 25], [30, 30], [35, 35], [40, 40], [45, 45], [50, 50], [55, 55], [60, 60], [65, 65], [70, 70], [75, 75], [80, 80], [85, 85], [90, 90], [95, 95], [100, 100]]) == 180\n assert candidate(points = [[1, 1], [1, 2], [2, 1], [2, 2], [100000000, 100000000], [100000000, 99999999], [99999999, 100000000], [99999999, 99999999]]) == 199999997\n assert candidate(points = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == 16\n assert candidate(points = [[50000000, 50000000], [100000000, 100000000], [50000000, 1], [1, 50000000], [99999999, 99999999], [1, 1], [99999999, 1], [1, 99999999]]) == 199999996\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [100000000, 100000000]]) == 18\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 16\n assert candidate(points = [[50000000, 50000000], [49999999, 49999999], [50000001, 50000001], [50000002, 50000002], [50000003, 50000003], [50000004, 50000004], [50000005, 50000005], [50000006, 50000006], [50000007, 50000007], [50000008, 50000008], [50000009, 50000009]]) == 18\n assert candidate(points = [[1, 100000000], [100000000, 1], [1, 1], [100000000, 100000000], [2, 2], [50, 50], [100, 100]]) == 199999998\n assert candidate(points = [[1, 100000000], [2, 99999999], [3, 99999998], [100000000, 1], [99999999, 2], [99999998, 3]]) == 199999996\n assert candidate(points = [[50000000, 50000000], [50000000, 40000000], [50000000, 30000000], [50000000, 20000000], [50000000, 10000000], [40000000, 50000000], [30000000, 50000000], [20000000, 50000000], [10000000, 50000000]]) == 70000000\n assert candidate(points = [[1, 1], [100000000, 1], [100000000, 100000000], [1, 100000000], [50000000, 50000000], [25000000, 25000000]]) == 199999998\n assert candidate(points = [[1, 100000000], [2, 99999998], [3, 99999996], [100000000, 1], [99999998, 2], [99999996, 3], [50000000, 50000000], [60000000, 60000000], [70000000, 70000000]]) == 199999995\n assert candidate(points = [[1, 1], [1, 100000000], [100000000, 1], [100000000, 100000000], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 199999998\n assert candidate(points = [[1, 2], [1, 4], [1, 6], [1, 8], [1, 10], [2, 1], [2, 3], [2, 5], [2, 7], [2, 9], [3, 1], [3, 3], [3, 5], [3, 7], [3, 9], [4, 1], [4, 3], [4, 5], [4, 7], [4, 9]]) == 10\n assert candidate(points = [[1, 1], [2, 3], [4, 6], [8, 12], [16, 24], [32, 48], [64, 96], [128, 192], [256, 384], [512, 768]]) == 638\n assert candidate(points = [[100000000, 100000000], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == 8\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60]]) == 80\n assert candidate(points = [[1000000, 1000000], [2000000, 2000000], [3000000, 3000000]]) == 2000000\n assert candidate(points = [[5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [1, 1], [2, 2], [3, 3], [4, 4], [10, 10]]) == 16\n assert candidate(points = [[1, 1], [100000000, 100000000], [50000000, 50000000]]) == 99999998\n assert candidate(points = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12]]) == 16\n assert candidate(points = [[1, 2], [4, 6], [8, 8], [7, 9], [3, 5]]) == 8\n assert candidate(points = [[1, 2], [4, 6], [8, 3], [3, 1], [5, 5]]) == 7\n assert candidate(points = [[100000000, 100000000], [1, 1], [2, 2]]) == 2\n assert candidate(points = [[100000000, 100000000], [1, 1], [50000000, 50000000]]) == 99999998\n assert candidate(points = [[1, 2], [2, 1], [3, 4], [4, 3], [5, 6], [6, 5]]) == 8\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [100, 100], [200, 200]]) == 198\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [1, 10]]) == 14\n assert candidate(points = [[1, 99999999], [99999999, 1], [49999999, 50000000], [50000000, 49999999]]) == 99999999\n assert candidate(points = [[1, 2], [4, 6], [8, 8], [7, 7], [10, 10]]) == 10\n assert candidate(points = [[1, 1], [2, 2], [1, 2], [2, 1], [3, 3]]) == 2\n assert candidate(points = [[5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12]]) == 12\n assert candidate(points = [[1, 10], [10, 1], [5, 5], [3, 3], [8, 8], [2, 2], [7, 7], [4, 4], [6, 6], [9, 9]]) == 14\n assert candidate(points = [[1, 2], [4, 6], [8, 3], [3, 1], [7, 9]]) == 8\n assert candidate(points = [[5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [1, 1], [2, 2], [3, 3], [4, 4]]) == 14\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == 6\n assert candidate(points = [[5, 5], [5, 10], [10, 5], [10, 10], [15, 15]]) == 10\n assert candidate(points = [[5, 5], [10, 10], [15, 15], [20, 20], [25, 25]]) == 30\n assert candidate(points = [[1, 2], [4, 6], [7, 8], [2, 1], [5, 5]]) == 7\n assert candidate(points = [[1, 2], [4, 6], [5, 3], [3, 1], [7, 5]]) == 7\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [100000000, 100000000]]) == 8\n assert candidate(points = [[100000000, 100000000], [1, 1], [50000000, 50000000], [99999999, 99999999]]) == 100000000\n assert candidate(points = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 14\n assert candidate(points = [[100000000, 1], [2, 100000000], [100000000, 100000000]]) == 99999998\n assert candidate(points = [[1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1]]) == 14\n assert candidate(points = [[5, 5], [10, 10], [15, 15], [20, 20], [25, 25], [30, 30]]) == 40\n assert candidate(points = [[1, 100000000], [100000000, 1], [100000000, 100000000], [1, 1]]) == 199999998\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [100000000, 100000000], [5, 5]]) == 8\n assert candidate(points = [[1, 100000000], [100000000, 1], [50000000, 50000000], [25000000, 75000000]]) == 99999999\n assert candidate(points = [[1, 2], [4, 6], [7, 8], [2, 10], [9, 2]]) == 12\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [100000000, 100000000], [4, 4], [5, 5]]) == 8\n assert candidate(points = [[1, 2], [3, 4], [5, 6], [7, 8]]) == 8\n assert candidate(points = [[100000000, 100000000], [1, 1], [2, 2], [3, 3]]) == 4\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16]]) == 28\n assert candidate(points = [[1, 5], [2, 3], [3, 8], [4, 2], [5, 7]]) == 7\n assert candidate(points = [[1, 2], [4, 6], [8, 8], [7, 7], [3, 3]]) == 10\n assert candidate(points = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]]) == 14\n assert candidate(points = [[1, 1], [100000000, 100000000], [2, 2], [3, 3], [4, 4], [5, 5]]) == 8\n assert candidate(points = [[100000000, 100000000], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 16\n assert candidate(points = [[1, 2], [4, 6], [8, 8], [7, 4], [6, 1]]) == 8\n assert candidate(points = [[1, 1], [2, 2], [3, 1], [2, 3], [1, 2], [2, 1]]) == 3\n assert candidate(points = [[5, 5], [6, 6], [7, 7], [8, 8], [1, 1], [2, 2], [3, 3], [4, 4]]) == 12\n assert candidate(points = [[100000000, 100000000], [1, 1], [2, 2], [3, 3], [4, 4]]) == 6\n assert candidate(points = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70]]) == 80\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4]]) == 4\n assert candidate(points = [[1, 2], [4, 6], [5, 3], [2, 8]]) == 7\n assert candidate(points = [[1, 2], [4, 6], [5, 3], [3, 1], [8, 9]]) == 7\n assert candidate(points = [[1, 2], [4, 6], [7, 8], [2, 1], [5, 5], [8, 4]]) == 9\n assert candidate(points = [[1, 2], [4, 6], [5, 1], [8, 3], [3, 8], [7, 7], [9, 4]]) == 10\n assert candidate(points = [[1, 3], [2, 5], [5, 8], [6, 7], [8, 10], [9, 12]]) == 14\n assert candidate(points = [[1, 1], [2, 2], [100000000, 100000000], [3, 3], [4, 4], [5, 5]]) == 8\n assert candidate(points = [[100000, 100000], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == 8\n assert candidate(points = [[1, 99999999], [99999999, 1], [50000000, 50000000], [25000000, 25000000], [75000000, 75000000]]) == 100000000\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]]) == 10\n assert candidate(points = [[1, 100000000], [100000000, 1], [1, 1], [100000000, 100000000], [50000000, 50000000]]) == 199999998\n"}, "metadata": {"canonical_parameter_names": ["points"], "leetcode_dataset_entry_point": "Solution().minimumDistance", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumDistance(vector>& points) {", "container": "Solution", "callable": "minimumDistance", "parameters": [{"name": "points", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3105, "task_id": "longest-strictly-increasing-or-strictly-decreasing-subarray", "difficulty": "Easy", "problem_description": "You are given an array of integers nums. Return the length of the longest subarray of nums which is either strictly increasing or strictly decreasing.\n \nExample 1:\n\nInput: nums = [1,4,3,3,2]\nOutput: 2\nExplanation:\nThe strictly increasing subarrays of nums are [1], [2], [3], [3], [4], and [1,4].\nThe strictly decreasing subarrays of nums are [1], [2], [3], [3], [4], [3,2], and [4,3].\nHence, we return 2.\n\nExample 2:\n\nInput: nums = [3,3,3,3]\nOutput: 1\nExplanation:\nThe strictly increasing subarrays of nums are [3], [3], [3], and [3].\nThe strictly decreasing subarrays of nums are [3], [3], [3], and [3].\nHence, we return 1.\n\nExample 3:\n\nInput: nums = [3,2,1]\nOutput: 3\nExplanation:\nThe strictly increasing subarrays of nums are [3], [2], and [1].\nThe strictly decreasing subarrays of nums are [3], [2], [1], [3,2], [2,1], and [3,2,1].\nHence, we return 3.\n\n \nConstraints:\n\n1 <= nums.length <= 50\n1 <= nums[i] <= 50\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 3, 5, 4, 7, 8, 6, 9]) == 3\n assert candidate(nums = [1, 2, 2, 3, 4, 5]) == 4\n assert candidate(nums = [10, 9, 4, 3, 3, 2, 1]) == 4\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(nums = [3, 3, 3, 3]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [10, 9, 4, 3, 5, 7, 6, 8, 1]) == 4\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [1, 3, 2, 4, 3, 5]) == 2\n assert candidate(nums = [1, 3, 5, 4, 7]) == 3\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 4, 3, 2, 1]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [4, 5, 6, 3, 2, 1, 2, 3]) == 4\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 5, 6]) == 4\n assert candidate(nums = [1, 4, 3, 3, 2]) == 2\n assert candidate(nums = [1, 3, 5, 4, 2]) == 3\n assert candidate(nums = [3, 2, 1]) == 3\n assert candidate(nums = [4, 3, 3, 2, 1]) == 3\n assert candidate(nums = [5, 4, 3, 2, 1]) == 5\n assert candidate(nums = [1, 3, 2, 4, 3]) == 2\n assert candidate(nums = [1, 2, 2, 3, 4]) == 3\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3]) == 3\n assert candidate(nums = [1, 2, 3, 2, 1]) == 3\n assert candidate(nums = [2, 2, 2, 2, 2]) == 1\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4]) == 2\n assert candidate(nums = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1]) == 5\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1]) == 6\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 6, 7, 8, 9]) == 6\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9]) == 8\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9]) == 8\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 2\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 3, 4, 5, 6, 7, 8, 9]) == 8\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9]) == 2\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 2\n assert candidate(nums = [3, 2, 1, 2, 3, 4, 5, 6, 7, 8]) == 8\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 2\n assert candidate(nums = [9, 8, 7, 6, 5, 5, 5, 4, 3, 2]) == 5\n assert candidate(nums = [10, 9, 8, 7, 8, 9, 10, 9, 8, 7, 8, 9, 10, 9, 8, 7]) == 4\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 8\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 4, 3, 2]) == 4\n assert candidate(nums = [1, 2, 2, 2, 2, 2, 2, 2, 2, 3]) == 2\n assert candidate(nums = [9, 8, 7, 6, 5, 3, 4, 5, 6, 7, 5, 4, 3, 2, 1, 2, 3]) == 6\n assert candidate(nums = [2, 1, 3, 2, 4, 3, 5, 4, 6, 5]) == 2\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 50\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [2, 1, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 5, 4, 3, 2, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1]) == 5\n assert candidate(nums = [50, 1, 50, 1, 50, 1, 50, 1, 50, 1, 50, 1, 50, 1, 50, 1, 50, 1, 50, 1]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3]) == 5\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10]) == 2\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == 9\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 4, 3, 2, 1]) == 5\n assert candidate(nums = [1, 1, 2, 3, 4, 5, 5, 6, 7, 8]) == 5\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1]) == 6\n assert candidate(nums = [10, 20, 15, 10, 5, 10, 15, 20, 25, 20, 15, 10, 5]) == 5\n assert candidate(nums = [2, 1, 3, 4, 5, 6, 7, 8, 9, 10, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6]) == 6\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8]) == 2\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 4, 5, 6, 7, 8, 9, 10]) == 8\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10]) == 2\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5]) == 10\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7]) == 2\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 2\n assert candidate(nums = [5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 5, 6, 7, 8, 9]) == 6\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [5, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2]) == 2\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 2\n assert candidate(nums = [10, 9, 9, 9, 9, 9, 9, 9, 9, 8]) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 10\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 1, 2, 3, 4, 3, 4, 5, 4, 5, 6]) == 5\n assert candidate(nums = [1, 3, 5, 7, 9, 8, 6, 4, 2, 1, 3, 5, 7, 9, 8, 6, 4, 2, 1]) == 6\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 2\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 2\n assert candidate(nums = [1, 2, 2, 1, 2, 3, 3, 2, 1, 2, 3, 4, 4, 3, 2, 1]) == 4\n assert candidate(nums = [1, 3, 5, 7, 9, 7, 5, 3, 1, 3, 5, 7]) == 5\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2]) == 3\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1]) == 3\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 50]) == 26\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [9, 8, 7, 6, 7, 8, 9, 10, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 11\n assert candidate(nums = [1, 3, 2, 4, 5, 3, 6, 7, 8, 5, 9]) == 4\n assert candidate(nums = [1, 3, 2, 4, 5, 7, 6, 8, 9, 10]) == 4\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6]) == 10\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9]) == 2\n assert candidate(nums = [1, 3, 2, 4, 5, 3, 6, 7, 5, 8]) == 3\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12, 11]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1]) == 5\n assert candidate(nums = [10, 20, 15, 10, 5, 1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1]) == 6\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7]) == 2\n assert candidate(nums = [5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5]) == 2\n assert candidate(nums = [10, 9, 8, 7, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 5, 6, 5, 6, 7, 8, 7, 8, 9, 10]) == 5\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 14, 12, 10, 8, 6, 4, 2, 4, 6, 8, 10, 12, 14, 16, 18]) == 9\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 2, 2, 2, 1, 1, 1]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1]) == 5\n assert candidate(nums = [2, 4, 6, 8, 10, 9, 7, 5, 3, 1, 2, 4, 6, 8, 10, 9, 7, 5, 3, 1]) == 6\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [3, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 50\n assert candidate(nums = [10, 9, 8, 7, 7, 6, 5, 4, 3, 2]) == 6\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 8]) == 9\n assert candidate(nums = [5, 6, 5, 6, 7, 6, 7, 8, 7, 8, 9, 8, 9, 10, 9]) == 3\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6]) == 6\n assert candidate(nums = [2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 11\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 2]) == 9\n assert candidate(nums = [1, 3, 5, 7, 9, 10, 8, 6, 4, 2]) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8]) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 0]) == 6\n assert candidate(nums = [3, 3, 2, 2, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 2\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 5\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 9\n assert candidate(nums = [50, 49, 47, 45, 43, 41, 39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 26\n assert candidate(nums = [10, 20, 30, 25, 20, 15, 10, 5, 1, 2, 3, 4, 5, 6]) == 7\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 3\n assert candidate(nums = [2, 3, 1, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11]) == 2\n assert candidate(nums = [5, 6, 7, 8, 9, 8, 7, 6, 5, 6]) == 5\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4]) == 4\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().longestMonotonicSubarray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int longestMonotonicSubarray(vector& nums) {", "container": "Solution", "callable": "longestMonotonicSubarray", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3106, "task_id": "lexicographically-smallest-string-after-operations-with-constraint", "difficulty": "Medium", "problem_description": "You are given a string s and an integer k.\nDefine a function distance(s1, s2) between two strings s1 and s2 of the same length n as:\n\nThe sum of the minimum distance between s1[i] and s2[i] when the characters from 'a' to 'z' are placed in a cyclic order, for all i in the range [0, n - 1].\n\nFor example, distance(\"ab\", \"cd\") == 4, and distance(\"a\", \"z\") == 1.\nYou can change any letter of s to any other lowercase English letter, any number of times.\nReturn a string denoting the lexicographically smallest string t you can get after some changes, such that distance(s, t) <= k.\n \nExample 1:\n\nInput: s = \"zbbz\", k = 3\nOutput: \"aaaz\"\nExplanation:\nChange s to \"aaaz\". The distance between \"zbbz\" and \"aaaz\" is equal to k = 3.\n\nExample 2:\n\nInput: s = \"xaxcd\", k = 4\nOutput: \"aawcd\"\nExplanation:\nThe distance between \"xaxcd\" and \"aawcd\" is equal to k = 4.\n\nExample 3:\n\nInput: s = \"lol\", k = 0\nOutput: \"lol\"\nExplanation:\nIt's impossible to change any character as k = 0.\n\n \nConstraints:\n\n1 <= s.length <= 100\n0 <= k <= 2000\ns consists only of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"zbbz\",k = 3) == \"aaaz\"\n assert candidate(s = \"abc\",k = 1) == \"aac\"\n assert candidate(s = \"abc\",k = 0) == \"abc\"\n assert candidate(s = \"zzz\",k = 9) == \"aaa\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",k = 50) == \"aaaaaaaaalponmlkjihgfedcba\"\n assert candidate(s = \"xyz\",k = 10) == \"aaa\"\n assert candidate(s = \"aaa\",k = 5) == \"aaa\"\n assert candidate(s = \"abc\",k = 2) == \"aab\"\n assert candidate(s = \"vwxyz\",k = 25) == \"aaaaa\"\n assert candidate(s = \"hello\",k = 7) == \"aello\"\n assert candidate(s = \"abcd\",k = 10) == \"aaaa\"\n assert candidate(s = \"aaaa\",k = 10) == \"aaaa\"\n assert candidate(s = \"qrst\",k = 20) == \"aart\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 26) == \"aaaaaaacijklmnopqrstuvwxyz\"\n assert candidate(s = \"xaxcd\",k = 4) == \"aawcd\"\n assert candidate(s = \"abc\",k = 26) == \"aaa\"\n assert candidate(s = \"zzzz\",k = 25) == \"aaaa\"\n assert candidate(s = \"abcdef\",k = 10) == \"aaaaaf\"\n assert candidate(s = \"zzzz\",k = 1) == \"azzz\"\n assert candidate(s = \"mnop\",k = 15) == \"akop\"\n assert candidate(s = \"lol\",k = 0) == \"lol\"\n assert candidate(s = \"zzz\",k = 6) == \"aaa\"\n assert candidate(s = \"zzzz\",k = 26) == \"aaaa\"\n assert candidate(s = \"aaaa\",k = 1) == \"aaaa\"\n assert candidate(s = \"abcdef\",k = 26) == \"aaaaaa\"\n assert candidate(s = \"abcdefg\",k = 0) == \"abcdefg\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",k = 100) == \"aaaaaaaaaaaaadlkjihgfedcba\"\n assert candidate(s = \"aaaabbbbcccc\",k = 12) == \"aaaaaaaaaaaa\"\n assert candidate(s = \"zzzz\",k = 16) == \"aaaa\"\n assert candidate(s = \"abcdabcdabcd\",k = 30) == \"aaaaaaaaaaaa\"\n assert candidate(s = \"abcdef\",k = 30) == \"aaaaaa\"\n assert candidate(s = \"xyzabc\",k = 12) == \"aaaaaa\"\n assert candidate(s = \"qrstuv\",k = 50) == \"aaaaaa\"\n assert candidate(s = \"aabbcc\",k = 12) == \"aaaaaa\"\n assert candidate(s = \"qrstuvwxyz\",k = 26) == \"aaltuvwxyz\"\n assert candidate(s = \"mnopqr\",k = 15) == \"akopqr\"\n assert candidate(s = \"programming\",k = 50) == \"aaaaaajming\"\n assert candidate(s = \"mnop\",k = 25) == \"aaop\"\n assert candidate(s = \"qqqqqqqqqqqq\",k = 50) == \"aaaaaqqqqqqq\"\n assert candidate(s = \"cryptography\",k = 100) == \"aaaaaaaaaaaa\"\n assert candidate(s = \"nopqrs\",k = 100) == \"aaaaaa\"\n assert candidate(s = \"abcde\",k = 50) == \"aaaaa\"\n assert candidate(s = \"abcdef\",k = 18) == \"aaaaaa\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 2000) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 2000) == \"aaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaa\",k = 2000) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 52) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(s = \"qwerasdfzxcv\",k = 15) == \"aadrasdfzxcv\"\n assert candidate(s = \"aaaaaaaaaa\",k = 9) == \"aaaaaaaaaa\"\n assert candidate(s = \"qrstuv\",k = 30) == \"aaaquv\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyza\",k = 26) == \"aaaaaaacijklmnopqrstuvwxyza\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 25) == \"aaaaaaadijklmnopqrstuvwxyz\"\n assert candidate(s = \"vutsrqponmlkjihgfedcba\",k = 500) == \"aaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(s = \"zzzzzzzzzz\",k = 25) == \"aaaaaaaaaa\"\n assert candidate(s = \"abcdefg\",k = 5) == \"aaabefg\"\n assert candidate(s = \"abcdefghijklm\",k = 39) == \"aaaaaaaaagklm\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 400) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\",k = 150) == \"aaaaaaaaaaaaaaaaaaaaaaaahm\"\n assert candidate(s = \"zzzzzzzzzz\",k = 9) == \"aaaaaaaaaz\"\n assert candidate(s = \"abcdef\",k = 25) == \"aaaaaa\"\n assert candidate(s = \"abcdefg\",k = 20) == \"aaaaaab\"\n assert candidate(s = \"abcdef\",k = 0) == \"abcdef\"\n assert candidate(s = \"wxyz\",k = 8) == \"aaxz\"\n assert candidate(s = \"zzzzzzzzzz\",k = 260) == \"aaaaaaaaaa\"\n assert candidate(s = \"mmmm\",k = 15) == \"ajmm\"\n assert candidate(s = \"abcabcabcabc\",k = 12) == \"aaaaaaaaaaaa\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",k = 1000) == \"aaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(s = \"zzzz\",k = 15) == \"aaaa\"\n assert candidate(s = \"zzzzzz\",k = 50) == \"aaaaaa\"\n assert candidate(s = \"abcdefghij\",k = 35) == \"aaaaaaaabj\"\n assert candidate(s = \"mnopqr\",k = 30) == \"aajpqr\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",k = 2000) == \"aaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",k = 1300) == \"aaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",k = 500) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(s = \"abcdabcd\",k = 16) == \"aaaaaaaa\"\n assert candidate(s = \"nopqrstuvwxyz\",k = 78) == \"aaaaaaaatwxyz\"\n assert candidate(s = \"xyzzxyzzxyzz\",k = 18) == \"aaaaaaaaaxzz\"\n assert candidate(s = \"wxyz\",k = 11) == \"aaaa\"\n assert candidate(s = \"abcdabcdabcd\",k = 26) == \"aaaaaaaaaaaa\"\n assert candidate(s = \"thequickbrownfoxjumpsoverthelazydog\",k = 1000) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(s = \"abcdefghij\",k = 26) == \"aaaaaaacij\"\n assert candidate(s = \"abcdefghij\",k = 15) == \"aaaaaaghij\"\n assert candidate(s = \"aaaabbbb\",k = 7) == \"aaaaaaaa\"\n assert candidate(s = \"zzzz\",k = 8) == \"aaaa\"\n assert candidate(s = \"qrst\",k = 100) == \"aaaa\"\n assert candidate(s = \"mnopqr\",k = 10) == \"cnopqr\"\n assert candidate(s = \"hello\",k = 15) == \"aahlo\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 1000) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\",k = 50) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabdabcd\"\n assert candidate(s = \"qqqqqqqq\",k = 64) == \"aaaaaamq\"\n assert candidate(s = \"zzzzzzzzzz\",k = 100) == \"aaaaaaaaaa\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 1000) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(s = \"abcdxyz\",k = 50) == \"aaaaaaa\"\n assert candidate(s = \"aquickbrownfoxjumps\",k = 50) == \"aaaaaaaakwnfoxjumps\"\n assert candidate(s = \"abcxyz\",k = 12) == \"aaaaaa\"\n assert candidate(s = \"abcdef\",k = 13) == \"aaaaac\"\n assert candidate(s = \"wxyz\",k = 5) == \"awyz\"\n assert candidate(s = \"abcd\",k = 100) == \"aaaa\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 1300) == \"aaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(s = \"mnbvcxzlkjhgfdsapoiuytrewq\",k = 50) == \"aaaaaaaaijhgfdsapoiuytrewq\"\n assert candidate(s = \"vwxyz\",k = 30) == \"aaaaa\"\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\",k = 200) == \"aaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(s = \"qrstuv\",k = 10) == \"arstuv\"\n assert candidate(s = \"mnopqr\",k = 20) == \"afopqr\"\n assert candidate(s = \"jklmno\",k = 15) == \"aelmno\"\n assert candidate(s = \"qzab\",k = 5) == \"lzab\"\n assert candidate(s = \"abcdefghij\",k = 45) == \"aaaaaaaaaa\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 500) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(s = \"mnop\",k = 20) == \"afop\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",k = 26) == \"aaaaaaosrqponmlkjihgfedcba\"\n"}, "metadata": {"canonical_parameter_names": ["s", "k"], "leetcode_dataset_entry_point": "Solution().getSmallestString", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string getSmallestString(string s, int k) {", "container": "Solution", "callable": "getSmallestString", "parameters": [{"name": "s", "type": "string"}, {"name": "k", "type": "int"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3107, "task_id": "minimum-operations-to-make-median-of-array-equal-to-k", "difficulty": "Medium", "problem_description": "You are given an integer array nums and a non-negative integer k. In one operation, you can increase or decrease any element by 1.\nReturn the minimum number of operations needed to make the median of nums equal to k.\nThe median of an array is defined as the middle element of the array when it is sorted in non-decreasing order. If there are two choices for a median, the larger of the two values is taken.\n \nExample 1:\n\nInput: nums = [2,5,6,8,5], k = 4\nOutput: 2\nExplanation:\nWe can subtract one from nums[1] and nums[4] to obtain [2, 4, 6, 8, 4]. The median of the resulting array is equal to k.\n\nExample 2:\n\nInput: nums = [2,5,6,8,5], k = 7\nOutput: 3\nExplanation:\nWe can add one to nums[1] twice and add one to nums[2] once to obtain [2, 7, 7, 8, 5].\n\nExample 3:\n\nInput: nums = [1,2,3,4,5,6], k = 4\nOutput: 0\nExplanation:\nThe median of the array is already equal to k.\n\n \nConstraints:\n\n1 <= nums.length <= 2 * 105\n1 <= nums[i] <= 109\n1 <= k <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 3, 3, 3, 7, 7, 9],k = 3) == 0\n assert candidate(nums = [5, 5, 5, 5, 5],k = 5) == 0\n assert candidate(nums = [1, 1000000000, 2, 999999999, 3],k = 500000000) == 499999997\n assert candidate(nums = [2, 5, 6, 8, 5],k = 7) == 3\n assert candidate(nums = [1, 1, 1, 1, 1],k = 3) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6],k = 4) == 0\n assert candidate(nums = [2, 5, 6, 8, 5],k = 4) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 5],k = 5) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],k = 5) == 0\n assert candidate(nums = [1, 2, 3, 100, 101],k = 3) == 0\n assert candidate(nums = [1, 3, 3, 3, 7],k = 3) == 0\n assert candidate(nums = [1, 3, 3, 3, 7, 7, 9],k = 5) == 2\n assert candidate(nums = [10, 20, 30, 40, 50],k = 30) == 0\n assert candidate(nums = [10, 20, 30, 40, 50],k = 35) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 8\n assert candidate(nums = [2, 3, 1, 5, 4, 6, 8, 7, 9],k = 6) == 1\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 20) == 100\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10],k = 5) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 40\n assert candidate(nums = [999999999, 999999999, 999999999, 999999999, 999999999],k = 1000000000) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],k = 6) == 0\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7],k = 4) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 55) == 5\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13],k = 8) == 1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21],k = 11) == 0\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 4) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 3) == 14\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 15\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 10\n assert candidate(nums = [5, 1, 9, 3, 7, 11, 13, 15, 17, 19],k = 10) == 1\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100],k = 600) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70],k = 40) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 15) == 0\n assert candidate(nums = [1, 1000000000, 1, 1000000000, 1, 1000000000],k = 500000000) == 500000000\n assert candidate(nums = [1000000000, 500000000, 750000000, 250000000, 1000],k = 500000000) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 105) == 5\n assert candidate(nums = [2, 3, 1, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21],k = 11) == 0\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 10) == 0\n assert candidate(nums = [1, 3, 3, 6, 7, 8, 9, 10, 11],k = 8) == 1\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 1, 2],k = 10) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 4) == 1\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 5, 5, 6],k = 3) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 0\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000],k = 6500) == 500\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 15) == 10\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 6) == 0\n assert candidate(nums = [1, 1000000000, 2, 999999999, 3, 999999998, 4, 999999997, 5, 999999996],k = 500000000) == 499999996\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000],k = 1000000000) == 0\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125],k = 1000000000) == 3062500000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 1\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 3) == 10\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90],k = 50) == 0\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],k = 7) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 80) == 0\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],k = 95) == 0\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 3, 3, 4],k = 2) == 0\n assert candidate(nums = [9, 3, 5, 7, 1, 8, 2, 4, 6],k = 5) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 5) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21],k = 10) == 1\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 3) == 0\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000],k = 1) == 5999999994\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 5) == 0\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 11) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 20\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 3) == 12\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],k = 30) == 1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == 0\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000],k = 500000000) == 1500000000\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 5) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70],k = 35) == 5\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5],k = 6) == 4\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],k = 29) == 16\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],k = 6) == 1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 65\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 25\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 10) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130],k = 65) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],k = 7) == 0\n assert candidate(nums = [9, 7, 5, 3, 1, 2, 4, 6, 8, 0],k = 5) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 20) == 1\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 500) == 100\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 1\n assert candidate(nums = [9, 3, 7, 5, 1, 8, 6, 4, 2, 0],k = 5) == 0\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000],k = 999999999) == 3\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70],k = 45) == 5\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().minOperationsToMakeMedianK", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "long long minOperationsToMakeMedianK(vector& nums, int k) {", "container": "Solution", "callable": "minOperationsToMakeMedianK", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "long long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3108, "task_id": "minimum-cost-walk-in-weighted-graph", "difficulty": "Hard", "problem_description": "There is an undirected weighted graph with n vertices labeled from 0 to n - 1.\nYou are given the integer n and an array edges, where edges[i] = [ui, vi, wi] indicates that there is an edge between vertices ui and vi with a weight of wi.\nA walk on a graph is a sequence of vertices and edges. The walk starts and ends with a vertex, and each edge connects the vertex that comes before it and the vertex that comes after it. It's important to note that a walk may visit the same edge or vertex more than once.\nThe cost of a walk starting at node u and ending at node v is defined as the bitwise AND of the weights of the edges traversed during the walk. In other words, if the sequence of edge weights encountered during the walk is w0, w1, w2, ..., wk, then the cost is calculated as w0 & w1 & w2 & ... & wk, where & denotes the bitwise AND operator.\nYou are also given a 2D array query, where query[i] = [si, ti]. For each query, you need to find the minimum cost of the walk starting at vertex si and ending at vertex ti. If there exists no such walk, the answer is -1.\nReturn the array answer, where answer[i] denotes the minimum cost of a walk for query i.\n \nExample 1:\n\nInput: n = 5, edges = [[0,1,7],[1,3,7],[1,2,1]], query = [[0,3],[3,4]]\nOutput: [1,-1]\nExplanation:\n\nTo achieve the cost of 1 in the first query, we need to move on the following edges: 0->1 (weight 7), 1->2 (weight 1), 2->1 (weight 1), 1->3 (weight 7).\nIn the second query, there is no walk between nodes 3 and 4, so the answer is -1.\nExample 2:\n\n\nInput: n = 3, edges = [[0,2,7],[0,1,15],[1,2,6],[1,2,1]], query = [[1,2]]\nOutput: [0]\nExplanation:\n\nTo achieve the cost of 0 in the first query, we need to move on the following edges: 1->2 (weight 1), 2->1 (weight 6), 1->2 (weight 1).\n\n \nConstraints:\n\n2 <= n <= 105\n0 <= edges.length <= 105\nedges[i].length == 3\n0 <= ui, vi <= n - 1\nui != vi\n0 <= wi <= 105\n1 <= query.length <= 105\nquery[i].length == 2\n0 <= si, ti <= n - 1\nsi != ti\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 10,edges = [[0, 1, 1], [2, 3, 2], [4, 5, 3], [6, 7, 4], [8, 9, 5]],query = [[0, 9], [1, 8]]) == [-1, -1]\n assert candidate(n = 6,edges = [[0, 1, 5], [1, 2, 4], [2, 3, 3], [3, 4, 2], [4, 5, 1]],query = [[0, 5], [2, 4]]) == [0, 0]\n assert candidate(n = 10,edges = [[0, 1, 100], [1, 2, 50], [2, 3, 25], [3, 4, 10], [4, 5, 5], [5, 6, 2], [6, 7, 1], [7, 8, 4], [8, 9, 8]],query = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [0, 0, 0, 0, 0]\n assert candidate(n = 3,edges = [[0, 2, 7], [0, 1, 15], [1, 2, 6], [1, 2, 1]],query = [[1, 2]]) == [0]\n assert candidate(n = 7,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6]],query = [[0, 6], [1, 5], [2, 4], [3, 3]]) == [0, 0, 0, 0]\n assert candidate(n = 4,edges = [[0, 1, 12], [1, 2, 10], [2, 3, 8], [3, 0, 6]],query = [[0, 2], [1, 3]]) == [0, 0]\n assert candidate(n = 8,edges = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50], [5, 6, 60], [6, 7, 70]],query = [[0, 7], [1, 6], [2, 5]]) == [0, 0, 0]\n assert candidate(n = 6,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 4], [3, 4, 8], [4, 5, 16]],query = [[0, 5], [2, 3]]) == [0, 0]\n assert candidate(n = 7,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6]],query = [[0, 6], [1, 5], [2, 4]]) == [0, 0, 0]\n assert candidate(n = 6,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5]],query = [[0, 5], [2, 4], [1, 3]]) == [0, 0, 0]\n assert candidate(n = 6,edges = [[0, 1, 3], [1, 2, 5], [2, 3, 2], [3, 4, 7], [4, 5, 1]],query = [[0, 5], [1, 4], [2, 2]]) == [0, 0, 0]\n assert candidate(n = 4,edges = [[0, 1, 3], [1, 2, 2], [2, 3, 1], [3, 0, 4]],query = [[0, 2], [1, 3]]) == [0, 0]\n assert candidate(n = 5,edges = [],query = [[0, 1], [1, 2], [2, 3], [3, 4]]) == [-1, -1, -1, -1]\n assert candidate(n = 4,edges = [],query = [[0, 1], [1, 2], [2, 3], [3, 0]]) == [-1, -1, -1, -1]\n assert candidate(n = 6,edges = [[0, 1, 8], [1, 2, 4], [2, 3, 2], [3, 4, 1], [4, 5, 6], [5, 0, 3]],query = [[0, 3], [2, 5], [1, 4]]) == [0, 0, 0]\n assert candidate(n = 6,edges = [[0, 1, 12], [1, 2, 11], [2, 3, 10], [3, 4, 9], [4, 5, 8], [5, 0, 7]],query = [[0, 5], [1, 4], [2, 3], [3, 2], [4, 1], [5, 0]]) == [0, 0, 0, 0, 0, 0]\n assert candidate(n = 8,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7]],query = [[0, 7], [1, 6]]) == [0, 0]\n assert candidate(n = 4,edges = [[0, 1, 3], [1, 2, 5], [2, 3, 2], [3, 0, 4]],query = [[0, 2], [1, 3], [0, 3]]) == [0, 0, 0]\n assert candidate(n = 7,edges = [[0, 1, 7], [1, 2, 5], [2, 3, 3], [3, 4, 1], [4, 5, 2], [5, 6, 6]],query = [[0, 6], [2, 4]]) == [0, 0]\n assert candidate(n = 4,edges = [[0, 1, 3], [1, 2, 5], [2, 3, 2]],query = [[0, 3], [1, 2], [2, 0]]) == [0, 0, 0]\n assert candidate(n = 6,edges = [[0, 1, 4], [1, 2, 3], [2, 3, 2], [3, 4, 1], [4, 5, 5]],query = [[0, 5], [2, 4]]) == [0, 0]\n assert candidate(n = 4,edges = [[0, 1, 3], [1, 2, 5], [2, 3, 2]],query = [[0, 2], [1, 3]]) == [0, 0]\n assert candidate(n = 4,edges = [[0, 1, 3], [1, 2, 3], [2, 3, 3]],query = [[0, 2], [1, 3]]) == [3, 3]\n assert candidate(n = 7,edges = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7]],query = [[0, 6], [1, 5]]) == [0, 0]\n assert candidate(n = 4,edges = [[0, 1, 3], [1, 2, 5], [2, 3, 2], [3, 0, 4]],query = [[0, 2], [1, 3], [2, 0]]) == [0, 0, 0]\n assert candidate(n = 10,edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10]],query = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [10, 10, 10, 10, 10]\n assert candidate(n = 6,edges = [[0, 1, 5], [1, 2, 4], [2, 3, 3], [3, 4, 2], [4, 5, 1]],query = [[0, 5], [1, 4], [2, 3]]) == [0, 0, 0]\n assert candidate(n = 4,edges = [[0, 1, 3], [1, 2, 5], [2, 3, 8]],query = [[0, 2], [1, 3], [2, 0]]) == [0, 0, 0]\n assert candidate(n = 7,edges = [[0, 1, 10], [1, 2, 11], [2, 3, 12], [3, 4, 13], [4, 5, 14], [5, 6, 15], [6, 0, 16]],query = [[0, 6], [1, 3]]) == [0, 0]\n assert candidate(n = 8,edges = [[0, 1, 8], [1, 2, 4], [2, 3, 2], [3, 4, 1], [4, 5, 16], [5, 6, 8], [6, 7, 4]],query = [[0, 7], [1, 6], [2, 5], [3, 4]]) == [0, 0, 0, 0]\n assert candidate(n = 7,edges = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7]],query = [[0, 6], [1, 5], [2, 4]]) == [0, 0, 0]\n assert candidate(n = 6,edges = [[0, 1, 5], [1, 2, 3], [2, 3, 1], [3, 4, 2], [4, 5, 6]],query = [[0, 5], [2, 4], [1, 3]]) == [0, 0, 0]\n assert candidate(n = 7,edges = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50], [5, 6, 60]],query = [[0, 6], [2, 5]]) == [0, 0]\n assert candidate(n = 3,edges = [[0, 1, 10], [1, 2, 5]],query = [[0, 2], [1, 0]]) == [0, 0]\n assert candidate(n = 7,edges = [[0, 1, 2], [1, 2, 2], [2, 3, 2], [3, 4, 2], [4, 5, 2], [5, 6, 2]],query = [[0, 6], [1, 5]]) == [2, 2]\n assert candidate(n = 4,edges = [[0, 1, 3], [1, 2, 3], [2, 3, 3]],query = [[0, 3], [1, 2]]) == [3, 3]\n assert candidate(n = 5,edges = [[0, 1, 2], [0, 2, 3], [0, 3, 4], [0, 4, 5]],query = [[0, 1], [0, 2], [0, 3], [0, 4]]) == [0, 0, 0, 0]\n assert candidate(n = 6,edges = [[0, 1, 2], [1, 2, 4], [2, 3, 8], [3, 4, 16], [4, 5, 32]],query = [[0, 5], [2, 4]]) == [0, 0]\n assert candidate(n = 8,edges = [],query = [[0, 1], [1, 2], [2, 3], [3, 4]]) == [-1, -1, -1, -1]\n assert candidate(n = 10,edges = [[0, 1, 10], [1, 2, 9], [2, 3, 8], [3, 4, 7], [4, 5, 6], [5, 6, 5], [6, 7, 4], [7, 8, 3], [8, 9, 2], [9, 0, 1]],query = [[0, 9], [1, 8]]) == [0, 0]\n assert candidate(n = 10,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1]],query = [[0, 9], [3, 6]]) == [1, 1]\n assert candidate(n = 12,edges = [[0, 1, 2], [1, 2, 2], [2, 3, 2], [3, 4, 2], [4, 5, 2], [5, 6, 2], [6, 7, 2], [7, 8, 2], [8, 9, 2], [9, 10, 2], [10, 11, 2]],query = [[0, 11], [3, 8]]) == [2, 2]\n assert candidate(n = 6,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 0, 6]],query = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [0, 0, 0, 0, 0, 0]\n assert candidate(n = 7,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6]],query = [[0, 6], [1, 4]]) == [0, 0]\n assert candidate(n = 5,edges = [[0, 1, 31], [1, 2, 29], [2, 3, 33], [3, 4, 35]],query = [[0, 4], [1, 3], [2, 0], [3, 1], [4, 2]]) == [1, 1, 1, 1, 1]\n assert candidate(n = 4,edges = [[0, 1, 8], [1, 2, 4], [2, 3, 2]],query = [[0, 3], [1, 2]]) == [0, 0]\n assert candidate(n = 9,edges = [[0, 1, 1], [2, 3, 2], [4, 5, 3], [6, 7, 4], [8, 0, 5]],query = [[0, 8], [1, 2], [3, 4], [5, 6], [7, 0]]) == [1, -1, -1, -1, -1]\n assert candidate(n = 7,edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10]],query = [[0, 6], [1, 5]]) == [10, 10]\n assert candidate(n = 6,edges = [[0, 1, 5], [1, 2, 3], [2, 3, 1], [3, 4, 4], [4, 5, 2]],query = [[0, 5], [1, 4]]) == [0, 0]\n assert candidate(n = 9,edges = [[0, 1, 100], [1, 2, 200], [2, 3, 300], [3, 4, 400], [4, 5, 500], [5, 6, 600], [6, 7, 700], [7, 8, 800]],query = [[0, 8], [4, 7]]) == [0, 0]\n assert candidate(n = 6,edges = [[0, 1, 3], [1, 2, 2], [2, 3, 1], [3, 4, 4], [4, 5, 5]],query = [[0, 5], [2, 4]]) == [0, 0]\n assert candidate(n = 9,edges = [[0, 1, 9], [1, 2, 8], [2, 3, 7], [3, 4, 6], [4, 5, 5], [5, 6, 4], [6, 7, 3], [7, 8, 2], [8, 0, 1]],query = [[0, 8], [1, 7]]) == [0, 0]\n assert candidate(n = 4,edges = [[0, 1, 3], [1, 2, 2], [2, 3, 1]],query = [[0, 2], [1, 3], [2, 0]]) == [0, 0, 0]\n assert candidate(n = 3,edges = [],query = [[0, 1], [1, 2], [2, 0]]) == [-1, -1, -1]\n assert candidate(n = 4,edges = [[0, 1, 10], [1, 2, 20], [2, 3, 30]],query = [[0, 3], [1, 2], [2, 0]]) == [0, 0, 0]\n assert candidate(n = 4,edges = [[0, 1, 10], [1, 2, 20], [2, 3, 30]],query = [[0, 3], [3, 0], [1, 1]]) == [0, 0, 0]\n assert candidate(n = 10,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9]],query = [[0, 9], [1, 8], [2, 7]]) == [0, 0, 0]\n assert candidate(n = 4,edges = [[0, 1, 3], [1, 2, 2], [2, 3, 1]],query = [[0, 2], [1, 3], [0, 3]]) == [0, 0, 0]\n assert candidate(n = 4,edges = [[0, 1, 15], [1, 2, 25], [2, 3, 35], [3, 0, 45]],query = [[0, 3], [1, 2], [2, 1], [3, 0]]) == [1, 1, 1, 1]\n assert candidate(n = 7,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 0, 7]],query = [[0, 6], [2, 4]]) == [0, 0]\n assert candidate(n = 6,edges = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 0, 7]],query = [[0, 5], [1, 4]]) == [0, 0]\n assert candidate(n = 6,edges = [[0, 1, 5], [1, 2, 3], [2, 3, 4], [3, 4, 2], [4, 5, 1]],query = [[0, 5], [1, 4]]) == [0, 0]\n assert candidate(n = 11,edges = [[0, 1, 5], [1, 2, 5], [2, 3, 5], [3, 4, 5], [4, 5, 5], [5, 6, 5], [6, 7, 5], [7, 8, 5], [8, 9, 5], [9, 10, 5]],query = [[0, 10], [2, 7]]) == [5, 5]\n assert candidate(n = 4,edges = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 0, 5]],query = [[0, 2], [1, 3]]) == [0, 0]\n assert candidate(n = 6,edges = [[0, 1, 10], [0, 2, 5], [1, 3, 1], [2, 4, 7], [3, 4, 3]],query = [[0, 4], [2, 5]]) == [0, -1]\n assert candidate(n = 7,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6]],query = [[0, 6], [1, 5]]) == [0, 0]\n assert candidate(n = 4,edges = [[0, 1, 3], [1, 2, 5], [2, 3, 2], [3, 0, 4]],query = [[0, 2], [1, 3]]) == [0, 0]\n assert candidate(n = 8,edges = [[0, 1, 8], [1, 2, 7], [2, 3, 6], [3, 4, 5], [4, 5, 4], [5, 6, 3], [6, 7, 2], [7, 0, 1]],query = [[0, 7], [1, 6], [2, 5]]) == [0, 0, 0]\n assert candidate(n = 12,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11]],query = [[0, 11], [1, 10]]) == [0, 0]\n assert candidate(n = 6,edges = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6]],query = [[0, 5], [2, 4]]) == [0, 0]\n assert candidate(n = 6,edges = [[0, 1, 3], [1, 2, 5], [2, 3, 2], [3, 4, 8], [4, 5, 4]],query = [[0, 5], [1, 4]]) == [0, 0]\n assert candidate(n = 7,edges = [[0, 1, 6], [1, 2, 5], [2, 3, 4], [3, 4, 3], [4, 5, 2], [5, 6, 1]],query = [[0, 6], [2, 5]]) == [0, 0]\n assert candidate(n = 4,edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 0, 10]],query = [[0, 3], [1, 2], [0, 2]]) == [10, 10, 10]\n assert candidate(n = 7,edges = [],query = [[0, 1], [2, 3], [4, 5]]) == [-1, -1, -1]\n assert candidate(n = 5,edges = [],query = [[0, 4], [1, 3]]) == [-1, -1]\n assert candidate(n = 7,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6]],query = [[0, 6], [1, 5], [2, 4], [3, 0]]) == [0, 0, 0, 0]\n assert candidate(n = 6,edges = [[0, 1, 3], [1, 2, 5], [2, 3, 2], [3, 4, 6], [4, 5, 4]],query = [[0, 5], [2, 4]]) == [0, 0]\n assert candidate(n = 6,edges = [[0, 1, 2], [1, 2, 4], [2, 3, 6], [3, 4, 8], [4, 5, 10], [5, 0, 1]],query = [[0, 5], [1, 4], [2, 3]]) == [0, 0, 0]\n assert candidate(n = 8,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7]],query = [[0, 7], [3, 6]]) == [0, 0]\n assert candidate(n = 5,edges = [[0, 1, 7], [1, 3, 7], [1, 2, 1]],query = [[0, 3], [3, 4]]) == [1, -1]\n assert candidate(n = 4,edges = [[0, 1, 12], [1, 2, 8], [2, 3, 10]],query = [[0, 3], [1, 2], [2, 3]]) == [8, 8, 8]\n assert candidate(n = 4,edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 0, 10]],query = [[0, 2], [1, 3]]) == [10, 10]\n assert candidate(n = 11,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10]],query = [[0, 10], [1, 9]]) == [0, 0]\n assert candidate(n = 6,edges = [[0, 1, 5], [1, 2, 5], [2, 3, 5], [3, 4, 5], [4, 5, 5]],query = [[0, 5], [2, 4]]) == [5, 5]\n assert candidate(n = 4,edges = [[0, 1, 8], [1, 2, 4], [2, 3, 2], [3, 0, 1]],query = [[0, 2], [1, 3]]) == [0, 0]\n assert candidate(n = 4,edges = [[0, 1, 2], [1, 2, 3], [2, 3, 4]],query = [[0, 3], [1, 2]]) == [0, 0]\n assert candidate(n = 6,edges = [[0, 1, 7], [1, 2, 7], [2, 0, 7], [3, 4, 1], [4, 5, 1], [5, 3, 1]],query = [[0, 3], [1, 4], [2, 5]]) == [-1, -1, -1]\n assert candidate(n = 7,edges = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50], [5, 6, 60], [6, 0, 70]],query = [[0, 3], [1, 5], [2, 4]]) == [0, 0, 0]\n assert candidate(n = 9,edges = [[0, 1, 8], [1, 2, 9], [2, 3, 10], [3, 4, 11], [4, 5, 12], [5, 6, 13], [6, 7, 14], [7, 8, 15]],query = [[0, 8], [1, 7]]) == [8, 8]\n assert candidate(n = 10,edges = [[0, 1, 10], [1, 2, 9], [2, 3, 8], [3, 4, 7], [4, 5, 6], [5, 6, 5], [6, 7, 4], [7, 8, 3], [8, 9, 2], [9, 0, 1]],query = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [0, 0, 0, 0, 0]\n assert candidate(n = 4,edges = [[0, 1, 3], [1, 2, 5], [2, 3, 7]],query = [[0, 2], [1, 3]]) == [1, 1]\n assert candidate(n = 6,edges = [[0, 1, 5], [1, 2, 5], [2, 3, 5], [3, 4, 5], [4, 5, 5]],query = [[0, 5], [1, 4], [2, 3]]) == [5, 5, 5]\n assert candidate(n = 7,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 0, 7]],query = [[0, 6], [1, 5], [2, 4], [3, 3]]) == [0, 0, 0, 0]\n assert candidate(n = 8,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 0, 8]],query = [[0, 7], [1, 6]]) == [0, 0]\n assert candidate(n = 6,edges = [[0, 1, 2], [1, 2, 4], [2, 3, 8], [3, 4, 16], [4, 5, 32]],query = [[0, 5], [1, 4], [2, 3]]) == [0, 0, 0]\n"}, "metadata": {"canonical_parameter_names": ["n", "edges", "query"], "leetcode_dataset_entry_point": "Solution().minimumCost", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector minimumCost(int n, vector>& edges, vector>& query) {", "container": "Solution", "callable": "minimumCost", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "vector>&"}, {"name": "query", "type": "vector>&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3110, "task_id": "score-of-a-string", "difficulty": "Easy", "problem_description": "You are given a string s. The score of a string is defined as the sum of the absolute difference between the ASCII values of adjacent characters.\nReturn the score of s.\n \nExample 1:\n\nInput: s = \"hello\"\nOutput: 13\nExplanation:\nThe ASCII values of the characters in s are: 'h' = 104, 'e' = 101, 'l' = 108, 'o' = 111. So, the score of s would be |104 - 101| + |101 - 108| + |108 - 108| + |108 - 111| = 3 + 7 + 0 + 3 = 13.\n\nExample 2:\n\nInput: s = \"zaz\"\nOutput: 50\nExplanation:\nThe ASCII values of the characters in s are: 'z' = 122, 'a' = 97. So, the score of s would be |122 - 97| + |97 - 122| = 25 + 25 = 50.\n\n \nConstraints:\n\n2 <= s.length <= 100\ns consists only of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 25\n assert candidate(s = \"a\") == 0\n assert candidate(s = \"abracadabra\") == 78\n assert candidate(s = \"zzzz\") == 0\n assert candidate(s = \"zyx\") == 2\n assert candidate(s = \"mnopqr\") == 5\n assert candidate(s = \"python\") == 34\n assert candidate(s = \"aaa\") == 0\n assert candidate(s = \"abcdabcd\") == 9\n assert candidate(s = \"zzz\") == 0\n assert candidate(s = \"xyz\") == 2\n assert candidate(s = \"zaz\") == 50\n assert candidate(s = \"zyxwvut\") == 6\n assert candidate(s = \"abc\") == 2\n assert candidate(s = \"hello\") == 13\n assert candidate(s = \"aabbcc\") == 2\n assert candidate(s = \"mississippi\") == 58\n assert candidate(s = \"qpqpqpqp\") == 7\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\") == 25\n assert candidate(s = \"qwerty\") == 44\n assert candidate(s = \"aaaabbbbccccdddd\") == 3\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmqwertyui\") == 276\n assert candidate(s = \"abcdabcdabcdabcdabcd\") == 27\n assert candidate(s = \"lkjlkjlkjlkjlkjlkjlkjlkjlkjlkjlkjlkjlkj\") == 50\n assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcdefghij\") == 63\n assert candidate(s = \"learning\") == 49\n assert candidate(s = \"helloalibaba\") == 51\n assert candidate(s = \"aaabbbcccdddeeefffggghhhiiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz\") == 25\n assert candidate(s = \"thisisaverylongstringwithavarietyofcharacters\") == 447\n assert candidate(s = \"abacabadabacaba\") == 22\n assert candidate(s = \"code\") == 24\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzzzzyxwvutsrqponmlkjihgfedcba\") == 50\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\") == 38\n assert candidate(s = \"hellohellohellohellohello\") == 93\n assert candidate(s = \"abcdabcda\") == 12\n assert candidate(s = \"data\") == 41\n assert candidate(s = \"challenge\") == 48\n assert candidate(s = \"artificial\") == 67\n assert candidate(s = \"abcabcabcabc\") == 14\n assert candidate(s = \"mnopqrstmnopqrstmnopqr\") == 33\n assert candidate(s = \"hellotherefriends\") == 119\n assert candidate(s = \"quickbrownfoxjumpsoverthelazydog\") == 282\n assert candidate(s = \"qrstuvpqponmlkjihgfedcba\") == 28\n assert candidate(s = \"aaaabbbbccccddddeeeeffff\") == 5\n assert candidate(s = \"abczzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 25\n assert candidate(s = \"science\") == 48\n assert candidate(s = \"thefiveboxingwizardsjumpquickly\") == 295\n assert candidate(s = \"aaaaabbbbbcccccdddddee\") == 4\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\") == 212\n assert candidate(s = \"mnbvcxzlkjhgfdsapoiuytrewqmnbvcxzlkjhgfdsapoiuytrewq\") == 428\n assert candidate(s = \"zazazazazazazazazazazazazazazazazazazazazazazazaza\") == 1225\n assert candidate(s = \"ejhjhehjhejhejhejhejhej\") == 69\n assert candidate(s = \"developer\") == 70\n assert candidate(s = \"abababababababab\") == 15\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyza\") == 50\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 75\n assert candidate(s = \"noon\") == 2\n assert candidate(s = \"solution\") == 35\n assert candidate(s = \"lkjasdlfkjsadlkfjasdlkfjasdlkfjasdlkfjsadlkfj\") == 340\n assert candidate(s = \"qpwoeirutyalskdjfhgzmxcvbnm\") == 234\n assert candidate(s = \"abcabcabcabcabcabc\") == 22\n assert candidate(s = \"abcdefgfe_dcba\") == 22\n assert candidate(s = \"algorithm\") == 64\n assert candidate(s = \"sdjfnwiehfuiwehfiuhweihufew\") == 242\n assert candidate(s = \"thisisaverylongstringwithvariouscharacters\") == 417\n assert candidate(s = \"jfkienfehndsjdfhienfhisodfns\") == 151\n assert candidate(s = \"intelligence\") == 62\n assert candidate(s = \"qwen\") == 33\n assert candidate(s = \"alibabacloud\") == 61\n assert candidate(s = \"fun\") == 22\n assert candidate(s = \"hellothereitisacoldwinter\") == 210\n assert candidate(s = \"aaabbbcccdddeeefffggghhhiiiijjjjkkkkllllmmmmnnnnooopppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz\") == 25\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 25\n assert candidate(s = \"asciiisawesome\") == 136\n assert candidate(s = \"programming\") == 69\n assert candidate(s = \"qwertypoiuytrewq\") == 120\n assert candidate(s = \"abczabcyabcbabczabcyabcbabcz\") == 229\n assert candidate(s = \"level\") == 48\n assert candidate(s = \"thisisaverylongstringthatcontainsmanycharacters\") == 461\n assert candidate(s = \"qazwsxedcrfvtgbyhnujmiklop\") == 215\n assert candidate(s = \"thisisaverylongstringwithmanycharacters\") == 389\n assert candidate(s = \"azbycxdwevfugthsijrkqlponm\") == 314\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(s = \"thequickbrownfoxjumpsoverthelazydog\") == 309\n assert candidate(s = \"mnopqrstmnopqrst\") == 21\n assert candidate(s = \"abcdefg\") == 6\n assert candidate(s = \"expert\") == 53\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().scoreOfString", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int scoreOfString(string s) {", "container": "Solution", "callable": "scoreOfString", "parameters": [{"name": "s", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3111, "task_id": "minimum-rectangles-to-cover-points", "difficulty": "Medium", "problem_description": "You are given a 2D integer array points, where points[i] = [xi, yi]. You are also given an integer w. Your task is to cover all the given points with rectangles.\nEach rectangle has its lower end at some point (x1, 0) and its upper end at some point (x2, y2), where x1 <= x2, y2 >= 0, and the condition x2 - x1 <= w must be satisfied for each rectangle.\nA point is considered covered by a rectangle if it lies within or on the boundary of the rectangle.\nReturn an integer denoting the minimum number of rectangles needed so that each point is covered by at least one rectangle.\nNote: A point may be covered by more than one rectangle.\n \nExample 1:\n\n\nInput: points = [[2,1],[1,0],[1,4],[1,8],[3,5],[4,6]], w = 1\nOutput: 2\nExplanation: \nThe image above shows one possible placement of rectangles to cover the points:\n\nA rectangle with a lower end at (1, 0) and its upper end at (2, 8)\nA rectangle with a lower end at (3, 0) and its upper end at (4, 8)\n\n\nExample 2:\n\n\nInput: points = [[0,0],[1,1],[2,2],[3,3],[4,4],[5,5],[6,6]], w = 2\nOutput: 3\nExplanation: \nThe image above shows one possible placement of rectangles to cover the points:\n\nA rectangle with a lower end at (0, 0) and its upper end at (2, 2)\nA rectangle with a lower end at (3, 0) and its upper end at (5, 5)\nA rectangle with a lower end at (6, 0) and its upper end at (6, 6)\n\n\nExample 3:\n\n\nInput: points = [[2,3],[1,2]], w = 0\nOutput: 2\nExplanation: \nThe image above shows one possible placement of rectangles to cover the points:\n\nA rectangle with a lower end at (1, 0) and its upper end at (1, 2)\nA rectangle with a lower end at (2, 0) and its upper end at (2, 3)\n\n\n \nConstraints:\n\n1 <= points.length <= 105\npoints[i].length == 2\n0 <= xi == points[i][0] <= 109\n0 <= yi == points[i][1] <= 109\n0 <= w <= 109\nAll pairs (xi, yi) are distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(points = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50]],w = 1) == 3\n assert candidate(points = [[5, 5], [10, 10], [15, 15]],w = 5) == 2\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],w = 3) == 3\n assert candidate(points = [[2, 3], [1, 2]],w = 0) == 2\n assert candidate(points = [[5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],w = 2) == 2\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6]],w = 2) == 3\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],w = 10) == 1\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],w = 4) == 1\n assert candidate(points = [[1, 1], [3, 3], [5, 5], [7, 7], [9, 9]],w = 2) == 3\n assert candidate(points = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500]],w = 150) == 3\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],w = 1) == 5\n assert candidate(points = [[10, 10], [20, 20], [30, 30]],w = 10) == 2\n assert candidate(points = [[100, 100], [101, 101], [102, 102], [103, 103]],w = 2) == 2\n assert candidate(points = [[2, 1], [1, 0], [1, 4], [1, 8], [3, 5], [4, 6]],w = 1) == 2\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],w = 2) == 4\n assert candidate(points = [[5, 5], [10, 10], [15, 15], [20, 20]],w = 5) == 2\n assert candidate(points = [[1, 1], [3, 3], [5, 5], [7, 7], [9, 9], [11, 11], [13, 13], [15, 15]],w = 2) == 4\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5]],w = 0) == 1\n assert candidate(points = [[5, 10], [6, 20], [7, 30], [8, 40], [9, 50], [10, 60], [11, 70], [12, 80], [13, 90], [14, 100], [15, 110], [16, 120], [17, 130]],w = 2) == 5\n assert candidate(points = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5], [11, 5], [12, 5], [13, 5], [14, 5], [15, 5]],w = 3) == 4\n assert candidate(points = [[1, 5], [2, 3], [4, 8], [6, 10], [7, 6], [9, 12]],w = 3) == 2\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],w = 1) == 5\n assert candidate(points = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1], [11, 10], [12, 9], [13, 8], [14, 7], [15, 6], [16, 5], [17, 4], [18, 3], [19, 2], [20, 1]],w = 2) == 7\n assert candidate(points = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]],w = 1) == 5\n assert candidate(points = [[1, 100], [2, 90], [3, 80], [4, 70], [5, 60], [6, 50], [7, 40], [8, 30], [9, 20], [10, 10]],w = 1) == 5\n assert candidate(points = [[5, 5], [10, 15], [15, 25], [20, 35], [25, 45], [30, 55], [35, 65], [40, 75], [45, 85], [50, 95]],w = 10) == 4\n assert candidate(points = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [10, 10]],w = 1) == 5\n assert candidate(points = [[5, 5], [10, 10], [15, 15], [20, 20], [25, 25], [30, 30], [35, 35], [40, 40], [45, 45], [50, 50], [55, 55], [60, 60], [65, 65], [70, 70], [75, 75], [80, 80], [85, 85], [90, 90], [95, 95], [100, 100]],w = 15) == 5\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],w = 0) == 1\n assert candidate(points = [[100, 100], [101, 101], [102, 102], [103, 103], [104, 104], [105, 105], [106, 106], [107, 107], [108, 108], [109, 109]],w = 3) == 3\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3], [4, 1], [4, 2], [4, 3], [5, 1], [5, 2], [5, 3]],w = 1) == 3\n assert candidate(points = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],w = 1) == 1\n assert candidate(points = [[1000000000, 1], [999999999, 2], [999999998, 3], [999999997, 4], [999999996, 5], [999999995, 6]],w = 1) == 3\n assert candidate(points = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]],w = 3) == 3\n assert candidate(points = [[1, 5], [2, 4], [3, 3], [4, 2], [5, 1], [6, 0], [7, 1], [8, 2], [9, 3], [10, 4]],w = 1) == 5\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],w = 2) == 1\n assert candidate(points = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]],w = 5) == 2\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1], [14, 1], [15, 1]],w = 4) == 3\n assert candidate(points = [[1, 9], [3, 8], [5, 7], [7, 6], [9, 5], [11, 4], [13, 3], [15, 2], [17, 1], [19, 0]],w = 2) == 5\n assert candidate(points = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5]],w = 0) == 2\n assert candidate(points = [[1, 5], [3, 6], [5, 7], [7, 8], [9, 9], [11, 10], [13, 11], [15, 12], [17, 13], [19, 14]],w = 5) == 4\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]],w = 3) == 4\n assert candidate(points = [[0, 10], [1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1]],w = 2) == 4\n assert candidate(points = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5]],w = 2) == 4\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1], [14, 1], [15, 1], [16, 1], [17, 1], [18, 1], [19, 1], [20, 1], [21, 1], [22, 1], [23, 1], [24, 1], [25, 1]],w = 3) == 7\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20], [21, 21], [22, 22], [23, 23], [24, 24], [25, 25], [26, 26], [27, 27], [28, 28], [29, 29], [30, 30]],w = 3) == 8\n assert candidate(points = [[1, 1], [2, 3], [3, 5], [4, 7], [5, 9], [6, 11], [7, 13], [8, 15], [9, 17], [10, 19]],w = 4) == 2\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20]],w = 5) == 4\n assert candidate(points = [[10, 5], [12, 7], [14, 9], [16, 11], [18, 13], [20, 15]],w = 5) == 2\n assert candidate(points = [[1, 1], [1, 10], [1, 20], [1, 30], [1, 40], [1, 50], [1, 60], [1, 70], [1, 80], [1, 90], [1, 100]],w = 1) == 1\n assert candidate(points = [[0, 10], [1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1]],w = 4) == 2\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],w = 1) == 1\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13]],w = 4) == 3\n assert candidate(points = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2], [3, 0], [3, 1], [3, 2]],w = 2) == 2\n assert candidate(points = [[0, 0], [2, 2], [4, 4], [6, 6], [8, 8], [10, 10], [12, 12], [14, 14], [16, 16]],w = 3) == 5\n assert candidate(points = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]],w = 1) == 5\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1], [14, 1], [15, 1], [16, 1], [17, 1], [18, 1], [19, 1], [20, 1], [21, 1], [22, 1], [23, 1], [24, 1], [25, 1], [26, 1], [27, 1], [28, 1], [29, 1], [30, 1]],w = 2) == 10\n assert candidate(points = [[1, 100], [2, 90], [3, 80], [4, 70], [5, 60], [6, 50], [7, 40], [8, 30], [9, 20], [10, 10]],w = 5) == 2\n assert candidate(points = [[1, 1], [3, 1], [5, 1], [7, 1], [9, 1], [11, 1], [13, 1], [15, 1], [17, 1], [19, 1], [21, 1], [23, 1], [25, 1]],w = 4) == 5\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]],w = 1) == 5\n assert candidate(points = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5]],w = 4) == 2\n assert candidate(points = [[1000000000, 1000000000], [500000000, 500000000], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4]],w = 500000000) == 2\n assert candidate(points = [[0, 0], [1, 1], [2, 1], [3, 2], [4, 2], [5, 3], [6, 3], [7, 4], [8, 4], [9, 5], [10, 5]],w = 2) == 4\n assert candidate(points = [[10, 5], [15, 8], [20, 12], [25, 15], [30, 20], [35, 25], [40, 30], [45, 35], [50, 40]],w = 5) == 5\n assert candidate(points = [[5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10]],w = 0) == 1\n assert candidate(points = [[1, 1], [10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]],w = 10) == 6\n assert candidate(points = [[1, 10], [2, 11], [3, 12], [4, 13], [5, 14], [6, 15], [7, 16], [8, 17], [9, 18], [10, 19]],w = 5) == 2\n assert candidate(points = [[1000000000, 1000000000], [999999999, 999999999], [999999998, 999999998], [999999997, 999999997]],w = 3) == 1\n assert candidate(points = [[1, 10], [1, 20], [1, 30], [1, 40], [1, 50], [1, 60], [1, 70], [1, 80], [1, 90], [1, 100], [1, 110]],w = 0) == 1\n assert candidate(points = [[1, 5], [2, 4], [3, 3], [4, 2], [5, 1]],w = 2) == 2\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],w = 5) == 2\n assert candidate(points = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10]],w = 2) == 2\n assert candidate(points = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26]],w = 2) == 9\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [1, 20]],w = 2) == 1\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1], [14, 1], [15, 1], [16, 1], [17, 1], [18, 1], [19, 1], [20, 1]],w = 3) == 5\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1], [14, 1], [15, 1]],w = 3) == 4\n assert candidate(points = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [10, 10], [11, 10], [12, 10], [13, 10], [14, 10], [15, 10]],w = 2) == 5\n assert candidate(points = [[1, 10], [2, 15], [3, 20], [4, 25], [5, 30], [6, 35]],w = 2) == 2\n assert candidate(points = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]],w = 2) == 4\n assert candidate(points = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10]],w = 10) == 5\n assert candidate(points = [[1, 5], [3, 10], [5, 15], [7, 20], [9, 25], [11, 30], [13, 35], [15, 40], [17, 45], [19, 50], [21, 55], [23, 60], [25, 65]],w = 5) == 5\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15]],w = 2) == 1\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]],w = 7) == 2\n assert candidate(points = [[0, 10], [5, 20], [10, 30], [15, 40], [20, 50], [25, 60]],w = 5) == 3\n assert candidate(points = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18]],w = 2) == 5\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1], [14, 1], [15, 1], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2], [8, 2], [9, 2], [10, 2], [11, 2], [12, 2], [13, 2], [14, 2], [15, 2]],w = 2) == 5\n assert candidate(points = [[1, 10], [2, 15], [3, 20], [4, 25], [5, 30], [6, 35], [7, 40], [8, 45], [9, 50], [10, 55]],w = 5) == 2\n assert candidate(points = [[1, 1], [10, 2], [19, 3], [28, 4], [37, 5], [46, 6], [55, 7], [64, 8], [73, 9], [82, 10], [91, 11], [100, 12], [109, 13], [118, 14], [127, 15], [136, 16], [145, 17], [154, 18], [163, 19], [172, 20]],w = 9) == 10\n assert candidate(points = [[5, 10], [10, 20], [15, 30], [20, 40], [25, 50], [30, 60], [35, 70], [40, 80], [45, 90], [50, 100]],w = 10) == 4\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3]],w = 1) == 2\n assert candidate(points = [[1, 10], [5, 5], [10, 1], [20, 20], [25, 25], [30, 30], [35, 35]],w = 15) == 2\n assert candidate(points = [[10, 1], [11, 2], [12, 3], [13, 4], [14, 5], [15, 6], [16, 7]],w = 3) == 2\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],w = 5) == 1\n assert candidate(points = [[100, 200], [105, 210], [110, 220], [115, 230], [120, 240], [125, 250], [130, 260]],w = 5) == 4\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5]],w = 1) == 1\n assert candidate(points = [[0, 10], [1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10]],w = 2) == 4\n assert candidate(points = [[10, 5], [15, 15], [20, 25], [25, 35], [30, 45], [35, 55], [40, 65], [45, 75], [50, 85], [55, 95]],w = 10) == 4\n assert candidate(points = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],w = 5) == 1\n assert candidate(points = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [10, 10]],w = 3) == 3\n assert candidate(points = [[1, 2], [4, 5], [7, 8], [10, 11], [13, 14], [16, 17], [19, 20]],w = 5) == 4\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1]],w = 3) == 4\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],w = 2) == 4\n assert candidate(points = [[5, 5], [10, 15], [15, 25], [20, 35], [25, 45], [30, 55], [35, 65], [40, 75], [45, 85], [50, 95]],w = 15) == 3\n assert candidate(points = [[10, 10], [11, 10], [12, 10], [13, 10], [14, 10], [15, 10], [16, 10], [17, 10], [18, 10], [19, 10]],w = 1) == 5\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10]],w = 1) == 1\n assert candidate(points = [[1, 100], [2, 150], [3, 200], [4, 250], [5, 300], [6, 350], [7, 400], [8, 450], [9, 500], [10, 550]],w = 300) == 1\n assert candidate(points = [[1, 100], [2, 90], [3, 80], [4, 70], [5, 60], [6, 50], [7, 40], [8, 30], [9, 20], [10, 10]],w = 15) == 1\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]],w = 2) == 5\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13]],w = 2) == 5\n assert candidate(points = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],w = 3) == 3\n assert candidate(points = [[5, 1], [6, 2], [7, 3], [8, 4], [9, 5], [10, 6], [11, 7], [12, 8], [13, 9], [14, 10]],w = 2) == 4\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],w = 10) == 1\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20]],w = 5) == 4\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20], [21, 21], [22, 22], [23, 23], [24, 24], [25, 25]],w = 5) == 5\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11]],w = 4) == 3\n assert candidate(points = [[5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50]],w = 10) == 3\n assert candidate(points = [[1, 10], [2, 11], [3, 12], [4, 13], [5, 14], [6, 15], [7, 16], [8, 17], [9, 18], [10, 19]],w = 4) == 2\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11]],w = 3) == 3\n"}, "metadata": {"canonical_parameter_names": ["points", "w"], "leetcode_dataset_entry_point": "Solution().minRectanglesToCoverPoints", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minRectanglesToCoverPoints(vector>& points, int w) {", "container": "Solution", "callable": "minRectanglesToCoverPoints", "parameters": [{"name": "points", "type": "vector>&"}, {"name": "w", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3112, "task_id": "minimum-time-to-visit-disappearing-nodes", "difficulty": "Medium", "problem_description": "There is an undirected graph of n nodes. You are given a 2D array edges, where edges[i] = [ui, vi, lengthi] describes an edge between node ui and node vi with a traversal time of lengthi units.\nAdditionally, you are given an array disappear, where disappear[i] denotes the time when the node i disappears from the graph and you won't be able to visit it.\nNote that the graph might be disconnected and might contain multiple edges.\nReturn the array answer, with answer[i] denoting the minimum units of time required to reach node i from node 0. If node i is unreachable from node 0 then answer[i] is -1.\n \nExample 1:\n\nInput: n = 3, edges = [[0,1,2],[1,2,1],[0,2,4]], disappear = [1,1,5]\nOutput: [0,-1,4]\nExplanation:\n\nWe are starting our journey from node 0, and our goal is to find the minimum time required to reach each node before it disappears.\n\nFor node 0, we don't need any time as it is our starting point.\nFor node 1, we need at least 2 units of time to traverse edges[0]. Unfortunately, it disappears at that moment, so we won't be able to visit it.\nFor node 2, we need at least 4 units of time to traverse edges[2].\n\n\nExample 2:\n\nInput: n = 3, edges = [[0,1,2],[1,2,1],[0,2,4]], disappear = [1,3,5]\nOutput: [0,2,3]\nExplanation:\n\nWe are starting our journey from node 0, and our goal is to find the minimum time required to reach each node before it disappears.\n\nFor node 0, we don't need any time as it is the starting point.\nFor node 1, we need at least 2 units of time to traverse edges[0].\nFor node 2, we need at least 3 units of time to traverse edges[0] and edges[1].\n\n\nExample 3:\n\nInput: n = 2, edges = [[0,1,1]], disappear = [1,1]\nOutput: [0,-1]\nExplanation:\nExactly when we reach node 1, it disappears.\n\n \nConstraints:\n\n1 <= n <= 5 * 104\n0 <= edges.length <= 105\nedges[i] == [ui, vi, lengthi]\n0 <= ui, vi <= n - 1\n1 <= lengthi <= 105\ndisappear.length == n\n1 <= disappear[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 2,edges = [[0, 1, 1]],disappear = [1, 1]) == [0, -1]\n assert candidate(n = 6,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5]],disappear = [1, 2, 3, 4, 5, 6]) == [0, 1, -1, -1, -1, -1]\n assert candidate(n = 4,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 0, 4]],disappear = [10, 10, 10, 10]) == [0, 1, 3, 4]\n assert candidate(n = 1,edges = [],disappear = [1]) == [0]\n assert candidate(n = 5,edges = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5]],disappear = [5, 6, 7, 8, 9]) == [0, 2, 5, -1, -1]\n assert candidate(n = 5,edges = [[0, 1, 5], [0, 2, 3], [1, 3, 1], [2, 3, 2], [2, 4, 6]],disappear = [10, 5, 4, 8, 7]) == [0, -1, 3, 5, -1]\n assert candidate(n = 4,edges = [[0, 1, 1], [0, 2, 2], [0, 3, 3]],disappear = [2, 3, 4, 5]) == [0, 1, 2, 3]\n assert candidate(n = 5,edges = [[0, 1, 5], [1, 2, 3], [2, 3, 4], [3, 4, 2], [4, 0, 6]],disappear = [10, 20, 30, 40, 50]) == [0, 5, 8, 8, 6]\n assert candidate(n = 3,edges = [[0, 1, 2], [1, 2, 1], [0, 2, 4]],disappear = [1, 3, 5]) == [0, 2, 3]\n assert candidate(n = 5,edges = [[0, 1, 2], [1, 2, 2], [2, 3, 1], [3, 4, 3]],disappear = [1, 2, 3, 4, 5]) == [0, -1, -1, -1, -1]\n assert candidate(n = 6,edges = [[0, 1, 10], [0, 2, 15], [1, 3, 5], [2, 3, 20], [3, 4, 10], [4, 5, 5]],disappear = [100, 200, 300, 400, 500, 600]) == [0, 10, 15, 15, 25, 30]\n assert candidate(n = 4,edges = [[0, 1, 2], [1, 2, 2], [2, 3, 1], [0, 3, 3]],disappear = [1, 5, 4, 6]) == [0, 2, -1, 3]\n assert candidate(n = 3,edges = [[0, 1, 2], [1, 2, 1], [0, 2, 4]],disappear = [1, 1, 5]) == [0, -1, 4]\n assert candidate(n = 5,edges = [[0, 1, 2], [0, 2, 3], [1, 3, 1], [2, 4, 4]],disappear = [10, 5, 6, 7, 8]) == [0, 2, 3, 3, 7]\n assert candidate(n = 4,edges = [[0, 1, 2], [1, 2, 2], [2, 3, 1], [0, 3, 4]],disappear = [1, 2, 3, 4]) == [0, -1, -1, -1]\n assert candidate(n = 6,edges = [[0, 1, 1], [0, 2, 1], [1, 3, 1], [2, 4, 1], [3, 5, 1], [4, 5, 1]],disappear = [10, 10, 10, 10, 10, 10]) == [0, 1, 1, 2, 2, 3]\n assert candidate(n = 4,edges = [[0, 1, 5], [1, 2, 3], [2, 3, 2]],disappear = [10, 10, 10, 10]) == [0, 5, 8, -1]\n assert candidate(n = 4,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3]],disappear = [5, 6, 7, 8]) == [0, 1, 3, 6]\n assert candidate(n = 7,edges = [[0, 1, 3], [0, 2, 4], [1, 3, 1], [1, 4, 2], [2, 4, 3], [2, 5, 5], [3, 6, 6], [4, 6, 7]],disappear = [20, 25, 30, 35, 40, 45, 50]) == [0, 3, 4, 4, 5, 9, 10]\n assert candidate(n = 7,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [0, 6, 6]],disappear = [2, 3, 4, 5, 6, 7, 8]) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(n = 6,edges = [[0, 1, 10], [0, 2, 5], [0, 3, 3], [1, 2, 2], [2, 3, 1], [3, 4, 4], [4, 5, 6]],disappear = [100, 150, 200, 250, 300, 350]) == [0, 6, 4, 3, 7, 13]\n assert candidate(n = 9,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8]],disappear = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == [0, 1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(n = 9,edges = [[0, 1, 5], [0, 2, 8], [1, 3, 6], [2, 4, 3], [3, 5, 2], [4, 6, 4], [5, 7, 7], [6, 8, 10], [7, 8, 5], [0, 8, 12], [1, 5, 4], [2, 6, 9]],disappear = [30, 40, 50, 60, 70, 80, 90, 100, 110]) == [0, 5, 8, 11, 11, 9, 15, 16, 12]\n assert candidate(n = 9,edges = [[0, 1, 5], [0, 2, 4], [1, 3, 3], [1, 4, 2], [2, 5, 1], [2, 6, 6], [3, 7, 7], [4, 8, 8], [5, 8, 9], [6, 8, 10]],disappear = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == [0, 5, 4, 8, 7, 5, 10, 15, 14]\n assert candidate(n = 15,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [1, 4, 4], [2, 5, 5], [2, 6, 6], [3, 7, 7], [3, 8, 8], [4, 9, 9], [4, 10, 10], [5, 11, 11], [5, 12, 12], [6, 13, 13], [6, 14, 14]],disappear = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15]) == [0, 1, 2, 4, 5, 7, 8, 11, 12, 14, -1, -1, -1, -1, -1]\n assert candidate(n = 8,edges = [[0, 1, 2], [0, 2, 4], [1, 2, 1], [1, 3, 3], [2, 4, 5], [3, 5, 2], [3, 6, 7], [5, 7, 8]],disappear = [10, 9, 8, 7, 6, 5, 4, 3]) == [0, 2, 3, 5, -1, -1, -1, -1]\n assert candidate(n = 5,edges = [[0, 1, 10], [0, 2, 5], [1, 2, 2], [2, 3, 3], [3, 4, 1]],disappear = [1, 10, 15, 20, 25]) == [0, 7, 5, 8, 9]\n assert candidate(n = 9,edges = [[0, 1, 1], [0, 2, 1], [0, 3, 1], [1, 4, 1], [1, 5, 1], [2, 6, 1], [2, 7, 1], [3, 8, 1]],disappear = [5, 5, 5, 5, 5, 5, 5, 5, 5]) == [0, 1, 1, 1, 2, 2, 2, 2, 2]\n assert candidate(n = 10,edges = [[0, 1, 10], [0, 2, 15], [1, 3, 5], [2, 3, 20], [3, 4, 10], [4, 5, 5], [5, 6, 10], [6, 7, 5], [7, 8, 3], [8, 9, 4]],disappear = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [0, 10, 15, 15, 25, 30, 40, 45, 48, 52]\n assert candidate(n = 8,edges = [[0, 1, 1], [0, 2, 1], [1, 2, 1], [1, 3, 2], [2, 3, 2], [3, 4, 3], [3, 5, 3], [4, 5, 4], [4, 6, 5], [5, 6, 5], [5, 7, 6], [6, 7, 6]],disappear = [1, 2, 3, 4, 5, 6, 7, 8]) == [0, 1, 1, 3, -1, -1, -1, -1]\n assert candidate(n = 10,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [1, 4, 4], [2, 5, 5], [3, 6, 6], [4, 7, 7], [5, 8, 8], [6, 9, 9]],disappear = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6]) == [0, 1, 2, -1, -1, 7, -1, -1, -1, -1]\n assert candidate(n = 12,edges = [[0, 1, 10], [0, 2, 20], [0, 3, 30], [0, 4, 40], [1, 5, 50], [1, 6, 60], [2, 7, 70], [2, 8, 80], [3, 9, 90], [4, 10, 100], [5, 11, 110], [6, 11, 110], [7, 11, 110], [8, 11, 110], [9, 11, 110], [10, 11, 110]],disappear = [120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120]) == [0, 10, 20, 30, 40, 60, 70, 90, 100, -1, -1, -1]\n assert candidate(n = 7,edges = [[0, 1, 2], [0, 2, 2], [1, 3, 2], [1, 4, 2], [2, 5, 2], [2, 6, 2], [3, 4, 2], [5, 6, 2]],disappear = [10, 20, 30, 40, 50, 60, 70]) == [0, 2, 2, 4, 4, 4, 4]\n assert candidate(n = 15,edges = [[0, 1, 2], [0, 2, 3], [1, 3, 4], [1, 4, 5], [2, 5, 6], [2, 6, 7], [3, 7, 8], [3, 8, 9], [4, 8, 10], [4, 9, 11], [5, 9, 12], [5, 10, 13], [6, 10, 14], [6, 11, 15], [7, 11, 16], [7, 12, 17], [8, 12, 18], [8, 13, 19], [9, 13, 20], [9, 14, 21], [10, 14, 22]],disappear = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == [0, 2, 3, 6, 7, 9, 10, 14, 15, 18, 22, 25, 31, 34, 39]\n assert candidate(n = 5,edges = [[0, 1, 1], [0, 2, 2], [1, 2, 1], [2, 3, 2], [3, 4, 1], [4, 0, 3]],disappear = [1, 2, 3, 4, 5]) == [0, 1, 2, -1, 3]\n assert candidate(n = 6,edges = [[0, 1, 5], [0, 2, 5], [1, 2, 10], [1, 3, 10], [2, 3, 1], [2, 4, 15], [3, 5, 10], [4, 5, 1]],disappear = [10, 20, 30, 40, 50, 60]) == [0, 5, 5, 6, 17, 16]\n assert candidate(n = 8,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [0, 3, 15], [3, 6, 10]],disappear = [5, 6, 7, 8, 9, 10, 11, 12]) == [0, 1, 3, 6, -1, -1, -1, -1]\n assert candidate(n = 10,edges = [[0, 1, 10], [0, 2, 20], [1, 3, 5], [2, 4, 15], [3, 5, 25], [4, 6, 30], [5, 7, 35], [6, 8, 40], [7, 9, 45]],disappear = [100, 150, 200, 250, 300, 350, 400, 450, 500, 550]) == [0, 10, 20, 15, 35, 40, 65, 75, 105, 120]\n assert candidate(n = 15,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 0, 15]],disappear = [16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == [0, 1, 3, 6, 10, 15, 21, -1, -1, -1, -1, -1, -1, -1, 15]\n assert candidate(n = 12,edges = [[0, 1, 10], [0, 2, 10], [1, 3, 15], [2, 4, 15], [3, 5, 20], [4, 6, 20], [5, 7, 25], [6, 8, 25], [7, 9, 30], [8, 10, 30], [9, 11, 35], [10, 11, 35]],disappear = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125]) == [0, 10, 10, 25, 25, 45, 45, 70, 70, 100, 100, -1]\n assert candidate(n = 10,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [2, 4, 4], [3, 5, 5], [4, 6, 6], [5, 7, 7], [6, 8, 8], [7, 9, 9], [8, 0, 10], [9, 1, 11]],disappear = [12, 13, 14, 15, 16, 17, 18, 19, 20, 21]) == [0, 1, 2, 4, 6, 9, 12, 16, 10, 12]\n assert candidate(n = 10,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [1, 4, 4], [2, 5, 5], [2, 6, 6], [3, 7, 7], [4, 8, 8], [5, 9, 9], [6, 7, 10], [7, 8, 11], [8, 9, 12]],disappear = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 1, 2, 4, 5, -1, -1, -1, -1, -1]\n assert candidate(n = 8,edges = [[0, 1, 5], [0, 2, 3], [1, 3, 2], [2, 4, 4], [3, 4, 6], [4, 5, 1], [5, 6, 3], [6, 7, 2]],disappear = [30, 40, 50, 60, 70, 80, 90, 100]) == [0, 5, 3, 7, 7, 8, 11, 13]\n assert candidate(n = 20,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1], [10, 11, 1], [11, 12, 1], [12, 13, 1], [13, 14, 1], [14, 15, 1], [15, 16, 1], [16, 17, 1], [17, 18, 1], [18, 19, 1]],disappear = [20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(n = 7,edges = [[0, 1, 10], [1, 2, 5], [2, 3, 3], [3, 4, 8], [4, 5, 7], [5, 6, 2], [0, 6, 15], [1, 3, 12], [2, 5, 9], [3, 6, 10]],disappear = [20, 30, 40, 50, 60, 70, 80]) == [0, 10, 15, 18, 24, 17, 15]\n assert candidate(n = 20,edges = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10], [9, 10, 11], [10, 11, 12], [11, 12, 13], [12, 13, 14], [13, 14, 15], [14, 15, 16], [15, 16, 17], [16, 17, 18], [17, 18, 19], [18, 19, 20], [0, 19, 100]],disappear = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == [0, 2, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(n = 10,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9]],disappear = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(n = 6,edges = [[0, 1, 2], [0, 2, 3], [1, 3, 4], [2, 4, 5], [3, 5, 6], [4, 5, 7], [0, 5, 1], [1, 4, 2], [2, 3, 3]],disappear = [5, 6, 7, 8, 9, 10]) == [0, 2, 3, 6, 4, 1]\n assert candidate(n = 12,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [1, 4, 4], [2, 5, 5], [2, 6, 6], [3, 7, 7], [4, 8, 8], [5, 9, 9], [6, 10, 10], [7, 11, 11], [8, 11, 12], [0, 11, 5], [1, 10, 4], [2, 9, 3], [3, 8, 2], [4, 7, 1], [5, 6, 6]],disappear = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == [0, 1, 2, 4, 5, 7, 8, 6, 6, 5, 5, 5]\n assert candidate(n = 12,edges = [[0, 1, 5], [0, 2, 5], [1, 3, 5], [1, 4, 5], [2, 5, 5], [2, 6, 5], [3, 7, 5], [3, 8, 5], [4, 9, 5], [4, 10, 5], [5, 11, 5], [6, 11, 5], [7, 8, 5], [9, 10, 5]],disappear = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 1, 5]) == [0, 5, 5, 10, 10, 10, 10, 15, 15, -1, -1, -1]\n assert candidate(n = 7,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6]],disappear = [7, 8, 9, 10, 11, 12, 13]) == [0, 1, 3, 6, 10, -1, -1]\n assert candidate(n = 10,edges = [[0, 1, 5], [0, 2, 5], [1, 3, 5], [1, 4, 5], [2, 5, 5], [2, 6, 5], [3, 7, 5], [4, 8, 5], [5, 9, 5], [6, 8, 5], [7, 9, 5]],disappear = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == [0, 5, 5, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(n = 7,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [1, 4, 4], [2, 5, 5], [2, 6, 6], [3, 4, 7], [5, 6, 8]],disappear = [2, 4, 6, 8, 10, 12, 14]) == [0, 1, 2, 4, 5, 7, 8]\n assert candidate(n = 9,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 0, 9]],disappear = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == [0, 1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(n = 9,edges = [[0, 1, 1], [0, 2, 1], [1, 3, 1], [1, 4, 1], [2, 5, 1], [2, 6, 1], [3, 7, 1], [4, 8, 1], [5, 8, 1], [6, 8, 1]],disappear = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == [0, 1, 1, 2, 2, 2, 2, 3, 3]\n assert candidate(n = 10,edges = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10], [0, 9, 100]],disappear = [10, 12, 14, 16, 18, 20, 22, 24, 26, 28]) == [0, 2, 5, 9, 14, -1, -1, -1, -1, -1]\n assert candidate(n = 12,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 0, 12]],disappear = [13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]) == [0, 1, 3, 6, 10, 15, -1, -1, -1, -1, -1, 12]\n assert candidate(n = 5,edges = [[0, 1, 1], [0, 2, 1], [0, 3, 1], [0, 4, 1], [1, 2, 1], [1, 3, 1], [1, 4, 1], [2, 3, 1], [2, 4, 1], [3, 4, 1]],disappear = [2, 3, 4, 5, 6]) == [0, 1, 1, 1, 1]\n assert candidate(n = 7,edges = [[0, 1, 2], [1, 2, 3], [2, 3, 1], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 0, 8]],disappear = [3, 4, 5, 6, 7, 8, 9]) == [0, 2, -1, -1, -1, -1, 8]\n assert candidate(n = 6,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 0, 1]],disappear = [2, 3, 4, 5, 6, 7]) == [0, 1, 2, 3, 2, 1]\n assert candidate(n = 10,edges = [[0, 1, 5], [0, 2, 10], [1, 3, 2], [2, 3, 1], [3, 4, 3], [4, 5, 1], [5, 6, 4], [6, 7, 2], [7, 8, 3], [8, 9, 1]],disappear = [15, 20, 25, 30, 35, 40, 45, 50, 55, 60]) == [0, 5, 8, 7, 10, 11, 15, 17, 20, 21]\n assert candidate(n = 11,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10]],disappear = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [0, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(n = 15,edges = [[0, 1, 1], [0, 2, 2], [0, 3, 3], [1, 4, 4], [2, 5, 5], [3, 6, 6], [4, 7, 7], [5, 8, 8], [6, 9, 9], [7, 10, 10], [8, 11, 11], [9, 12, 12], [10, 13, 13], [11, 14, 14]],disappear = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(n = 6,edges = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50], [5, 0, 60]],disappear = [15, 25, 35, 45, 55, 65]) == [0, 10, 30, -1, -1, 60]\n assert candidate(n = 10,edges = [[0, 1, 10], [0, 2, 20], [1, 3, 5], [1, 4, 50], [2, 5, 15], [2, 6, 25], [3, 7, 5], [4, 8, 10], [5, 9, 20], [6, 9, 15]],disappear = [100, 110, 120, 130, 140, 150, 160, 170, 180, 190]) == [0, 10, 20, 15, 60, 35, 45, 20, 70, 55]\n assert candidate(n = 5,edges = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 0, 50], [0, 3, 15], [2, 4, 25]],disappear = [25, 30, 35, 40, 45]) == [0, 10, 30, 15, -1]\n assert candidate(n = 8,edges = [[0, 1, 2], [1, 2, 3], [2, 3, 1], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [0, 7, 10]],disappear = [3, 4, 5, 6, 7, 8, 9, 10]) == [0, 2, -1, -1, -1, -1, -1, -1]\n assert candidate(n = 20,edges = [[0, 1, 5], [1, 2, 5], [2, 3, 5], [3, 4, 5], [4, 5, 5], [0, 6, 5], [1, 7, 5], [2, 8, 5], [3, 9, 5], [4, 10, 5], [5, 11, 5], [6, 7, 5], [7, 8, 5], [8, 9, 5], [9, 10, 5], [10, 11, 5], [11, 12, 5], [12, 13, 5], [13, 14, 5], [14, 15, 5], [15, 16, 5], [16, 17, 5], [17, 18, 5], [18, 19, 5]],disappear = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6]) == [0, 5, 10, 15, 20, -1, 5, 10, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(n = 8,edges = [[0, 1, 1], [0, 2, 1], [1, 3, 1], [1, 4, 1], [2, 5, 1], [2, 6, 1], [3, 7, 1], [4, 7, 1], [5, 7, 1], [6, 7, 1]],disappear = [10, 9, 8, 7, 6, 5, 4, 3]) == [0, 1, 1, 2, 2, 2, 2, -1]\n assert candidate(n = 12,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1], [10, 11, 1]],disappear = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(n = 5,edges = [[0, 1, 2], [1, 2, 3], [1, 3, 1], [2, 4, 4], [3, 4, 5]],disappear = [10, 10, 10, 10, 10]) == [0, 2, 5, 3, 8]\n assert candidate(n = 15,edges = [[0, 1, 5], [0, 2, 10], [0, 3, 15], [1, 4, 20], [2, 5, 25], [3, 6, 30], [4, 7, 35], [5, 8, 40], [6, 9, 45], [7, 10, 50], [8, 11, 55], [9, 12, 60], [10, 13, 65], [11, 14, 70], [12, 13, 5], [13, 14, 10]],disappear = [30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170]) == [0, 5, 10, 15, 25, 35, 45, 60, 75, 90, 110, 130, -1, -1, -1]\n assert candidate(n = 5,edges = [[0, 1, 5], [0, 2, 3], [1, 2, 10], [1, 3, 6], [2, 4, 7], [3, 4, 8]],disappear = [15, 20, 25, 30, 35]) == [0, 5, 3, 11, 10]\n assert candidate(n = 15,edges = [[0, 1, 2], [0, 4, 5], [1, 2, 3], [1, 3, 2], [2, 3, 1], [3, 4, 2], [4, 5, 2], [5, 6, 1], [6, 7, 3], [7, 8, 4], [8, 9, 2], [9, 10, 1], [10, 11, 5], [11, 12, 6], [12, 13, 3], [13, 14, 2]],disappear = [15, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 1]) == [0, 2, 5, 4, 5, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(n = 12,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1], [10, 11, 1], [11, 0, 1]],disappear = [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 5, -1, -1, -1, -1, -1, -1]\n assert candidate(n = 8,edges = [[0, 1, 10], [0, 2, 20], [1, 3, 15], [1, 4, 25], [2, 3, 30], [2, 5, 25], [3, 6, 10], [4, 6, 5], [5, 7, 5], [6, 7, 15]],disappear = [100, 200, 150, 250, 300, 350, 400, 450]) == [0, 10, 20, 25, 35, 45, 35, 50]\n assert candidate(n = 10,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 1], [2, 4, 2], [3, 5, 1], [4, 6, 2], [5, 7, 1], [6, 8, 2], [7, 9, 1]],disappear = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6]) == [0, 1, 2, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(n = 8,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7]],disappear = [2, 4, 6, 8, 10, 12, 14, 16]) == [0, 1, 3, 6, -1, -1, -1, -1]\n assert candidate(n = 8,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [1, 4, 4], [2, 5, 5], [2, 6, 6], [3, 7, 7], [4, 7, 8]],disappear = [1, 2, 3, 4, 5, 6, 7, 8]) == [0, 1, 2, -1, -1, -1, -1, -1]\n assert candidate(n = 15,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [1, 4, 4], [2, 5, 5], [2, 6, 6], [3, 7, 7], [4, 8, 8], [5, 9, 9], [6, 10, 10], [7, 11, 11], [8, 12, 12], [9, 13, 13], [10, 14, 14]],disappear = [20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20]) == [0, 1, 2, 4, 5, 7, 8, 11, 13, 16, 18, -1, -1, -1, -1]\n assert candidate(n = 5,edges = [[0, 1, 1], [0, 2, 1], [0, 3, 1], [1, 2, 1], [1, 3, 1], [2, 3, 1], [2, 4, 1], [3, 4, 1]],disappear = [5, 5, 5, 5, 5]) == [0, 1, 1, 1, 2]\n assert candidate(n = 10,edges = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50], [5, 6, 60], [6, 7, 70], [7, 8, 80], [8, 9, 90], [9, 0, 100], [0, 2, 15], [1, 3, 25]],disappear = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500]) == [0, 10, 15, 35, 75, 125, 185, 255, 190, 100]\n assert candidate(n = 10,edges = [[0, 1, 5], [0, 2, 3], [1, 3, 2], [1, 4, 7], [2, 5, 1], [3, 6, 4], [4, 7, 3], [5, 8, 6], [6, 9, 5]],disappear = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55]) == [0, 5, 3, 7, 12, 4, 11, 15, 10, 16]\n assert candidate(n = 12,edges = [[0, 1, 1], [0, 2, 2], [0, 3, 3], [1, 4, 4], [1, 5, 5], [2, 6, 6], [2, 7, 7], [3, 8, 8], [3, 9, 9], [4, 10, 10], [5, 11, 11], [6, 11, 12], [7, 10, 13], [8, 11, 14], [9, 10, 15]],disappear = [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]) == [0, 1, 2, 3, 5, 6, 8, 9, 11, 12, 15, 17]\n assert candidate(n = 10,edges = [[0, 1, 5], [1, 2, 10], [2, 3, 15], [3, 4, 20], [4, 5, 25], [5, 6, 30], [6, 7, 35], [7, 8, 40], [8, 9, 45]],disappear = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == [0, 5, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(n = 6,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 0, 1]],disappear = [10, 20, 30, 40, 50, 60]) == [0, 1, 2, 3, 2, 1]\n assert candidate(n = 12,edges = [[0, 1, 10], [0, 5, 50], [1, 2, 20], [1, 3, 30], [2, 4, 40], [3, 7, 50], [4, 6, 60], [5, 6, 10], [5, 8, 20], [6, 9, 30], [7, 10, 40], [8, 10, 50], [9, 11, 60]],disappear = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200]) == [0, 10, 30, 40, 70, 50, 60, 90, 70, 90, 120, 150]\n assert candidate(n = 6,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [0, 2, 4], [1, 3, 5], [2, 4, 6], [3, 5, 7]],disappear = [6, 7, 8, 9, 10, 11]) == [0, 1, 3, 6, 9, -1]\n assert candidate(n = 7,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [2, 4, 4], [3, 4, 1], [4, 5, 2], [5, 6, 3]],disappear = [5, 6, 7, 8, 9, 10, 11]) == [0, 1, 2, 4, 5, 7, 10]\n assert candidate(n = 10,edges = [[0, 1, 5], [0, 2, 10], [1, 3, 3], [2, 4, 7], [3, 4, 2], [3, 5, 6], [4, 6, 8], [5, 7, 1], [6, 8, 4], [7, 9, 9]],disappear = [20, 25, 30, 35, 40, 45, 50, 55, 60, 65]) == [0, 5, 10, 8, 10, 14, 18, 15, 22, 24]\n assert candidate(n = 8,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [2, 4, 4], [3, 5, 5], [4, 6, 6], [5, 7, 7]],disappear = [1, 1, 1, 1, 1, 1, 1, 1]) == [0, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(n = 20,edges = [[0, 1, 2], [0, 2, 3], [0, 3, 4], [0, 4, 5], [0, 5, 6], [0, 6, 7], [0, 7, 8], [0, 8, 9], [0, 9, 10], [0, 10, 11], [0, 11, 12], [0, 12, 13], [0, 13, 14], [0, 14, 15], [0, 15, 16], [0, 16, 17], [0, 17, 18], [0, 18, 19], [0, 19, 20]],disappear = [30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]) == [0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(n = 10,edges = [[0, 1, 1], [0, 2, 2], [0, 3, 3], [0, 4, 4], [0, 5, 5], [0, 6, 6], [0, 7, 7], [0, 8, 8], [0, 9, 9]],disappear = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(n = 15,edges = [[0, 1, 10], [0, 2, 10], [1, 3, 5], [1, 4, 5], [2, 5, 5], [2, 6, 5], [3, 7, 2], [3, 8, 2], [4, 9, 2], [4, 10, 2], [5, 11, 2], [5, 12, 2], [6, 13, 2], [6, 14, 2], [7, 8, 1], [9, 10, 1], [11, 12, 1], [13, 14, 1]],disappear = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 5, 4, 3, 2, 1]) == [0, 10, 10, 15, 15, 15, 15, 17, 17, -1, -1, -1, -1, -1, -1]\n assert candidate(n = 7,edges = [[0, 1, 5], [0, 2, 10], [1, 3, 15], [1, 4, 20], [2, 5, 25], [2, 6, 30], [3, 4, 5], [4, 5, 10], [5, 6, 15], [6, 3, 20], [0, 3, 35]],disappear = [20, 30, 40, 50, 60, 70, 80]) == [0, 5, 10, 20, 25, 35, 40]\n assert candidate(n = 5,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [2, 4, 4]],disappear = [5, 6, 7, 8, 9]) == [0, 1, 2, 4, 6]\n assert candidate(n = 7,edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [1, 4, 10], [2, 5, 10], [2, 6, 10], [3, 4, 10], [5, 6, 10]],disappear = [50, 50, 50, 50, 50, 50, 50]) == [0, 10, 10, 20, 20, 20, 20]\n assert candidate(n = 7,edges = [[0, 1, 2], [0, 2, 2], [1, 3, 3], [1, 4, 3], [2, 5, 3], [2, 6, 3], [3, 4, 2], [5, 6, 2], [0, 3, 5], [0, 5, 5]],disappear = [10, 15, 20, 25, 30, 35, 40]) == [0, 2, 2, 5, 5, 5, 5]\n assert candidate(n = 20,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [1, 4, 4], [2, 5, 5], [2, 6, 6], [3, 7, 7], [3, 8, 8], [4, 9, 9], [4, 10, 10], [5, 11, 11], [5, 12, 12], [6, 13, 13], [6, 14, 14], [7, 15, 15], [7, 16, 16], [8, 17, 17], [8, 18, 18], [9, 19, 19], [10, 19, 20]],disappear = [30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]) == [0, 1, 2, 4, 5, 7, 8, 11, 12, 14, 15, 18, 19, 21, 22, 26, 27, 29, -1, -1]\n assert candidate(n = 8,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [0, 7, 1]],disappear = [2, 3, 4, 5, 6, 7, 8, 9]) == [0, 1, 2, 3, 4, 3, 2, 1]\n assert candidate(n = 10,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1]],disappear = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(n = 8,edges = [[0, 1, 2], [0, 2, 3], [1, 3, 1], [2, 3, 2], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1]],disappear = [10, 12, 13, 14, 15, 16, 17, 18]) == [0, 2, 3, 3, 4, 5, 6, 7]\n assert candidate(n = 25,edges = [[0, 1, 2], [0, 2, 3], [1, 3, 4], [1, 4, 5], [2, 5, 6], [2, 6, 7], [3, 7, 8], [3, 8, 9], [4, 8, 10], [4, 9, 11], [5, 9, 12], [5, 10, 13], [6, 10, 14], [6, 11, 15], [7, 11, 16], [7, 12, 17], [8, 12, 18], [8, 13, 19], [9, 13, 20], [9, 14, 21], [10, 14, 22], [10, 15, 23], [11, 15, 24], [11, 16, 25], [12, 16, 26], [12, 17, 27], [13, 17, 28], [13, 18, 29], [14, 18, 30], [14, 19, 31], [15, 19, 32], [15, 20, 33], [16, 20, 34], [16, 21, 35], [17, 21, 36], [17, 22, 37], [18, 22, 38], [18, 23, 39], [19, 23, 40], [19, 24, 41]],disappear = [45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21]) == [0, 2, 3, 6, 7, 9, 10, 14, 15, 18, 22, 25, 31, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n"}, "metadata": {"canonical_parameter_names": ["n", "edges", "disappear"], "leetcode_dataset_entry_point": "Solution().minimumTime", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector minimumTime(int n, vector>& edges, vector& disappear) {", "container": "Solution", "callable": "minimumTime", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "vector>&"}, {"name": "disappear", "type": "vector&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3113, "task_id": "find-the-number-of-subarrays-where-boundary-elements-are-maximum", "difficulty": "Hard", "problem_description": "You are given an array of positive integers nums.\nReturn the number of subarrays of nums, where the first and the last elements of the subarray are equal to the largest element in the subarray.\n \nExample 1:\n\nInput: nums = [1,4,3,3,2]\nOutput: 6\nExplanation:\nThere are 6 subarrays which have the first and the last elements equal to the largest element of the subarray:\n\nsubarray [1,4,3,3,2], with its largest element 1. The first element is 1 and the last element is also 1.\nsubarray [1,4,3,3,2], with its largest element 4. The first element is 4 and the last element is also 4.\nsubarray [1,4,3,3,2], with its largest element 3. The first element is 3 and the last element is also 3.\nsubarray [1,4,3,3,2], with its largest element 3. The first element is 3 and the last element is also 3.\nsubarray [1,4,3,3,2], with its largest element 2. The first element is 2 and the last element is also 2.\nsubarray [1,4,3,3,2], with its largest element 3. The first element is 3 and the last element is also 3.\n\nHence, we return 6.\n\nExample 2:\n\nInput: nums = [3,3,3]\nOutput: 6\nExplanation:\nThere are 6 subarrays which have the first and the last elements equal to the largest element of the subarray:\n\nsubarray [3,3,3], with its largest element 3. The first element is 3 and the last element is also 3.\nsubarray [3,3,3], with its largest element 3. The first element is 3 and the last element is also 3.\nsubarray [3,3,3], with its largest element 3. The first element is 3 and the last element is also 3.\nsubarray [3,3,3], with its largest element 3. The first element is 3 and the last element is also 3.\nsubarray [3,3,3], with its largest element 3. The first element is 3 and the last element is also 3.\nsubarray [3,3,3], with its largest element 3. The first element is 3 and the last element is also 3.\n\nHence, we return 6.\n\nExample 3:\n\nInput: nums = [1]\nOutput: 1\nExplanation:\nThere is a single subarray of nums which is [1], with its largest element 1. The first element is 1 and the last element is also 1.\nHence, we return 1.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 4, 5, 4, 5]) == 8\n assert candidate(nums = [2, 1, 2, 1, 2]) == 8\n assert candidate(nums = [1, 3, 2, 3, 1, 3]) == 9\n assert candidate(nums = [1, 2, 2, 1]) == 5\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 55\n assert candidate(nums = [5, 1, 5, 2, 5, 5]) == 12\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [2, 1, 2]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [10, 20, 10, 30, 20, 10]) == 6\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 55\n assert candidate(nums = [1, 2, 2, 2, 1]) == 8\n assert candidate(nums = [2, 1, 2, 3, 2, 1, 2]) == 9\n assert candidate(nums = [1, 4, 3, 3, 2]) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1]) == 9\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 9, 7, 5, 3, 1]) == 11\n assert candidate(nums = [3, 3, 3]) == 6\n assert candidate(nums = [5, 4, 3, 2, 1]) == 5\n assert candidate(nums = [2, 2, 1, 2, 2]) == 11\n assert candidate(nums = [2, 2, 1, 1, 2, 2, 1, 1, 2, 2]) == 27\n assert candidate(nums = [1, 3, 2, 3, 1, 3, 1]) == 10\n assert candidate(nums = [1, 2, 3, 2, 1]) == 5\n assert candidate(nums = [7, 1, 5, 3, 6, 4, 7]) == 8\n assert candidate(nums = [10, 10, 10, 10, 10]) == 15\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 496\n assert candidate(nums = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5]) == 84\n assert candidate(nums = [15, 10, 15, 5, 15, 20, 15, 5, 15, 10, 15, 25, 15, 5, 15, 10, 15]) == 26\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 37\n assert candidate(nums = [8, 5, 8, 9, 8, 5, 8, 9, 8]) == 12\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1]) == 21\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 27\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 100\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 2, 1]) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 19\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 21\n assert candidate(nums = [2, 4, 6, 8, 10, 8, 6, 4, 2]) == 9\n assert candidate(nums = [1, 1, 1, 1, 2, 1, 1, 1, 1, 3, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1]) == 48\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 135\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 210\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 30\n assert candidate(nums = [7, 8, 9, 9, 8, 7, 9, 8, 7]) == 12\n assert candidate(nums = [1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1]) == 40\n assert candidate(nums = [3, 5, 2, 5, 3, 3, 5, 2, 3, 5, 5, 5, 5, 5, 3, 2, 5, 3, 5, 5, 3, 2, 3, 5, 3, 5, 5, 3, 2, 3]) == 124\n assert candidate(nums = [2, 2, 3, 3, 3, 3, 3, 2, 2, 2]) == 24\n assert candidate(nums = [1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == 20\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80]) == 21\n assert candidate(nums = [2, 1, 4, 4, 4, 1, 4, 2, 4, 1]) == 20\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 1, 1, 1]) == 60\n assert candidate(nums = [9, 10, 11, 10, 10, 9, 11, 10, 9]) == 11\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 26\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 30\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 39\n assert candidate(nums = [1, 2, 1, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1]) == 21\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2]) == 13\n assert candidate(nums = [5, 6, 5, 7, 5, 6, 5, 8, 5, 9, 5, 10, 5, 11, 5, 12, 5, 13, 5, 14, 5]) == 21\n assert candidate(nums = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5]) == 97\n assert candidate(nums = [7, 2, 7, 3, 7, 7, 7, 3, 7, 2, 7]) == 32\n assert candidate(nums = [100, 90, 80, 70, 60, 70, 80, 90, 100]) == 13\n assert candidate(nums = [5, 5, 1, 5, 5, 2, 5, 5, 3, 5, 5, 4, 5, 5, 5]) == 70\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 55\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 27\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 57\n assert candidate(nums = [100, 200, 100, 300, 200, 100, 400, 300, 200, 100, 500, 400, 300, 200, 100]) == 15\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 136\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 30\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 33\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1]) == 18\n assert candidate(nums = [7, 5, 7, 8, 7, 5, 7, 8, 7]) == 12\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 210\n assert candidate(nums = [5, 5, 5, 5, 5, 6, 5, 5, 5, 5, 5, 7, 5, 5, 5, 5, 5, 8, 5, 5, 5, 5, 5]) == 63\n assert candidate(nums = [2, 4, 6, 8, 10, 8, 6, 4, 2, 12, 2, 4, 6, 8, 10, 8, 6, 4, 2, 12]) == 21\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1]) == 11\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 58\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 33\n assert candidate(nums = [8, 1, 8, 9, 8, 9, 8, 10, 8, 9, 8, 1]) == 14\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 47\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 77\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 28\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 58\n assert candidate(nums = [1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == 27\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 33\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 3, 3, 3, 2, 2, 1]) == 30\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 21\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 43\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 42\n assert candidate(nums = [6, 1, 6, 6, 6, 1, 6, 1, 6]) == 24\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 39\n assert candidate(nums = [2, 3, 2, 2, 3, 2, 3, 2, 2, 3, 2, 3, 2, 2, 3, 2, 3, 2, 2, 3, 2, 3, 2, 2, 3, 2, 3, 2, 2, 3, 2]) == 103\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 21\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 27\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 30\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 210\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 528\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 33\n assert candidate(nums = [1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1]) == 15\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7]) == 36\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9]) == 44\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 25\n assert candidate(nums = [1, 2, 1, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1]) == 36\n assert candidate(nums = [7, 8, 8, 7, 9, 8, 7, 8, 7]) == 11\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 30\n assert candidate(nums = [2, 1, 4, 4, 4, 1, 2]) == 10\n assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 465\n assert candidate(nums = [1, 2, 2, 1, 2, 1, 1, 1, 2, 2, 2, 1, 2, 1, 2, 2, 2, 2, 2, 1]) == 89\n assert candidate(nums = [100, 200, 300, 400, 500, 400, 300, 200, 100, 200, 300, 400, 500, 400, 300, 200, 100]) == 21\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 120\n assert candidate(nums = [1, 9, 2, 8, 3, 7, 4, 6, 5, 5, 6, 4, 7, 3, 8, 2, 9, 1]) == 23\n assert candidate(nums = [3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 50\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().numberOfSubarrays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "long long numberOfSubarrays(vector& nums) {", "container": "Solution", "callable": "numberOfSubarrays", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "long long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3114, "task_id": "latest-time-you-can-obtain-after-replacing-characters", "difficulty": "Easy", "problem_description": "You are given a string s representing a 12-hour format time where some of the digits (possibly none) are replaced with a \"?\".\n12-hour times are formatted as \"HH:MM\", where HH is between 00 and 11, and MM is between 00 and 59. The earliest 12-hour time is 00:00, and the latest is 11:59.\nYou have to replace all the \"?\" characters in s with digits such that the time we obtain by the resulting string is a valid 12-hour format time and is the latest possible.\nReturn the resulting string.\n \nExample 1:\n\nInput: s = \"1?:?4\"\nOutput: \"11:54\"\nExplanation: The latest 12-hour format time we can achieve by replacing \"?\" characters is \"11:54\".\n\nExample 2:\n\nInput: s = \"0?:5?\"\nOutput: \"09:59\"\nExplanation: The latest 12-hour format time we can achieve by replacing \"?\" characters is \"09:59\".\n\n \nConstraints:\n\ns.length == 5\ns[2] is equal to the character \":\".\nAll characters except s[2] are digits or \"?\" characters.\nThe input is generated such that there is at least one time between \"00:00\" and \"11:59\" that you can obtain after replacing the \"?\" characters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"10:?5\") == \"10:55\"\n assert candidate(s = \"??:??:\") == \"11:59\"\n assert candidate(s = \"??:5?\") == \"11:59\"\n assert candidate(s = \"1?:4?\") == \"11:49\"\n assert candidate(s = \"1?:?4\") == \"11:54\"\n assert candidate(s = \"11:?9\") == \"11:59\"\n assert candidate(s = \"?1:59\") == \"11:59\"\n assert candidate(s = \"1?:30\") == \"11:30\"\n assert candidate(s = \"0?:5?\") == \"09:59\"\n assert candidate(s = \"0?:??\") == \"09:59\"\n assert candidate(s = \"?9:5?\") == \"09:59\"\n assert candidate(s = \"1??:4?\") == None\n assert candidate(s = \"1??:59\") == None\n assert candidate(s = \"??:?0\") == \"11:50\"\n assert candidate(s = \"0??:59\") == None\n assert candidate(s = \"00:?1\") == \"00:51\"\n assert candidate(s = \"1?:3?\") == \"11:39\"\n assert candidate(s = \"1?:??\") == \"11:59\"\n assert candidate(s = \"???:59\") == None\n assert candidate(s = \"11:5?\") == \"11:59\"\n assert candidate(s = \"09:5?\") == \"09:59\"\n assert candidate(s = \"0??:?0\") == None\n assert candidate(s = \"00:??\") == \"00:59\"\n assert candidate(s = \"1?:?0\") == \"11:50\"\n assert candidate(s = \"?1:?2\") == \"11:52\"\n assert candidate(s = \"0?:0?\") == \"09:09\"\n assert candidate(s = \"??:59\") == \"11:59\"\n assert candidate(s = \"11:??\") == \"11:59\"\n assert candidate(s = \"09:?1\") == \"09:51\"\n assert candidate(s = \"???:??\") == None\n assert candidate(s = \"01:?7\") == \"01:57\"\n assert candidate(s = \"?0:??\") == \"10:59\"\n assert candidate(s = \"?:?0\") == None\n assert candidate(s = \"10:?0\") == \"10:50\"\n assert candidate(s = \"1??:5?\") == None\n assert candidate(s = \"12:?9\") == None\n assert candidate(s = \"???:5?\") == None\n assert candidate(s = \"??:??\") == \"11:59\"\n assert candidate(s = \"0?:?0\") == \"09:50\"\n assert candidate(s = \"1??:??\") == None\n assert candidate(s = \"08:?5\") == \"08:55\"\n assert candidate(s = \"0?:?1\") == \"09:51\"\n assert candidate(s = \"09:?8\") == \"09:58\"\n assert candidate(s = \"???:45\") == None\n assert candidate(s = \"1??:10\") == None\n assert candidate(s = \"1?:??:??:?9\") == \"11:59\"\n assert candidate(s = \"0??:3?\") == None\n assert candidate(s = \"??:?9\") == \"11:59\"\n assert candidate(s = \"1?:?1\") == \"11:51\"\n assert candidate(s = \"1?:??:5?\") == \"11:59\"\n assert candidate(s = \"0??:5?\") == None\n assert candidate(s = \"1?:50\") == \"11:50\"\n assert candidate(s = \"0??:10\") == None\n assert candidate(s = \"11:?\") == \"11:59\"\n assert candidate(s = \"???:00\") == None\n assert candidate(s = \"10:?8\") == \"10:58\"\n assert candidate(s = \"11:?5\") == \"11:55\"\n assert candidate(s = \"1?:??:45\") == \"11:59\"\n assert candidate(s = \"0?:59\") == \"09:59\"\n assert candidate(s = \"0?:50\") == \"09:50\"\n assert candidate(s = \"09:??\") == \"09:59\"\n assert candidate(s = \"?:45\") == None\n assert candidate(s = \"?1:??\") == \"11:59\"\n assert candidate(s = \"0?:5?:?4\") == \"09:59\"\n assert candidate(s = \"???:30\") == None\n assert candidate(s = \"1?:?3\") == \"11:53\"\n assert candidate(s = \"0?:2?\") == \"09:29\"\n assert candidate(s = \"??:0?\") == \"11:09\"\n assert candidate(s = \"?0:?8\") == \"10:58\"\n assert candidate(s = \"09:?9\") == \"09:59\"\n assert candidate(s = \"1??:?4\") == None\n assert candidate(s = \"10:?9\") == \"10:59\"\n assert candidate(s = \"??:45\") == \"11:45\"\n assert candidate(s = \"1??:3?\") == None\n assert candidate(s = \"???:25\") == None\n assert candidate(s = \"0?:00\") == \"09:00\"\n assert candidate(s = \"11:?1\") == \"11:51\"\n assert candidate(s = \"??:4?\") == \"11:49\"\n assert candidate(s = \"1?:?5\") == \"11:55\"\n assert candidate(s = \"?:5?:3?\") == None\n assert candidate(s = \"01:?9\") == \"01:59\"\n assert candidate(s = \"0?:?5\") == \"09:55\"\n assert candidate(s = \"1?:00\") == \"11:00\"\n assert candidate(s = \"?:00\") == None\n assert candidate(s = \"1?:0?\") == \"11:09\"\n assert candidate(s = \"?:?8\") == None\n assert candidate(s = \"0?:??:00\") == \"09:59\"\n assert candidate(s = \"1?:1?\") == \"11:19\"\n assert candidate(s = \"1?:?8\") == \"11:58\"\n assert candidate(s = \"??:??:59\") == \"11:59\"\n assert candidate(s = \"1?:59\") == \"11:59\"\n assert candidate(s = \"0?:??:5?\") == \"09:59\"\n assert candidate(s = \"??:00\") == \"11:00\"\n assert candidate(s = \"0?:3?\") == \"09:39\"\n assert candidate(s = \"10:5?\") == \"10:59\"\n assert candidate(s = \"11:?0\") == \"11:50\"\n assert candidate(s = \"1?:4?:?5\") == \"11:49\"\n assert candidate(s = \"0?:??:1?\") == \"09:59\"\n assert candidate(s = \"1??:0?\") == None\n assert candidate(s = \"0??:0?\") == None\n assert candidate(s = \"09:??:?0\") == \"09:59\"\n assert candidate(s = \"?:09\") == None\n assert candidate(s = \"0?:?:5?\") == None\n assert candidate(s = \"1?:55\") == \"11:55\"\n assert candidate(s = \"0?:??:?9\") == \"09:59\"\n assert candidate(s = \"?9:?9\") == \"09:59\"\n assert candidate(s = \"11:??:5?\") == \"11:59\"\n assert candidate(s = \"?8:?8\") == \"08:58\"\n assert candidate(s = \"0?:?:??\") == None\n assert candidate(s = \"1??:?0\") == None\n assert candidate(s = \"09:?0\") == \"09:50\"\n assert candidate(s = \"0?:58\") == \"09:58\"\n assert candidate(s = \"1?:5?\") == \"11:59\"\n assert candidate(s = \"?:??\") == None\n assert candidate(s = \"?:59\") == None\n assert candidate(s = \"0?:1?\") == \"09:19\"\n assert candidate(s = \"0??:?9\") == None\n assert candidate(s = \"1?:??:0?\") == \"11:59\"\n assert candidate(s = \"0?:4?\") == \"09:49\"\n assert candidate(s = \"09:?5\") == \"09:55\"\n assert candidate(s = \"1?:?9\") == \"11:59\"\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().findLatestTime", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string findLatestTime(string s) {", "container": "Solution", "callable": "findLatestTime", "parameters": [{"name": "s", "type": "string"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3115, "task_id": "maximum-prime-difference", "difficulty": "Medium", "problem_description": "You are given an integer array nums.\nReturn an integer that is the maximum distance between the indices of two (not necessarily different) prime numbers in nums.\n \nExample 1:\n\nInput: nums = [4,2,9,5,3]\nOutput: 3\nExplanation: nums[1], nums[3], and nums[4] are prime. So the answer is |4 - 1| = 3.\n\nExample 2:\n\nInput: nums = [4,8,2,8]\nOutput: 0\nExplanation: nums[2] is prime. Because there is just one prime number, the answer is |2 - 2| = 0.\n\n \nConstraints:\n\n1 <= nums.length <= 3 * 105\n1 <= nums[i] <= 100\nThe input is generated such that the number of prime numbers in the nums is at least one.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [97, 1, 97, 1, 97]) == 4\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 9\n assert candidate(nums = [100, 97, 94, 91, 88, 85, 82, 79, 76, 73, 70, 67, 64, 61, 58, 55, 52, 49, 46, 43, 40, 37, 34, 31, 28, 25, 22, 19, 16, 13, 10, 7, 4, 1]) == 30\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 9\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94]) == 0\n assert candidate(nums = [3, 3, 3, 3]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 5\n assert candidate(nums = [30, 31, 32, 33, 34, 35, 36, 37, 38, 39]) == 6\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 0\n assert candidate(nums = [71, 71, 71, 71, 71, 71, 71]) == 6\n assert candidate(nums = [4, 2, 9, 5, 3]) == 3\n assert candidate(nums = [2]) == 0\n assert candidate(nums = [2, 100, 50, 25, 75]) == 0\n assert candidate(nums = [11, 13, 17, 19, 23, 29, 31]) == 6\n assert candidate(nums = [79, 15, 29, 53, 79, 79, 79]) == 6\n assert candidate(nums = [11, 13, 17, 19, 23, 29]) == 5\n assert candidate(nums = [29, 23, 19, 17, 13, 11, 7, 5, 3, 2]) == 9\n assert candidate(nums = [83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199]) == 23\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 0\n assert candidate(nums = [71, 73, 79, 71, 73, 79, 71, 73, 79, 71]) == 9\n assert candidate(nums = [30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 6\n assert candidate(nums = [83, 67, 89, 53, 61]) == 4\n assert candidate(nums = [29, 29, 29, 29, 29, 29, 29, 29, 29, 29]) == 9\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 9\n assert candidate(nums = [11, 11, 11, 11, 11, 11, 11, 11, 11, 11]) == 9\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 0\n assert candidate(nums = [4, 8, 2, 8]) == 0\n assert candidate(nums = [3, 3, 3, 3, 3]) == 4\n assert candidate(nums = [3, 5, 7, 11, 13, 17, 19]) == 6\n assert candidate(nums = [1, 4, 6, 8, 10]) == None\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 17\n assert candidate(nums = [10, 15, 20, 25, 30]) == None\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 45\n assert candidate(nums = [53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331]) == 51\n assert candidate(nums = [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199]) == 45\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499]) == 94\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 95\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 45\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199]) == 45\n assert candidate(nums = [89, 97, 83, 79, 73, 71, 67, 61, 59, 53, 47, 43, 41, 37, 31, 29, 23, 19, 17, 13, 11, 7, 5, 3, 2, 89, 97, 83, 79, 73, 71, 67, 61, 59, 53, 47, 43, 41, 37, 31, 29, 23, 19, 17, 13, 11, 7, 5, 3, 2]) == 49\n assert candidate(nums = [84, 71, 83, 35, 29, 68, 51, 47, 92, 79, 60, 59, 46, 53, 61, 15, 73, 74, 87, 45, 40, 73, 84, 70, 83, 32, 57, 94, 48, 43, 30, 47, 76, 90, 51, 39, 28, 88, 22, 53, 59, 46, 53, 61, 15, 73, 74, 87, 45, 40, 73, 84, 70, 83, 32, 57, 94, 48, 43, 30, 47, 76, 90, 51, 39, 28, 88, 22, 53, 59, 46, 53, 61, 15, 73, 74, 87, 45, 40, 73, 84, 70, 83, 32, 57, 94, 48, 43, 30, 47, 76, 90, 51, 39, 28, 88, 22, 53, 59, 46, 53, 61, 15, 73, 74, 87, 45, 40, 73, 84, 70, 83, 32, 57, 94, 48, 43, 30, 47, 76, 90, 51, 39, 28, 88, 22, 53, 59, 46, 53, 61]) == 129\n assert candidate(nums = [151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997]) == 132\n assert candidate(nums = [5, 11, 17, 23, 29, 35, 41, 47, 53, 59, 65, 71, 77, 83, 89, 95, 101, 107, 113, 119, 125, 131, 137, 143, 149, 155, 161, 167, 173, 179, 185, 191, 197, 203, 209, 211, 217, 223, 229, 235, 239, 245, 251, 257, 263, 269, 275, 281, 287, 293, 299, 305, 311, 317, 323, 329, 331, 337, 343, 349, 353, 359, 365, 371, 373, 379, 383, 389, 395, 397]) == 69\n assert candidate(nums = [46, 67, 41, 89, 29, 97, 73, 31, 61, 37, 79, 83, 7, 53, 59, 8, 5, 3, 2, 97, 43, 47, 11, 19, 60, 88, 23, 71, 13, 5, 17, 19, 67, 73, 11, 89, 59, 71, 79, 31, 7, 37, 97, 2, 29, 19, 61, 13, 19, 67, 73, 11, 89, 59, 71, 79, 31, 7, 37, 97, 2, 29, 19, 61, 13, 19, 67, 73, 11, 89, 59, 71, 79, 31, 7, 37, 97, 2, 29, 19, 61, 13, 19, 67, 73, 11, 89, 59, 71, 79, 31, 7, 37]) == 91\n assert candidate(nums = [101, 97, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499]) == 70\n assert candidate(nums = [29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397]) == 68\n assert candidate(nums = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150]) == 96\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499]) == 94\n assert candidate(nums = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199]) == 92\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1024, 1089, 1156, 1225, 1296, 1369, 1444, 1521, 1600, 1681, 1764, 1849, 1936, 2025]) == None\n assert candidate(nums = [71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199]) == 26\n assert candidate(nums = [97, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == 97\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maximumPrimeDifference", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maximumPrimeDifference(vector& nums) {", "container": "Solution", "callable": "maximumPrimeDifference", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3116, "task_id": "kth-smallest-amount-with-single-denomination-combination", "difficulty": "Hard", "problem_description": "You are given an integer array coins representing coins of different denominations and an integer k.\nYou have an infinite number of coins of each denomination. However, you are not allowed to combine coins of different denominations.\nReturn the kth smallest amount that can be made using these coins.\n \nExample 1:\n\nInput: coins = [3,6,9], k = 3\nOutput: 9\nExplanation: The given coins can make the following amounts:\nCoin 3 produces multiples of 3: 3, 6, 9, 12, 15, etc.\nCoin 6 produces multiples of 6: 6, 12, 18, 24, etc.\nCoin 9 produces multiples of 9: 9, 18, 27, 36, etc.\nAll of the coins combined produce: 3, 6, 9, 12, 15, etc.\n\nExample 2:\n\nInput: coins = [5,2], k = 7\nOutput: 12 \nExplanation: The given coins can make the following amounts:\nCoin 5 produces multiples of 5: 5, 10, 15, 20, etc.\nCoin 2 produces multiples of 2: 2, 4, 6, 8, 10, 12, etc.\nAll of the coins combined produce: 2, 4, 5, 6, 8, 10, 12, 14, 15, etc.\n\n \nConstraints:\n\n1 <= coins.length <= 15\n1 <= coins[i] <= 25\n1 <= k <= 2 * 109\ncoins contains pairwise distinct integers.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(coins = [10, 20, 30],k = 5) == 50\n assert candidate(coins = [15, 20, 25],k = 15) == 125\n assert candidate(coins = [15, 25, 35],k = 8) == 70\n assert candidate(coins = [25, 50, 75],k = 20) == 500\n assert candidate(coins = [1, 10, 100],k = 100) == 100\n assert candidate(coins = [4, 8, 12],k = 10) == 40\n assert candidate(coins = [7, 14, 28],k = 5) == 35\n assert candidate(coins = [2, 3, 5, 7],k = 12) == 15\n assert candidate(coins = [10, 20, 30],k = 20) == 200\n assert candidate(coins = [7, 11, 13],k = 15) == 52\n assert candidate(coins = [3, 6, 9],k = 3) == 9\n assert candidate(coins = [7, 11, 13],k = 10) == 35\n assert candidate(coins = [9, 18, 27, 36],k = 15) == 135\n assert candidate(coins = [15, 20, 25],k = 8) == 60\n assert candidate(coins = [2, 3, 5],k = 30) == 40\n assert candidate(coins = [1, 2, 3],k = 10) == 10\n assert candidate(coins = [5, 2],k = 7) == 12\n assert candidate(coins = [1, 2, 3],k = 5) == 5\n assert candidate(coins = [8, 16, 24],k = 12) == 96\n assert candidate(coins = [17, 19, 23],k = 8) == 57\n assert candidate(coins = [3, 5, 7],k = 20) == 36\n assert candidate(coins = [17, 23, 29],k = 20) == 153\n assert candidate(coins = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 75) == 150\n assert candidate(coins = [2, 5, 7, 10],k = 30) == 46\n assert candidate(coins = [1, 3, 6, 9, 12, 15],k = 100) == 100\n assert candidate(coins = [2, 5, 10, 20],k = 25) == 42\n assert candidate(coins = [2, 4, 8, 16, 32, 64],k = 200) == 400\n assert candidate(coins = [1, 3, 5, 7, 9],k = 100) == 100\n assert candidate(coins = [3, 5, 7, 9, 11, 13],k = 100) == 165\n assert candidate(coins = [2, 5, 10, 20],k = 30) == 50\n assert candidate(coins = [3, 5, 7, 9],k = 20) == 36\n assert candidate(coins = [2, 3, 5, 7, 11, 13, 17, 19],k = 150) == 185\n assert candidate(coins = [6, 12, 18, 24, 30],k = 25) == 150\n assert candidate(coins = [2, 5, 10, 20, 25],k = 200) == 334\n assert candidate(coins = [1, 3, 5, 7, 9, 11],k = 100) == 100\n assert candidate(coins = [2, 4, 8, 16, 32, 64],k = 150) == 300\n assert candidate(coins = [4, 6, 8, 10, 12, 14],k = 60) == 156\n assert candidate(coins = [7, 14, 21, 28, 35],k = 75) == 525\n assert candidate(coins = [15, 25, 35, 45, 55, 65, 75],k = 300) == 2430\n assert candidate(coins = [13, 26, 39, 52, 65, 78, 91],k = 100) == 1300\n assert candidate(coins = [1, 4, 9, 16, 25],k = 100) == 100\n assert candidate(coins = [2, 3, 5, 7],k = 50) == 65\n assert candidate(coins = [13, 17, 19],k = 30) == 169\n assert candidate(coins = [7, 14, 21, 28],k = 25) == 175\n assert candidate(coins = [8, 16, 24, 32, 40, 48],k = 100) == 800\n assert candidate(coins = [3, 5, 7],k = 15) == 27\n assert candidate(coins = [11, 22, 33, 44, 55],k = 50) == 550\n assert candidate(coins = [11, 13, 17, 19],k = 50) == 190\n assert candidate(coins = [1, 3, 7, 9, 11, 13],k = 40) == 40\n assert candidate(coins = [11, 13, 17],k = 15) == 68\n assert candidate(coins = [1, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42],k = 700) == 700\n assert candidate(coins = [7, 14, 21, 28],k = 25) == 175\n assert candidate(coins = [4, 7, 10, 13, 16],k = 75) == 169\n assert candidate(coins = [5, 10, 15, 20, 25, 30, 35],k = 100) == 500\n assert candidate(coins = [15, 21, 27, 33, 39],k = 40) == 234\n assert candidate(coins = [2, 5, 10, 20, 25, 50],k = 1000) == 1666\n assert candidate(coins = [11, 13, 17],k = 20) == 91\n assert candidate(coins = [6, 12, 18, 24, 30],k = 50) == 300\n assert candidate(coins = [1, 2, 4, 8, 16, 32],k = 1000) == 1000\n assert candidate(coins = [17, 19, 23, 29, 31, 37, 41, 43, 47],k = 400) == 1410\n assert candidate(coins = [5, 10, 15, 20, 25, 30],k = 150) == 750\n assert candidate(coins = [2, 3, 5, 7, 11],k = 100) == 126\n assert candidate(coins = [1, 3, 5, 7, 9, 11, 13],k = 50) == 50\n assert candidate(coins = [2, 3, 5, 7, 11],k = 50) == 64\n assert candidate(coins = [21, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79],k = 1000) == 3161\n assert candidate(coins = [11, 22, 33, 44],k = 100) == 1100\n assert candidate(coins = [18, 24, 30, 36, 42],k = 70) == 648\n assert candidate(coins = [17, 23, 29],k = 12) == 92\n assert candidate(coins = [10, 15, 20, 25, 30],k = 300) == 2050\n assert candidate(coins = [25, 50, 75, 100, 125],k = 35) == 875\n assert candidate(coins = [6, 9, 12, 18],k = 50) == 225\n assert candidate(coins = [3, 5, 7, 9, 11],k = 30) == 50\n assert candidate(coins = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],k = 600) == 3000\n assert candidate(coins = [18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102],k = 1500) == 12312\n assert candidate(coins = [3, 5, 15],k = 25) == 54\n assert candidate(coins = [11, 22, 33, 44, 55],k = 100) == 1100\n assert candidate(coins = [15, 25, 35, 45],k = 60) == 555\n assert candidate(coins = [6, 12, 18, 24],k = 100) == 600\n assert candidate(coins = [5, 10, 15, 20, 25, 30, 35],k = 200) == 1000\n assert candidate(coins = [11, 22, 33],k = 25) == 275\n assert candidate(coins = [5, 10, 15, 20, 25],k = 250) == 1250\n assert candidate(coins = [19, 21, 23, 25],k = 40) == 228\n assert candidate(coins = [15, 25, 35, 45, 55, 65, 75],k = 200) == 1635\n assert candidate(coins = [2, 3, 5, 7, 11, 13, 17, 19],k = 300) == 365\n assert candidate(coins = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768],k = 1000) == 2000\n assert candidate(coins = [2, 4, 8, 16, 32, 64, 128],k = 200) == 400\n assert candidate(coins = [7, 11, 13],k = 15) == 52\n assert candidate(coins = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 500) == 5000\n assert candidate(coins = [7, 11, 13, 17, 19],k = 35) == 91\n assert candidate(coins = [15, 25, 35, 45],k = 200) == 1845\n assert candidate(coins = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120],k = 800) == 6400\n assert candidate(coins = [3, 6, 9, 12, 15],k = 50) == 150\n assert candidate(coins = [1, 4, 9, 16, 25],k = 150) == 150\n assert candidate(coins = [3, 6, 12, 18, 24, 30],k = 150) == 450\n assert candidate(coins = [3, 5, 7, 9],k = 20) == 36\n assert candidate(coins = [17, 19, 23],k = 20) == 136\n assert candidate(coins = [11, 22, 33, 44, 55],k = 45) == 495\n assert candidate(coins = [13, 26, 39, 52, 65],k = 50) == 650\n assert candidate(coins = [19, 31, 37, 41],k = 25) == 190\n assert candidate(coins = [7, 14, 21],k = 15) == 105\n assert candidate(coins = [3, 6, 9, 12, 15],k = 30) == 90\n assert candidate(coins = [6, 10, 14],k = 30) == 110\n assert candidate(coins = [2, 4, 6, 8, 10],k = 30) == 60\n assert candidate(coins = [15, 20, 25],k = 50) == 420\n assert candidate(coins = [13, 26, 39, 52, 65, 78],k = 150) == 1950\n assert candidate(coins = [2, 3, 5, 7],k = 25) == 33\n assert candidate(coins = [9, 18, 27, 36, 45],k = 30) == 270\n assert candidate(coins = [8, 16, 24, 32, 40, 48],k = 200) == 1600\n assert candidate(coins = [7, 14, 28],k = 15) == 105\n assert candidate(coins = [2, 5, 10, 25],k = 50) == 84\n"}, "metadata": {"canonical_parameter_names": ["coins", "k"], "leetcode_dataset_entry_point": "Solution().findKthSmallest", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "long long findKthSmallest(vector& coins, int k) {", "container": "Solution", "callable": "findKthSmallest", "parameters": [{"name": "coins", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "long long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3117, "task_id": "minimum-sum-of-values-by-dividing-array", "difficulty": "Hard", "problem_description": "You are given two arrays nums and andValues of length n and m respectively.\nThe value of an array is equal to the last element of that array.\nYou have to divide nums into m disjoint contiguous subarrays such that for the ith subarray [li, ri], the bitwise AND of the subarray elements is equal to andValues[i], in other words, nums[li] & nums[li + 1] & ... & nums[ri] == andValues[i] for all 1 <= i <= m, where & represents the bitwise AND operator.\nReturn the minimum possible sum of the values of the m subarrays nums is divided into. If it is not possible to divide nums into m subarrays satisfying these conditions, return -1.\n \nExample 1:\n\nInput: nums = [1,4,3,3,2], andValues = [0,3,3,2]\nOutput: 12\nExplanation:\nThe only possible way to divide nums is:\n\n[1,4] as 1 & 4 == 0.\n[3] as the bitwise AND of a single element subarray is that element itself.\n[3] as the bitwise AND of a single element subarray is that element itself.\n[2] as the bitwise AND of a single element subarray is that element itself.\n\nThe sum of the values for these subarrays is 4 + 3 + 3 + 2 = 12.\n\nExample 2:\n\nInput: nums = [2,3,5,7,7,7,5], andValues = [0,7,5]\nOutput: 17\nExplanation:\nThere are three ways to divide nums:\n\n[[2,3,5],[7,7,7],[5]] with the sum of the values 5 + 7 + 5 == 17.\n[[2,3,5,7],[7,7],[5]] with the sum of the values 7 + 7 + 5 == 19.\n[[2,3,5,7,7],[7],[5]] with the sum of the values 7 + 7 + 5 == 19.\n\nThe minimum possible sum of the values is 17.\n\nExample 3:\n\nInput: nums = [1,2,3,4], andValues = [2]\nOutput: -1\nExplanation:\nThe bitwise AND of the entire array nums is 0. As there is no possible way to divide nums into a single subarray to have the bitwise AND of elements 2, return -1.\n\n \nConstraints:\n\n1 <= n == nums.length <= 104\n1 <= m == andValues.length <= min(n, 10)\n1 <= nums[i] < 105\n0 <= andValues[j] < 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 5, 5, 5],andValues = [5, 5]) == 10\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16],andValues = [0, 0, 0]) == 28\n assert candidate(nums = [8, 12, 10, 14],andValues = [8, 14]) == 24\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],andValues = [10, 10, 10, 10]) == 40\n assert candidate(nums = [15, 11, 13, 14, 12],andValues = [15, 11, 12]) == 38\n assert candidate(nums = [10, 20, 30, 40, 50],andValues = [10, 20, 30]) == -1\n assert candidate(nums = [9, 18, 27, 36],andValues = [9, 18, 27]) == -1\n assert candidate(nums = [1, 2, 3, 4],andValues = [2]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],andValues = [1]) == 1\n assert candidate(nums = [1, 2, 4, 8, 16],andValues = [0, 0, 0, 0, 0]) == -1\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],andValues = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 55\n assert candidate(nums = [31, 30, 29, 28, 27, 26, 25, 24, 23, 22],andValues = [31]) == -1\n assert candidate(nums = [8, 4, 2, 1],andValues = [8, 4, 2, 1]) == 15\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],andValues = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 45\n assert candidate(nums = [1, 4, 3, 3, 2],andValues = [0, 3, 3, 2]) == 12\n assert candidate(nums = [10, 20, 30, 40, 50],andValues = [10, 20, 30, 40, 50]) == 150\n assert candidate(nums = [1, 2, 4, 8, 16],andValues = [1, 2, 4, 8, 16]) == 31\n assert candidate(nums = [1, 1, 1, 1, 1],andValues = [1, 1, 1, 1, 1]) == 5\n assert candidate(nums = [10, 15, 7, 3],andValues = [10, 7]) == -1\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2],andValues = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2]) == 2046\n assert candidate(nums = [7, 7, 7, 7, 7, 7],andValues = [7, 7]) == 14\n assert candidate(nums = [15, 15, 15, 15],andValues = [15]) == 15\n assert candidate(nums = [31, 15, 7, 3],andValues = [31, 15, 7, 3]) == 56\n assert candidate(nums = [31, 31, 31, 31],andValues = [31, 31]) == 62\n assert candidate(nums = [1, 1, 1, 1],andValues = [1, 1, 1, 1]) == 4\n assert candidate(nums = [2, 3, 5, 7, 7, 7, 5],andValues = [0, 7, 5]) == 17\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7],andValues = [7, 7, 7]) == 21\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],andValues = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 100\n assert candidate(nums = [8, 8, 8, 8, 8],andValues = [8, 8, 8]) == 24\n assert candidate(nums = [15, 15, 15, 15, 15],andValues = [15]) == 15\n assert candidate(nums = [6, 6, 6, 6, 6, 6, 6, 6, 6],andValues = [6, 6, 6, 6]) == 24\n assert candidate(nums = [5, 5, 5, 5, 5],andValues = [5, 5]) == 10\n assert candidate(nums = [5, 3, 1, 4, 8, 7],andValues = [5, 3, 1]) == -1\n assert candidate(nums = [9, 10, 11, 12, 13, 14],andValues = [9, 10, 11]) == -1\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3],andValues = [3, 3, 3]) == 9\n assert candidate(nums = [31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],andValues = [31, 30, 29, 28, 27, 26, 25, 24, 23, 22]) == -1\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],andValues = [7, 14, 21, 28, 35]) == -1\n assert candidate(nums = [63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63],andValues = [63, 63, 63, 63]) == 252\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],andValues = [7, 7, 7, 7, 7, 7]) == 42\n assert candidate(nums = [123, 456, 789, 1011, 1213, 1415, 1617, 1819, 2021],andValues = [123, 789, 1617]) == -1\n assert candidate(nums = [64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64],andValues = [64, 64, 64, 64, 64]) == 320\n assert candidate(nums = [31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31],andValues = [31, 31, 31, 31, 31]) == 155\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],andValues = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == 2036\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],andValues = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == -1\n assert candidate(nums = [5, 3, 7, 15, 9, 6, 12],andValues = [3, 7, 12]) == -1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],andValues = [0, 0, 0, 0, 0]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],andValues = [1, 2, 3, 4, 5]) == -1\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8],andValues = [8, 8, 8, 8, 8]) == 40\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],andValues = [0, 1, 2, 4, 8, 16, 32, 64, 128]) == -1\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],andValues = [1, 2, 3, 4, 5]) == -1\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8],andValues = [8, 8, 8, 8, 8]) == 40\n assert candidate(nums = [32, 16, 8, 4, 2, 1, 0, 0, 0, 0],andValues = [32, 16, 8, 4, 2, 1, 0]) == 63\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],andValues = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 70\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],andValues = [5, 10, 15, 20]) == -1\n assert candidate(nums = [2, 6, 10, 14, 18, 22, 26, 30],andValues = [6, 14, 22, 30]) == -1\n assert candidate(nums = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60],andValues = [6, 12, 18, 24, 30, 36, 42, 48, 54]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],andValues = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == -1\n assert candidate(nums = [255, 127, 63, 31, 15, 7, 3, 1, 0, 1],andValues = [1, 3, 7, 15, 31, 63, 127, 255, 1]) == -1\n assert candidate(nums = [17, 17, 17, 17, 17, 17, 17, 17, 17, 17],andValues = [17, 17, 17]) == 51\n assert candidate(nums = [15, 11, 7, 3, 1, 0, 1, 3, 7, 11, 15],andValues = [15, 11, 7, 3, 1]) == -1\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55],andValues = [5, 10, 15, 20, 25]) == -1\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8],andValues = [8, 8, 8, 8]) == 32\n assert candidate(nums = [15, 7, 3, 1, 8, 4, 2, 1],andValues = [1, 3, 2, 8]) == -1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],andValues = [0, 1, 2, 4, 8, 16, 32, 64, 128, 256]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],andValues = [1, 1, 1, 1, 1]) == 5\n assert candidate(nums = [127, 63, 31, 15, 7, 3, 1],andValues = [63, 15, 3]) == -1\n assert candidate(nums = [15, 7, 3, 1, 1, 2, 4, 8],andValues = [1, 3, 3, 0, 2]) == -1\n assert candidate(nums = [15, 7, 3, 1, 15, 3, 7, 1],andValues = [1, 3, 3, 1]) == -1\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9],andValues = [9, 9, 9, 9, 9]) == 45\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],andValues = [3, 3, 3, 3, 3]) == 15\n assert candidate(nums = [255, 255, 255, 255, 255, 255, 255, 255, 255, 255],andValues = [255, 255, 255, 255, 255]) == 1275\n assert candidate(nums = [255, 127, 63, 31, 15, 7, 3, 1],andValues = [127, 31, 7, 1]) == 166\n assert candidate(nums = [255, 127, 63, 31, 15, 7, 3, 1, 0, 0],andValues = [255, 127, 63, 31, 15, 7, 3, 1, 0]) == 502\n assert candidate(nums = [31, 15, 7, 3, 1],andValues = [31, 15, 7, 3, 1]) == 57\n assert candidate(nums = [15, 7, 3, 1, 1, 1, 1, 1, 1, 1],andValues = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == -1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],andValues = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 1023\n assert candidate(nums = [6, 12, 18, 24, 30, 36, 42, 48],andValues = [6, 18, 30, 42]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],andValues = [1, 2, 3, 4, 5]) == -1\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],andValues = [5, 15, 35, 50]) == -1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],andValues = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 50\n assert candidate(nums = [8, 4, 2, 1, 0, 0, 0, 0, 0, 0],andValues = [8, 4, 2, 1, 0]) == 15\n assert candidate(nums = [31, 15, 7, 3, 1, 0, 1, 3, 7, 15],andValues = [0, 1, 3, 7, 15]) == 26\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],andValues = [0, 9, 18, 27, 36, 45, 54, 63, 72]) == -1\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],andValues = [9, 9, 9, 9]) == 36\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],andValues = [3, 7, 15, 31, 63, 127, 255, 511, 1023]) == -1\n assert candidate(nums = [99, 88, 77, 66, 55, 44, 33, 22, 11, 0],andValues = [99, 88, 77, 66, 55, 44, 33, 22, 11]) == -1\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],andValues = [7, 7, 7, 7]) == 28\n assert candidate(nums = [127, 63, 31, 15, 7, 3, 1],andValues = [127, 63, 31, 15, 7, 3, 1]) == 247\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],andValues = [15, 12, 8, 4, 0]) == 40\n assert candidate(nums = [255, 127, 63, 31, 15, 7, 3, 1, 0],andValues = [127, 31, 3]) == -1\n assert candidate(nums = [255, 254, 253, 252, 251, 250, 249, 248, 247, 246],andValues = [255, 246]) == -1\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],andValues = [10, 10, 10, 10, 10]) == 50\n assert candidate(nums = [127, 63, 31, 15, 7, 3, 1, 0, 1, 3, 7, 15, 31, 63, 127],andValues = [127, 63, 31, 15, 7, 3, 1, 0, 1, 3, 7, 15, 31, 63, 127]) == 494\n assert candidate(nums = [8, 4, 2, 1, 1, 2, 4, 8],andValues = [0, 0, 0, 0]) == 15\n assert candidate(nums = [9, 5, 3, 1, 3, 5, 9, 1, 3, 5],andValues = [1, 3, 5, 9]) == -1\n assert candidate(nums = [8, 4, 2, 1, 8, 4, 2, 1],andValues = [8, 4, 2, 1, 8, 4]) == -1\n assert candidate(nums = [63, 62, 61, 60, 59, 58, 57, 56, 55, 54],andValues = [63, 60, 57]) == -1\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],andValues = [7, 7, 7, 7]) == 28\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700],andValues = [0, 100, 500]) == -1\n assert candidate(nums = [10, 11, 12, 13, 14, 15, 10, 11, 12, 13],andValues = [10, 14, 10]) == -1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],andValues = [1, 4, 16, 64, 256]) == -1\n assert candidate(nums = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15],andValues = [15, 15, 15, 15, 15]) == 75\n assert candidate(nums = [32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],andValues = [0, 0, 0, 0, 0]) == 21824\n assert candidate(nums = [5, 7, 15, 9, 13, 8, 6],andValues = [3, 7, 13, 6]) == -1\n assert candidate(nums = [31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15],andValues = [31, 30, 29, 28, 27, 26, 25]) == -1\n assert candidate(nums = [31, 15, 7, 3, 1, 3, 7, 15, 31],andValues = [1, 3, 7, 15, 31]) == 57\n assert candidate(nums = [16, 12, 8, 4, 2, 1, 0, 0, 0],andValues = [0, 0, 0, 0, 0]) == 5\n assert candidate(nums = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3],andValues = [2, 3, 2, 3]) == 10\n assert candidate(nums = [255, 255, 255, 255, 255, 255, 255, 255, 255, 255],andValues = [0, 255, 0, 255, 0]) == -1\n assert candidate(nums = [8, 12, 14, 15, 9, 10, 12],andValues = [8, 14, 10]) == -1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256],andValues = [0, 0, 0, 0, 0, 0, 0]) == -1\n assert candidate(nums = [128, 64, 32, 16, 8, 4, 2, 1],andValues = [128, 64, 32, 16, 8, 4, 2, 1]) == 255\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],andValues = [5, 5, 5, 5, 5]) == 25\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],andValues = [1, 1, 1, 1, 1]) == 5\n assert candidate(nums = [31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1],andValues = [31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 256\n assert candidate(nums = [31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16],andValues = [31, 30, 29, 28, 27]) == -1\n assert candidate(nums = [32, 16, 8, 4, 2, 1, 32, 16, 8, 4, 2, 1],andValues = [32, 16, 8, 4, 2, 1, 32, 16]) == -1\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],andValues = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023]) == -1\n assert candidate(nums = [255, 127, 63, 31, 15, 7, 3, 1, 0],andValues = [255, 127, 63, 31, 15, 7, 3, 1, 0]) == 502\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8],andValues = [8, 8, 8, 8, 8, 8, 8]) == 56\n assert candidate(nums = [128, 64, 32, 16, 8, 4, 2, 1, 0, 0],andValues = [128, 64, 32, 16, 8, 4, 2, 1, 0]) == 255\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900],andValues = [100, 200, 300]) == -1\n assert candidate(nums = [31, 14, 7, 3, 1, 0, 0, 0, 0, 0],andValues = [31, 14, 7, 3, 1, 0]) == 56\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049],andValues = [3, 27, 729, 19683]) == -1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],andValues = [10, 30, 60, 100]) == -1\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],andValues = [15, 14, 13, 12, 11]) == -1\n assert candidate(nums = [255, 127, 63, 31, 15, 7, 3, 1],andValues = [255, 127, 63, 31, 15, 7, 3, 1]) == 502\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],andValues = [0, 2, 8, 32, 128]) == -1\n assert candidate(nums = [15, 10, 7, 8, 4, 6, 5],andValues = [10, 8, 4]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],andValues = [1, 1, 1, 1, 1]) == 5\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],andValues = [10, 10, 10, 10]) == 40\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],andValues = [0, 3, 0, 3, 0]) == -1\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80],andValues = [0, 8, 16, 24, 32]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],andValues = [1, 1, 1, 1, 1, 1, 1, 1, 1, 0]) == -1\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],andValues = [5, 10, 15, 50]) == -1\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],andValues = [15, 14, 13, 12]) == -1\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4, 5, 6, 7],andValues = [0, 1, 2, 3, 4, 5, 6, 7]) == 28\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],andValues = [1, 3, 7, 15]) == -1\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120],andValues = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112]) == 848\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],andValues = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == -1\n assert candidate(nums = [1, 5, 3, 7, 9, 11, 13, 15],andValues = [1, 3, 15]) == -1\n assert candidate(nums = [31, 29, 27, 25, 23, 21, 19, 17],andValues = [29, 21, 17]) == -1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],andValues = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 1023\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],andValues = [7, 7, 7, 7, 7]) == 35\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],andValues = [5, 5, 5, 5]) == 20\n assert candidate(nums = [31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1],andValues = [29, 19, 11, 5]) == -1\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023],andValues = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023]) == 2036\n assert candidate(nums = [123, 456, 789, 1011, 1213, 1314, 1415],andValues = [123, 456, 789, 1415]) == -1\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],andValues = [7, 7, 7, 7, 7]) == 35\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023],andValues = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023]) == 2036\n assert candidate(nums = [8, 4, 2, 1, 0, 0, 1, 2, 4, 8],andValues = [8, 4, 2, 1, 0, 1, 2, 4, 8]) == 30\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047],andValues = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023]) == 3060\n assert candidate(nums = [255, 254, 253, 252, 251, 250, 249, 248, 247, 246, 245, 244, 243, 242, 241],andValues = [255, 254, 253, 252, 251, 250, 249, 248, 247, 246, 245]) == -1\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],andValues = [7, 14, 21, 28, 35, 42, 49, 56, 63]) == -1\n assert candidate(nums = [255, 127, 63, 31, 15, 7, 3, 1, 0, 1, 3, 7, 15, 31, 63, 127, 255],andValues = [255, 127, 63, 31, 15, 7, 3, 1, 0, 1, 3, 7, 15, 31, 63, 127, 255]) == 1004\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],andValues = [0, 10, 30, 40, 50, 60, 70, 80, 90, 100]) == -1\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35],andValues = [5, 15, 35]) == -1\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023],andValues = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023]) == 4072\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],andValues = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 2047\n assert candidate(nums = [255, 127, 63, 31, 15, 7, 3, 1, 0, 1],andValues = [0, 1, 3, 7, 15, 31, 63, 127, 255, 1]) == -1\n assert candidate(nums = [255, 255, 255, 255, 255, 255, 255, 255, 255, 255],andValues = [255, 255, 255, 255, 255]) == 1275\n assert candidate(nums = [21, 22, 23, 24, 25, 26, 27, 28, 29],andValues = [21, 23, 27]) == -1\n assert candidate(nums = [33, 33, 33, 33, 33, 33, 33],andValues = [33, 33, 33, 33]) == 132\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],andValues = [512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == -1\n assert candidate(nums = [31, 14, 7, 3, 1, 1, 1, 1],andValues = [31, 14, 7, 3, 1]) == 56\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],andValues = [1, 2, 4, 8, 16]) == -1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],andValues = [0, 5, 0, 5, 0]) == -1\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56],andValues = [8, 16, 24, 32]) == 104\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],andValues = [1, 1, 1, 1, 1, 1, 1]) == 7\n assert candidate(nums = [1234, 5678, 91011, 121314, 151617, 181920, 212223, 242526, 272829],andValues = [5678, 121314, 212223]) == -1\n"}, "metadata": {"canonical_parameter_names": ["nums", "andValues"], "leetcode_dataset_entry_point": "Solution().minimumValueSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumValueSum(vector& nums, vector& andValues) {", "container": "Solution", "callable": "minimumValueSum", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "andValues", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3120, "task_id": "count-the-number-of-special-characters-i", "difficulty": "Easy", "problem_description": "You are given a string word. A letter is called special if it appears both in lowercase and uppercase in word.\nReturn the number of special letters in word.\n \nExample 1:\n\nInput: word = \"aaAbcBC\"\nOutput: 3\nExplanation:\nThe special characters in word are 'a', 'b', and 'c'.\n\nExample 2:\n\nInput: word = \"abc\"\nOutput: 0\nExplanation:\nNo character in word appears in uppercase.\n\nExample 3:\n\nInput: word = \"abBCab\"\nOutput: 1\nExplanation:\nThe only special character in word is 'b'.\n\n \nConstraints:\n\n1 <= word.length <= 50\nword consists of only lowercase and uppercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word = \"abc\") == 0\n assert candidate(word = \"xyzXYZ\") == 3\n assert candidate(word = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == 26\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\") == 26\n assert candidate(word = \"aabbcc\") == 0\n assert candidate(word = \"AABBCC\") == 0\n assert candidate(word = \"cCcCc\") == 1\n assert candidate(word = \"AaBbCc\") == 3\n assert candidate(word = \"abBCab\") == 1\n assert candidate(word = \"AbCdEfGhIjKlMnOpQrStUvWxYz\") == 0\n assert candidate(word = \"XyZxYz\") == 3\n assert candidate(word = \"a\") == 0\n assert candidate(word = \"A\") == 0\n assert candidate(word = \"aaAbcBC\") == 3\n assert candidate(word = \"bBbB\") == 1\n assert candidate(word = \"aA\") == 1\n assert candidate(word = \"\") == 0\n assert candidate(word = \"MixedCASEwithSPECIALSspecial\") == 7\n assert candidate(word = \"nestedLoopNESTED\") == 5\n assert candidate(word = \"kKkKkKkKkKkKkKkKkKkKkKkKkKkKkKkKkKkKkKkKkKkKkKkKkKkKkKkKkKkKkKkK\") == 1\n assert candidate(word = \"LongStringWithNoSpecials\") == 3\n assert candidate(word = \"vVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvVvV\") == 1\n assert candidate(word = \"abcdefABCDEF\") == 6\n assert candidate(word = \"SpecialLettersTest\") == 3\n assert candidate(word = \"MixedCASEwithSpecials\") == 4\n assert candidate(word = \"UniqueSpecialsABCDabcd\") == 6\n assert candidate(word = \"aaaaBBBBccccDDDDeeeeFFFFggggHHHHiiiiJJJjkkkkLLLLmmmmNNNNooooPPPqqqqRRRRssssTTTTuuuuVVVVwwwwXXXXyyyyZZZZ\") == 1\n assert candidate(word = \"eEeEeEeEeEeEeEeEeEeEeEeEeEeEeEeEeEeEeEeEeEeEeEeEeEeEeEeEeEeEe\") == 1\n assert candidate(word = \"aAbBcC\") == 3\n assert candidate(word = \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaA\") == 1\n assert candidate(word = \"abcABC\") == 3\n assert candidate(word = \"abcdefGHIJKLmnopQRstUVWxyz\") == 0\n assert candidate(word = \"Python3.8\") == 0\n assert candidate(word = \"aAbBC\") == 2\n assert candidate(word = \"worldWORLD\") == 5\n assert candidate(word = \"xylophoneXYZ\") == 2\n assert candidate(word = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == 26\n assert candidate(word = \"qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM\") == 26\n assert candidate(word = \"nestedCASECASEnested\") == 2\n assert candidate(word = \"aAaAaAaAaAaAaAaAaAaA\") == 1\n assert candidate(word = \"SpecialsAllOverAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == 26\n assert candidate(word = \"AbCdefGhIjkLmnopQrstUVwXyZ\") == 0\n assert candidate(word = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\") == 26\n assert candidate(word = \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaA\") == 1\n assert candidate(word = \"UPPERlower\") == 2\n assert candidate(word = \"zZyYxXwWvVuUtTsSrRpPoOnNmMlLkKjJiIhHgGfFeEdDcCbBaA\") == 25\n assert candidate(word = \"NoSpecial\") == 0\n assert candidate(word = \"SpecialCharacters123\") == 2\n assert candidate(word = \"OneSpecialA\") == 1\n assert candidate(word = \"SingleSpeciala\") == 0\n assert candidate(word = \"AbcDeEfGhIjKlMnOpQrStUvWxYz\") == 1\n assert candidate(word = \"helloHELLO\") == 4\n assert candidate(word = \"HelloWorld\") == 0\n assert candidate(word = \"MultipleUUppercases\") == 1\n assert candidate(word = \"wWwWwWwWwWwWwWwWwWwWwWwWwWwWwWwWwWwWwWwWwWwWwWwWwWwWwWwWwWwWwWwW\") == 1\n assert candidate(word = \"yYyYyYyYyYyYyYyYyYyYyYyYyYyYyYyYyYyYyYyYyYyYyYyYyYyYyYyYyYyYyYyY\") == 1\n assert candidate(word = \"AbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYz\") == 0\n assert candidate(word = \"TrailingSpecialsAaBbCc\") == 4\n assert candidate(word = \"abcABCabcABCabcABC\") == 3\n assert candidate(word = \"JustOneSpecialCharacterb\") == 2\n assert candidate(word = \"iIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiI\") == 1\n assert candidate(word = \"noSpecial\") == 0\n assert candidate(word = \"NoSpecialCharacters\") == 2\n assert candidate(word = \"SpecialCharacters\") == 2\n assert candidate(word = \"lowerCASEuppercase\") == 4\n assert candidate(word = \"UniqueUniqueUniqueUnique\") == 1\n assert candidate(word = \"CASEsensitive\") == 2\n assert candidate(word = \"OneSpecialAa\") == 1\n assert candidate(word = \"SingleSpecialA\") == 1\n assert candidate(word = \"jJjJjJjJjJjJjJjJjJjJjJjJjJjJjJjJjJjJjJjJjJjJjJjJjJjJjJjJjJjJjJjJ\") == 1\n assert candidate(word = \"bBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbB\") == 1\n assert candidate(word = \"aabbCCddeeffGGhhiiJJkkllMMnnooppQQrrssttuuVVwwxxyyzz\") == 0\n assert candidate(word = \"MultipleMultipleMultiple\") == 0\n assert candidate(word = \"ComplexMixAaBbCc123!@#AaBbCc\") == 4\n assert candidate(word = \"TestCase\") == 1\n assert candidate(word = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == 26\n assert candidate(word = \"mMmMmMmMmMmMmMmMmMmMmMmMmMmMmMmMmMmMmMmMmMmMmMmMmMmMmMmMmMmMmMmM\") == 1\n assert candidate(word = \"NestedSpecialsAaBBbbCCcc\") == 4\n assert candidate(word = \"fFfFfFfFfFfFfFfFfFfFfFfFfFfFfFfFfFfFfFfFfFfFfFfFfFfFfFfFfFfFfFf\") == 1\n assert candidate(word = \"lLlLlLlLlLlLlLlLlLlLlLlLlLlLlLlLlLlLlLlLlLlLlLlLlLlLlLlLlLlLlLlL\") == 1\n assert candidate(word = \"tTtTtTtTtTtTtTtTtTtTtTtTtTtTtTtTtTtTtTtTtTtTtTtTtTtTtTtTtTtTtTtT\") == 1\n assert candidate(word = \"abcdEFGHijKLMnopQRSTuvWXyz\") == 0\n assert candidate(word = \"JustOneAa\") == 1\n assert candidate(word = \"nNnNnNnNnNnNnNnNnNnNnNnNnNnNnNnNnNnNnNnNnNnNnNnNnNnNnNnNnNnNnNnN\") == 1\n assert candidate(word = \"StartingWithSpecialsAaBbCc\") == 4\n assert candidate(word = \"uniqueUnique\") == 1\n assert candidate(word = \"gGgGgGgGgGgGgGgGgGgGgGgGgGgGgGgGgGgGgGgGgGgGgGgGgGgGgGgGgGgGgGgG\") == 1\n assert candidate(word = \"xXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxX\") == 1\n assert candidate(word = \"AaAaAaAaAaBbBbBbBbCcCcCcCcDdDdDdDdEeEeEeEeFfFfFfFfGgGgGgGgHhHhHhHhIiIiIiIiJjJjJjJjKkKkKkKkLlLlLlLlMmMmMmMmNnNnNnNnOoOoOoOoPpPpPpPpQqQqQqQqRrRrRrRrSsSsSsSsTtTtTtTtUuUuUuUuVvVvVvVvWwWwWwWwXxXxXxXxYyYyYyYyZzZzZzZz\") == 26\n assert candidate(word = \"specialCharSPECIAL\") == 7\n assert candidate(word = \"hHhHhHhHhHhHhHhHhHhHhHhHhHhHhHhHhHhHhHhHhHhHhHhHhHhHhHhHhHhHhHhH\") == 1\n assert candidate(word = \"AlphabetSoup\") == 1\n assert candidate(word = \"AaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAa\") == 1\n assert candidate(word = \"RepeatRepeatREPEAT\") == 4\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ\") == 1\n assert candidate(word = \"pPpPpPpPpPpPpPpPpPpPpPpPpPpPpPpPpPpPpPpPpPpPpPpPpPpPpPpPpPpPpPpP\") == 1\n assert candidate(word = \"aA1Bb2Cc3Dd4Ee5Ff6Gg7Hh8Ii9Jj0\") == 10\n assert candidate(word = \"specialCharacters\") == 1\n assert candidate(word = \"sSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsS\") == 1\n assert candidate(word = \"aAaAaA\") == 1\n assert candidate(word = \"JustOneZz\") == 1\n assert candidate(word = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzAaBbCc\") == 26\n assert candidate(word = \"Zebra\") == 0\n assert candidate(word = \"EndingWithSpecialsAaBbCc\") == 5\n assert candidate(word = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZ\") == 0\n assert candidate(word = \"bbbbbbbbBBBBBBB\") == 1\n assert candidate(word = \"RePeAtInGChaRaCtErS\") == 3\n assert candidate(word = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzABCD\") == 4\n assert candidate(word = \"AaBbCc1234567890!@#$%^&*()\") == 3\n assert candidate(word = \"repeatedCHARactersCHARacters\") == 3\n assert candidate(word = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzabcdefghijklmnopqrstuvwxyz\") == 26\n assert candidate(word = \"UniqueCASE\") == 2\n assert candidate(word = \"doubleDOUBLEtrouble\") == 6\n assert candidate(word = \"PythonIsAwesome\") == 0\n assert candidate(word = \"MixedCASE123\") == 1\n assert candidate(word = \"QwErTyUiOpAsDfGhJkLzXcVbNm\") == 0\n assert candidate(word = \"rRrRrRrRrRrRrRrRrRrRrRrRrRrRrRrRrRrRrRrRrRrRrRrRrRrRrRrRrRrRrRrR\") == 1\n assert candidate(word = \"abCDefGHijKLmnopQRstUVwxYZ\") == 0\n assert candidate(word = \"abcABCdefDEFghiGHI\") == 9\n assert candidate(word = \"pythonPYTHON\") == 6\n assert candidate(word = \"OverlapOverlap\") == 0\n assert candidate(word = \"aBcDeFgHiJkLmNoPqRsTuVwXyZ\") == 0\n assert candidate(word = \"CASEcase\") == 4\n assert candidate(word = \"testCaseTestCase\") == 1\n assert candidate(word = \"specialCHARSareHERE\") == 5\n assert candidate(word = \"SingleSpecialAa\") == 1\n assert candidate(word = \"qQqQqQqQqQqQqQqQqQqQqQqQqQqQqQqQqQqQqQqQqQqQqQqQqQqQqQqQqQqQqQqQ\") == 1\n assert candidate(word = \"aaBBccDDeeFFggHHiiJJkkLLmmNNooPPqqRRssTTuuVVwwXXyyZZ\") == 0\n assert candidate(word = \"dDdDdDdDdDdDdDdDdDdDdDdDdDdDdDdDdDdDdDdDdDdDdDdDdDdDdDdDdDdDdDd\") == 1\n assert candidate(word = \"SsEeCcIiAaLlTtCcHaArAcCtTeErsRsS\") == 8\n assert candidate(word = \"JustOneSpecialCharacterB\") == 2\n assert candidate(word = \"bBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbB\") == 1\n assert candidate(word = \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAa\") == 1\n assert candidate(word = \"NoRepeatsJustSpecialsAaBbCc\") == 4\n assert candidate(word = \"MiXeDcAsEwItHiSmOvEs\") == 4\n assert candidate(word = \"HelloWORLD\") == 2\n assert candidate(word = \"SpecialCharactersTEST\") == 4\n assert candidate(word = \"ZzYyXxWwVvUuTtSsRrQqPpOoNnMmLlKkJjIiHhGgFfEeDdCcBbAa\") == 26\n assert candidate(word = \"oOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoO\") == 1\n assert candidate(word = \"SpecialCHARacters\") == 4\n assert candidate(word = \"zZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZzZ\") == 1\n assert candidate(word = \"MultiplELowercases\") == 2\n assert candidate(word = \"AabbCCddeEFFgghhIIjjKKllMMnnooppQQrrSsttUuvvWwXxyyZz\") == 7\n assert candidate(word = \"MiXeDcAsE123\") == 1\n assert candidate(word = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == 26\n assert candidate(word = \"OverlapAaBbCcAaBbCc\") == 3\n assert candidate(word = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 0\n assert candidate(word = \"uniqueUnIQUE\") == 4\n assert candidate(word = \"helloWorldHELLO\") == 4\n assert candidate(word = \"specialSPECIAL\") == 7\n assert candidate(word = \"PythonProgramming\") == 0\n assert candidate(word = \"cCcCcCcCcCcCcCcCcCcCcCcCcCcCcCcCcCcCcCcCcCcCcCcCcCcCcCcCcCcCcCcCcCcCc\") == 1\n assert candidate(word = \"uUuUuUuUuUuUuUuUuUuUuUuUuUuUuUuUuUuUuUuUuUuUuUuUuUuUuUuUuUuUuUuU\") == 1\n assert candidate(word = \"SpecialAndNormalChars123!@#\") == 4\n assert candidate(word = \"Mississippi\") == 0\n assert candidate(word = \"MixedCASEWithSOMEspecial\") == 4\n assert candidate(word = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz1234567890\") == 26\n assert candidate(word = \"NoSpecialHere\") == 0\n assert candidate(word = \"aaaaaaaaaAAAAAA\") == 1\n"}, "metadata": {"canonical_parameter_names": ["word"], "leetcode_dataset_entry_point": "Solution().numberOfSpecialChars", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int numberOfSpecialChars(string word) {", "container": "Solution", "callable": "numberOfSpecialChars", "parameters": [{"name": "word", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3121, "task_id": "count-the-number-of-special-characters-ii", "difficulty": "Medium", "problem_description": "You are given a string word. A letter c is called special if it appears both in lowercase and uppercase in word, and every lowercase occurrence of c appears before the first uppercase occurrence of c.\nReturn the number of special letters in word.\n \nExample 1:\n\nInput: word = \"aaAbcBC\"\nOutput: 3\nExplanation:\nThe special characters are 'a', 'b', and 'c'.\n\nExample 2:\n\nInput: word = \"abc\"\nOutput: 0\nExplanation:\nThere are no special characters in word.\n\nExample 3:\n\nInput: word = \"AbBCab\"\nOutput: 0\nExplanation:\nThere are no special characters in word.\n\n \nConstraints:\n\n1 <= word.length <= 2 * 105\nword consists of only lowercase and uppercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word = \"aAbBcCdDeEfFgG\") == 7\n assert candidate(word = \"AaBbCc\") == 0\n assert candidate(word = \"aabbCC\") == 0\n assert candidate(word = \"Aabbcc\") == 0\n assert candidate(word = \"abABcdCD\") == 4\n assert candidate(word = \"zZaA\") == 2\n assert candidate(word = \"aAbBcC\") == 3\n assert candidate(word = \"aAb\") == 1\n assert candidate(word = \"abcABC\") == 3\n assert candidate(word = \"ZzYyXxWwVvUuTtSsRrQqPpOoNnMmLlKkJjIiHhGgFfEeDdCcBbAa\") == 0\n assert candidate(word = \"AbBCab\") == 0\n assert candidate(word = \"ZzYyXx\") == 0\n assert candidate(word = \"ZzYyXxWwVvUuTtSsRrQqPpOoNnMmLlKkJjiIhHgGfFeEdDcCbBaA\") == 9\n assert candidate(word = \"aA\") == 1\n assert candidate(word = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == 0\n assert candidate(word = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 0\n assert candidate(word = \"abcdefgHIJKLmnopqrstuvwxyz\") == 0\n assert candidate(word = \"aaAbcBC\") == 3\n assert candidate(word = \"aabB\") == 1\n assert candidate(word = \"abc\") == 0\n assert candidate(word = \"Aa\") == 0\n assert candidate(word = \"aabbccAABBCC\") == 3\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\") == 26\n assert candidate(word = \"AaBbCcDdEeFf\") == 0\n assert candidate(word = \"aBcDeFgHiJkLmNoPqRsTuVwXyZ\") == 0\n assert candidate(word = \"AaBbCcDd\") == 0\n assert candidate(word = \"zZyYxXwWvVuUtTsSrRqQpPoOnNmMlLkKjJiIhHgGfFeEdDcCbBaA\") == 26\n assert candidate(word = \"aabbccAAABBBCCC\") == 3\n assert candidate(word = \"zZyYxXwWvVuUtTsSrRpPqQoOnNmMlLkKjJiIhHgGfFeEdDcCbBaA\") == 26\n assert candidate(word = \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaA\") == 0\n assert candidate(word = \"aaaaaAAAAAaaaaaAAAAA\") == 0\n assert candidate(word = \"abcXYZabcXYZ\") == 0\n assert candidate(word = \"zzzzZ\") == 1\n assert candidate(word = \"abcdEFGhijklmNOPqrSTuvWXYZ\") == 0\n assert candidate(word = \"aAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == 0\n assert candidate(word = \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaA\") == 0\n assert candidate(word = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == 0\n assert candidate(word = \"AbCdEfGhIjKlMnOpQrStUvWxYz\") == 0\n assert candidate(word = \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaA\") == 0\n assert candidate(word = \"aAaAaAaAaAaAaAaAaAaA\") == 0\n assert candidate(word = \"aAbBcCddeEfffGggHhhIiiJjjKkkLllMmmNnnOooPppQqqRrrSssTttUuuVvvWwwXxxYyyZzz\") == 4\n assert candidate(word = \"Zabcdefghijklmnopqrstuvwxyz\") == 0\n assert candidate(word = \"zZyYxXwWvVuUtTsSrRpPoOnNmMlLkKjJiIhHgGfFeEdDcCbBaA\") == 25\n assert candidate(word = \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaA\") == 0\n assert candidate(word = \"aBcD\") == 0\n assert candidate(word = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbB\") == 24\n assert candidate(word = \"AbCdeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZ\") == 2\n assert candidate(word = \"xyzXYZabcABC\") == 6\n assert candidate(word = \"zzzzZzzzZzzzzzzz\") == 0\n assert candidate(word = \"AbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYz\") == 0\n assert candidate(word = \"AbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == 25\n assert candidate(word = \"abcABCabcABCabcABC\") == 0\n assert candidate(word = \"abABcdCDefEfghGhijIJklKLmMnopNOPqrstQRstUVuvwVwxWXyzYZ\") == 20\n assert candidate(word = \"AABBCCDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXXYZZZ\") == 0\n assert candidate(word = \"aAAAbBBBcCCCCdDDDD\") == 4\n assert candidate(word = \"AbcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\") == 25\n assert candidate(word = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == 0\n assert candidate(word = \"abCDcdEFefGHghIJijKLklMNmnOPopQRqrSTstUVuvWXwxYZyz\") == 0\n assert candidate(word = \"abcdefABCDEFghijklGHJKLmnopQRStuTUvwVWXyYZ\") == 16\n assert candidate(word = \"AABBCCDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXXYYZZ\") == 0\n assert candidate(word = \"aAAaBBBbcccC\") == 1\n assert candidate(word = \"aBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == 0\n assert candidate(word = \"aaaBBBcccDDD\") == 0\n assert candidate(word = \"abABcdE\") == 2\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\") == 0\n assert candidate(word = \"aBcDDefFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == 21\n assert candidate(word = \"aAbBcCdefGhIjKlMnopQrstUvwXyz\") == 3\n assert candidate(word = \"aaaBBBcccDDDeeeFFFgggHHHiiiJJJkkkLLLmmmNNNoooPPPqqqRRRsssTTTuuuVVVwwwXXXyyyZZZ\") == 0\n assert candidate(word = \"aBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzabcdefghijklmnopqrstuvwxyz\") == 0\n assert candidate(word = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzAaBbCc\") == 0\n assert candidate(word = \"ZZZZzzzzYYYYyyyyXXXXXXXXxxWWWWwwwwVVVVvvvvUUUUuuuuTTTTttttSSSSssssRRRRrrrrQQQQqqqqPPPPppppOOOOooooNNNNnnnnMMMMmmmmLLLLllllKKKKkkkkJJJJjjjjIIIIiiiiHHHHhhhhGGGGggggFFFFFFffffEEEEeeeeDDDDddddCCCCccccBBBBbbbbAAAAAAAAaaaa\") == 0\n assert candidate(word = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZ\") == 0\n assert candidate(word = \"abcdefgHIJKLMNopqrstuvwxyz\") == 0\n assert candidate(word = \"AbCdEfGhIjKlMnOpQrStUvWxYzABCD\") == 2\n assert candidate(word = \"zZyYxXwWvVuUtTrRsSqQpPnNmMlLkKiIhHgGfFeEdDcCbBaA\") == 24\n assert candidate(word = \"aAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 0\n assert candidate(word = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzAA\") == 1\n assert candidate(word = \"aB\") == 0\n assert candidate(word = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaA\") == 1\n assert candidate(word = \"aBcDEfGHiJKlMNopQRsTuVwXyZ\") == 0\n assert candidate(word = \"aaaAAAaaaAAAaaaAAA\") == 0\n assert candidate(word = \"aBbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\") == 0\n assert candidate(word = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == 0\n assert candidate(word = \"zzzZZZyyyYYYxxxXXXwwwWWWvvvVVVuuuUUUtttTTTsssSSSrrrRRRqqqQQQpppPPPoooOOOnnnNNNmmmMMMlllLLLkkkKKKjjjJJJiiiIIIhhhHHHgggGGGfffFFFeeeEEEdddDDDcccCCCbbbBBBaaaAAA\") == 26\n assert candidate(word = \"aBcDefGhiJklMnoPqrStuVwxYz\") == 0\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyz\") == 0\n assert candidate(word = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\") == 0\n assert candidate(word = \"aaBBccDDeeFFggHHiiJJkkLLmmNNooPPqqRRssTTuuVVwwXXyyZZ\") == 0\n assert candidate(word = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\") == 0\n assert candidate(word = \"aaBBccDDeeFFggHHiiJjkkLLmmNNooPPqqRRssTTuuVVwwXXyyZZ\") == 0\n assert candidate(word = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZ\") == 0\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzZ\") == 1\n assert candidate(word = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZ\") == 0\n assert candidate(word = \"mnopqrstuNOPQRS\") == 6\n assert candidate(word = \"aAbC\") == 1\n assert candidate(word = \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaA\") == 0\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyzZ\") == 1\n assert candidate(word = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == 26\n assert candidate(word = \"aAbCdeFghIjKlmNoPqRsTuVwXyZ\") == 1\n assert candidate(word = \"aaAaabBBccCCCd\") == 2\n"}, "metadata": {"canonical_parameter_names": ["word"], "leetcode_dataset_entry_point": "Solution().numberOfSpecialChars", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int numberOfSpecialChars(string word) {", "container": "Solution", "callable": "numberOfSpecialChars", "parameters": [{"name": "word", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3122, "task_id": "minimum-number-of-operations-to-satisfy-conditions", "difficulty": "Medium", "problem_description": "You are given a 2D matrix grid of size m x n. In one operation, you can change the value of any cell to any non-negative number. You need to perform some operations such that each cell grid[i][j] is:\n\nEqual to the cell below it, i.e. grid[i][j] == grid[i + 1][j] (if it exists).\nDifferent from the cell to its right, i.e. grid[i][j] != grid[i][j + 1] (if it exists).\n\nReturn the minimum number of operations needed.\n \nExample 1:\n\nInput: grid = [[1,0,2],[1,0,2]]\nOutput: 0\nExplanation:\n\nAll the cells in the matrix already satisfy the properties.\n\nExample 2:\n\nInput: grid = [[1,1,1],[0,0,0]]\nOutput: 3\nExplanation:\n\nThe matrix becomes [[1,0,1],[1,0,1]] which satisfies the properties, by doing these 3 operations:\n\nChange grid[1][0] to 1.\nChange grid[0][1] to 0.\nChange grid[1][2] to 1.\n\n\nExample 3:\n\nInput: grid = [[1],[2],[3]]\nOutput: 2\nExplanation:\n\nThere is a single column. We can change the value to 1 in each cell using 2 operations.\n\n \nConstraints:\n\n1 <= n, m <= 1000\n0 <= grid[i][j] <= 9\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1], [2], [3]]) == 2\n assert candidate(grid = [[1, 1, 1], [0, 0, 0]]) == 3\n assert candidate(grid = [[0, 1, 2], [2, 1, 0], [0, 1, 2]]) == 2\n assert candidate(grid = [[9, 9], [9, 9], [9, 9]]) == 3\n assert candidate(grid = [[0, 1, 2, 3], [0, 1, 2, 3], [0, 1, 2, 3]]) == 0\n assert candidate(grid = [[1, 1], [2, 2], [3, 3]]) == 4\n assert candidate(grid = [[9, 9, 9], [9, 9, 9], [9, 9, 9]]) == 3\n assert candidate(grid = [[7, 8, 9], [7, 8, 9], [7, 8, 9], [7, 8, 9]]) == 0\n assert candidate(grid = [[1, 1, 2, 2], [2, 2, 1, 1], [1, 1, 2, 2]]) == 6\n assert candidate(grid = [[5, 5, 5, 5], [5, 5, 5, 5], [5, 5, 5, 5]]) == 6\n assert candidate(grid = [[1, 2, 3], [3, 4, 5], [5, 6, 7]]) == 6\n assert candidate(grid = [[1, 2, 3, 4], [4, 3, 2, 1], [1, 2, 3, 4]]) == 4\n assert candidate(grid = [[0]]) == 0\n assert candidate(grid = [[1, 2], [2, 1]]) == 2\n assert candidate(grid = [[0, 1, 2], [3, 4, 5], [6, 7, 8]]) == 6\n assert candidate(grid = [[1, 2], [3, 4]]) == 2\n assert candidate(grid = [[1, 0, 2], [1, 0, 2]]) == 0\n assert candidate(grid = [[0, 0, 0, 0], [1, 1, 1, 1], [2, 2, 2, 2]]) == 8\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 0], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 18\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 4\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]]) == 24\n assert candidate(grid = [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]]) == 12\n assert candidate(grid = [[9, 9, 9, 9, 9], [8, 8, 8, 8, 8], [7, 7, 7, 7, 7]]) == 10\n assert candidate(grid = [[1, 1, 2, 2, 3, 3], [1, 1, 2, 2, 3, 3], [4, 4, 5, 5, 6, 6], [4, 4, 5, 5, 6, 6]]) == 12\n assert candidate(grid = [[1, 1, 2, 2, 3, 3], [1, 1, 2, 2, 3, 3], [1, 1, 2, 2, 3, 3]]) == 9\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == 9\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 6\n assert candidate(grid = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [2, 1, 2, 1, 2, 1, 2, 1, 2, 1]]) == 18\n assert candidate(grid = [[1, 2, 2, 3], [1, 2, 2, 3], [1, 2, 2, 3]]) == 3\n assert candidate(grid = [[9, 9, 9, 9], [8, 8, 8, 8], [7, 7, 7, 7], [6, 6, 6, 6]]) == 12\n assert candidate(grid = [[1, 2, 1, 2, 1, 2], [2, 1, 2, 1, 2, 1], [1, 2, 1, 2, 1, 2], [2, 1, 2, 1, 2, 1]]) == 12\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 10\n assert candidate(grid = [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5]]) == 0\n assert candidate(grid = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6]]) == 9\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 10\n assert candidate(grid = [[5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5]]) == 12\n assert candidate(grid = [[0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0]]) == 12\n assert candidate(grid = [[0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [2, 2, 2, 2, 2]]) == 10\n assert candidate(grid = [[0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [2, 2, 2, 2, 2], [3, 3, 3, 3, 3]]) == 15\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 0\n assert candidate(grid = [[1, 2, 1, 2, 1], [2, 1, 2, 1, 2], [1, 2, 1, 2, 1]]) == 5\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 0], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [1, 2, 3, 4, 5, 6, 7, 8, 9, 0], [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 18\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 16\n assert candidate(grid = [[0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[0, 1, 2, 3, 4], [5, 6, 7, 8, 9], [0, 1, 2, 3, 4]]) == 5\n assert candidate(grid = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]]) == 5\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4, 4, 4, 4, 4]]) == 30\n assert candidate(grid = [[1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0]]) == 6\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]]) == 10\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]]) == 14\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 15\n assert candidate(grid = [[1, 1, 2, 2, 3], [1, 1, 2, 2, 3], [1, 1, 2, 2, 3], [1, 1, 2, 2, 3]]) == 8\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 0], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]]) == 18\n assert candidate(grid = [[1, 1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 1, 2, 3, 4, 5, 6, 7, 8, 9]]) == 3\n assert candidate(grid = [[1, 1, 2, 2, 3, 3, 4, 4, 5, 5], [1, 1, 2, 2, 3, 3, 4, 4, 5, 5], [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]]) == 15\n assert candidate(grid = [[9, 8, 7], [6, 5, 4], [3, 2, 1], [0, 9, 8], [7, 6, 5]]) == 12\n assert candidate(grid = [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5]]) == 0\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 5, 6, 7, 8, 9]]) == 0\n assert candidate(grid = [[9, 9, 9, 9], [8, 8, 8, 8], [7, 7, 7, 7]]) == 8\n assert candidate(grid = [[1, 1, 1, 1, 1], [2, 2, 2, 2, 2], [3, 3, 3, 3, 3]]) == 10\n assert candidate(grid = [[9, 8, 7, 6], [9, 8, 7, 6], [9, 8, 7, 6]]) == 0\n assert candidate(grid = [[1, 1, 1, 2, 2, 2], [3, 3, 3, 4, 4, 4], [5, 5, 5, 6, 6, 6]]) == 12\n assert candidate(grid = [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [1, 1, 1, 1]]) == 10\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0], [0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 20\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 0], [1, 2, 3, 4, 5, 6, 7, 8, 9, 0], [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]]) == 0\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 2, 3, 4, 5], [5, 4, 3, 2, 1]]) == 8\n assert candidate(grid = [[1, 2, 1, 2, 1, 2, 1, 2, 1, 2], [2, 1, 2, 1, 2, 1, 2, 1, 2, 1], [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]]) == 10\n assert candidate(grid = [[9, 8, 7, 6, 5], [4, 3, 2, 1, 0], [9, 8, 7, 6, 5]]) == 5\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]]) == 16\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]]) == 5\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]]) == 20\n assert candidate(grid = [[4, 3, 2, 1], [4, 3, 2, 1], [4, 3, 2, 1], [4, 3, 2, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == 10\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]]) == 32\n assert candidate(grid = [[1, 1, 2, 2, 1, 1], [2, 2, 1, 1, 2, 2], [1, 1, 2, 2, 1, 1]]) == 9\n assert candidate(grid = [[1, 1, 1, 2, 2, 2], [1, 1, 1, 2, 2, 2], [1, 1, 1, 2, 2, 2]]) == 6\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 2, 1, 2, 1, 2], [2, 2, 2, 2, 2, 2], [2, 1, 2, 1, 2, 1], [1, 1, 1, 1, 1, 1]]) == 15\n assert candidate(grid = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]) == 10\n assert candidate(grid = [[0, 0, 0], [1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4]]) == 12\n assert candidate(grid = [[1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0]]) == 10\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 15\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 0], [0, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 18\n assert candidate(grid = [[0, 0, 0, 0, 0], [0, 1, 0, 1, 0], [0, 0, 0, 0, 0], [0, 1, 0, 1, 0]]) == 4\n assert candidate(grid = [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3]]) == 8\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 2, 4, 5]]) == 6\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4, 4]]) == 21\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]]) == 20\n assert candidate(grid = [[5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5]]) == 5\n assert candidate(grid = [[1, 0, 0, 0, 1], [0, 1, 1, 1, 0], [0, 1, 1, 1, 0], [1, 0, 0, 0, 1]]) == 10\n assert candidate(grid = [[1, 2, 2, 3, 3, 4, 4, 5, 5, 6], [1, 2, 2, 3, 3, 4, 4, 5, 5, 6], [1, 2, 2, 3, 3, 4, 4, 5, 5, 6]]) == 12\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 10\n assert candidate(grid = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]) == 0\n assert candidate(grid = [[3, 3, 3, 3, 3, 3, 3], [2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1]]) == 14\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 7, 9]]) == 8\n assert candidate(grid = [[1, 2, 1, 2, 1], [2, 1, 2, 1, 2], [1, 2, 1, 2, 1], [2, 1, 2, 1, 2]]) == 10\n assert candidate(grid = [[5, 4, 3, 2, 1], [5, 4, 3, 2, 1], [5, 4, 3, 2, 1], [5, 4, 3, 2, 1], [5, 4, 3, 2, 1]]) == 0\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9]]) == 8\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0], [0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]]) == 20\n assert candidate(grid = [[0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 10\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]]) == 32\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 20\n assert candidate(grid = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) == 6\n assert candidate(grid = [[0, 0, 1, 1, 2, 2, 3, 3], [0, 0, 1, 1, 2, 2, 3, 3], [0, 0, 1, 1, 2, 2, 3, 3]]) == 12\n assert candidate(grid = [[9, 8, 7, 6, 5], [5, 4, 3, 2, 1], [1, 2, 3, 4, 5]]) == 8\n assert candidate(grid = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9]]) == 18\n assert candidate(grid = [[9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]]) == 0\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 0], [0, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 0], [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 20\n assert candidate(grid = [[9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]]) == 0\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().minimumOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumOperations(vector>& grid) {", "container": "Solution", "callable": "minimumOperations", "parameters": [{"name": "grid", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3123, "task_id": "find-edges-in-shortest-paths", "difficulty": "Hard", "problem_description": "You are given an undirected weighted graph of n nodes numbered from 0 to n - 1. The graph consists of m edges represented by a 2D array edges, where edges[i] = [ai, bi, wi] indicates that there is an edge between nodes ai and bi with weight wi.\nConsider all the shortest paths from node 0 to node n - 1 in the graph. You need to find a boolean array answer where answer[i] is true if the edge edges[i] is part of at least one shortest path. Otherwise, answer[i] is false.\nReturn the array answer.\nNote that the graph may not be connected.\n \nExample 1:\n\n\nInput: n = 6, edges = [[0,1,4],[0,2,1],[1,3,2],[1,4,3],[1,5,1],[2,3,1],[3,5,3],[4,5,2]]\nOutput: [true,true,true,false,true,true,true,false]\nExplanation:\nThe following are all the shortest paths between nodes 0 and 5:\n\nThe path 0 -> 1 -> 5: The sum of weights is 4 + 1 = 5.\nThe path 0 -> 2 -> 3 -> 5: The sum of weights is 1 + 1 + 3 = 5.\nThe path 0 -> 2 -> 3 -> 1 -> 5: The sum of weights is 1 + 1 + 2 + 1 = 5.\n\n\nExample 2:\n\n\nInput: n = 4, edges = [[2,0,1],[0,1,1],[0,3,4],[3,2,2]]\nOutput: [true,false,false,true]\nExplanation:\nThere is one shortest path between nodes 0 and 3, which is the path 0 -> 2 -> 3 with the sum of weights 1 + 2 = 3.\n\n \nConstraints:\n\n2 <= n <= 5 * 104\nm == edges.length\n1 <= m <= min(5 * 104, n * (n - 1) / 2)\n0 <= ai, bi < n\nai != bi\n1 <= wi <= 105\nThere are no repeated edges.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 5,edges = [[0, 1, 2], [0, 2, 2], [1, 2, 3], [1, 3, 2], [2, 3, 1], [2, 4, 4], [3, 4, 2]]) == [False, True, False, False, True, False, True]\n assert candidate(n = 7,edges = [[0, 1, 2], [0, 2, 5], [1, 2, 1], [1, 3, 4], [2, 3, 2], [3, 4, 1], [4, 5, 3], [5, 6, 2]]) == [True, False, True, False, True, True, True, True]\n assert candidate(n = 5,edges = [[0, 1, 2], [0, 2, 3], [1, 2, 1], [1, 3, 4], [2, 3, 2], [3, 4, 1]]) == [True, True, True, False, True, True]\n assert candidate(n = 10,edges = [[0, 1, 1], [0, 2, 1], [0, 3, 1], [1, 4, 1], [1, 5, 1], [2, 6, 1], [2, 7, 1], [3, 8, 1], [3, 9, 1], [4, 5, 1], [6, 7, 1], [8, 9, 1]]) == [False, False, True, False, False, False, False, False, True, False, False, False]\n assert candidate(n = 7,edges = [[0, 1, 3], [1, 2, 2], [2, 3, 1], [3, 4, 1], [4, 5, 2], [5, 6, 3]]) == [True, True, True, True, True, True]\n assert candidate(n = 5,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [0, 4, 10]]) == [True, True, True, True, True]\n assert candidate(n = 3,edges = [[0, 1, 1], [0, 2, 5], [1, 2, 2]]) == [True, False, True]\n assert candidate(n = 4,edges = [[2, 0, 1], [0, 1, 1], [0, 3, 4], [3, 2, 2]]) == [True, False, False, True]\n assert candidate(n = 6,edges = [[0, 1, 4], [0, 2, 1], [1, 3, 2], [1, 4, 3], [1, 5, 1], [2, 3, 1], [3, 5, 3], [4, 5, 2]]) == [True, True, True, False, True, True, True, False]\n assert candidate(n = 3,edges = [[0, 1, 1], [1, 2, 1], [0, 2, 4]]) == [True, True, False]\n assert candidate(n = 15,edges = [[0, 1, 1], [0, 2, 1], [1, 3, 1], [1, 4, 1], [2, 5, 1], [2, 6, 1], [3, 7, 1], [3, 8, 1], [4, 9, 1], [4, 10, 1], [5, 11, 1], [5, 12, 1], [6, 13, 1], [6, 14, 1], [7, 8, 1], [9, 10, 1], [11, 12, 1], [13, 14, 1]]) == [False, True, False, False, False, True, False, False, False, False, False, False, False, True, False, False, False, False]\n assert candidate(n = 25,edges = [[0, 1, 5], [0, 2, 5], [1, 3, 3], [1, 4, 2], [2, 5, 3], [2, 6, 4], [3, 7, 1], [3, 8, 2], [4, 9, 1], [5, 10, 2], [5, 11, 3], [6, 12, 1], [6, 13, 4], [7, 14, 1], [7, 15, 2], [8, 16, 1], [8, 17, 2], [9, 18, 2], [10, 19, 1], [10, 20, 2], [11, 21, 2], [11, 22, 1], [12, 23, 1], [12, 24, 2], [13, 23, 2], [13, 24, 3]]) == [False, True, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, False, False, False, False, False, False, True, False, False]\n assert candidate(n = 10,edges = [[0, 1, 5], [0, 2, 2], [1, 3, 1], [1, 4, 6], [2, 5, 3], [3, 6, 2], [4, 7, 4], [5, 8, 5], [6, 9, 1], [7, 9, 3], [8, 9, 2]]) == [True, False, True, False, False, True, False, False, True, False, False]\n assert candidate(n = 15,edges = [[0, 1, 10], [0, 2, 20], [1, 3, 5], [1, 4, 10], [2, 5, 15], [3, 6, 20], [4, 7, 25], [5, 8, 30], [6, 9, 35], [7, 10, 40], [8, 11, 45], [9, 12, 50], [10, 13, 55], [11, 14, 60], [0, 6, 65], [1, 7, 70], [2, 8, 75], [3, 9, 80], [4, 10, 85], [5, 11, 90], [6, 12, 95], [7, 13, 100], [8, 14, 105]]) == [False, True, False, False, True, False, False, True, False, False, True, False, False, True, False, False, False, False, False, False, False, False, True]\n assert candidate(n = 12,edges = [[0, 1, 3], [0, 2, 2], [1, 3, 1], [2, 4, 4], [3, 5, 2], [4, 6, 3], [5, 7, 1], [6, 8, 5], [7, 9, 2], [8, 10, 1], [9, 11, 3], [10, 11, 2], [0, 5, 7], [1, 6, 8], [2, 7, 9], [3, 8, 10], [4, 9, 11]]) == [True, False, True, False, True, False, True, False, True, False, True, False, False, False, False, False, False]\n assert candidate(n = 10,edges = [[0, 1, 2], [1, 2, 2], [2, 3, 1], [3, 4, 3], [4, 5, 2], [5, 6, 1], [6, 7, 2], [7, 8, 3], [8, 9, 2], [0, 9, 10]]) == [False, False, False, False, False, False, False, False, False, True]\n assert candidate(n = 15,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 1], [1, 4, 2], [2, 5, 3], [2, 6, 4], [3, 7, 2], [3, 8, 3], [4, 9, 1], [4, 10, 4], [5, 11, 2], [5, 12, 3], [6, 13, 4], [6, 14, 5], [7, 8, 1], [9, 10, 2], [11, 12, 3], [13, 14, 4]]) == [False, True, False, False, False, True, False, False, False, False, False, False, False, True, False, False, False, False]\n assert candidate(n = 10,edges = [[0, 1, 2], [0, 2, 4], [0, 3, 1], [1, 4, 3], [1, 5, 1], [2, 3, 2], [2, 6, 5], [3, 7, 1], [4, 8, 2], [5, 8, 3], [6, 9, 4], [7, 9, 3], [8, 9, 1]]) == [False, False, True, False, False, False, False, True, False, False, False, True, False]\n assert candidate(n = 7,edges = [[0, 1, 5], [0, 2, 10], [1, 2, 1], [1, 3, 4], [2, 3, 2], [3, 4, 3], [4, 5, 2], [5, 6, 1], [6, 0, 3]]) == [False, False, False, False, False, False, False, False, True]\n assert candidate(n = 12,edges = [[0, 1, 2], [0, 2, 4], [1, 3, 3], [1, 4, 1], [2, 4, 2], [2, 5, 5], [3, 6, 2], [4, 6, 1], [4, 7, 4], [5, 8, 3], [6, 9, 2], [7, 10, 1], [8, 10, 3], [9, 11, 2], [10, 11, 1]]) == [True, False, False, True, False, False, False, True, False, False, True, False, False, True, False]\n assert candidate(n = 7,edges = [[0, 1, 1], [0, 2, 2], [0, 3, 3], [1, 2, 4], [1, 3, 5], [2, 4, 6], [2, 5, 7], [3, 4, 8], [3, 5, 9], [4, 6, 10], [5, 6, 11]]) == [False, True, False, False, False, True, False, False, False, True, False]\n assert candidate(n = 7,edges = [[0, 1, 5], [0, 2, 3], [1, 3, 2], [2, 3, 1], [3, 4, 4], [4, 5, 2], [5, 6, 1], [2, 4, 6], [0, 5, 7], [1, 6, 8]]) == [False, False, False, False, False, False, True, False, True, False]\n assert candidate(n = 9,edges = [[0, 1, 1], [0, 2, 2], [0, 3, 3], [1, 4, 4], [1, 5, 5], [2, 6, 6], [2, 7, 7], [3, 8, 8], [4, 5, 9], [4, 6, 10], [5, 7, 11], [6, 8, 12], [7, 8, 13]]) == [False, False, True, False, False, False, False, True, False, False, False, False, False]\n assert candidate(n = 10,edges = [[0, 1, 5], [0, 2, 3], [1, 3, 2], [1, 4, 6], [2, 5, 4], [2, 6, 2], [3, 7, 3], [4, 8, 1], [5, 8, 3], [6, 9, 5], [7, 9, 2], [8, 9, 4]]) == [False, True, False, False, False, True, False, False, False, True, False, False]\n assert candidate(n = 8,edges = [[0, 1, 10], [0, 2, 5], [1, 3, 2], [1, 4, 1], [2, 3, 3], [2, 4, 7], [3, 5, 1], [4, 6, 4], [5, 7, 2], [6, 7, 1]]) == [False, True, False, False, True, False, True, False, True, False]\n assert candidate(n = 8,edges = [[0, 1, 10], [0, 2, 20], [1, 3, 5], [1, 4, 15], [2, 3, 20], [2, 5, 10], [3, 6, 15], [4, 6, 5], [5, 7, 5], [6, 7, 10]]) == [False, True, False, False, False, True, False, False, True, False]\n assert candidate(n = 10,edges = [[0, 1, 3], [0, 2, 1], [1, 3, 2], [1, 4, 4], [2, 5, 2], [3, 6, 1], [4, 6, 1], [5, 7, 2], [6, 8, 3], [7, 9, 1], [8, 9, 2]]) == [False, True, False, False, True, False, False, True, False, True, False]\n assert candidate(n = 15,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [1, 4, 4], [2, 5, 2], [3, 6, 5], [4, 7, 1], [5, 8, 3], [6, 9, 4], [7, 10, 2], [8, 11, 1], [9, 12, 3], [10, 13, 4], [11, 14, 2], [12, 14, 5]]) == [False, True, False, False, True, False, False, True, False, False, True, False, False, True, False]\n assert candidate(n = 7,edges = [[0, 1, 5], [0, 2, 3], [1, 2, 2], [1, 3, 6], [2, 3, 4], [2, 4, 3], [3, 4, 1], [3, 5, 2], [4, 5, 3], [4, 6, 4], [5, 6, 2]]) == [False, True, False, False, False, True, False, False, False, True, False]\n assert candidate(n = 8,edges = [[0, 1, 5], [0, 2, 10], [1, 3, 2], [1, 4, 3], [2, 3, 1], [2, 5, 4], [3, 6, 3], [4, 6, 2], [5, 6, 1], [6, 7, 5]]) == [True, False, True, True, False, False, True, True, False, True]\n assert candidate(n = 20,edges = [[0, 1, 5], [0, 2, 3], [1, 3, 4], [1, 4, 2], [2, 5, 1], [2, 6, 3], [3, 7, 2], [3, 8, 4], [4, 9, 2], [5, 10, 3], [5, 11, 1], [6, 12, 4], [6, 13, 1], [7, 14, 2], [7, 15, 3], [8, 16, 1], [8, 17, 4], [9, 18, 2], [10, 19, 3], [11, 12, 2], [13, 14, 1], [15, 16, 2], [17, 18, 3], [18, 19, 4]]) == [False, True, False, False, True, False, False, False, False, True, False, False, False, False, False, False, False, False, True, False, False, False, False, False]\n assert candidate(n = 10,edges = [[0, 1, 1], [0, 2, 2], [0, 3, 3], [1, 4, 1], [2, 5, 2], [3, 6, 3], [4, 7, 1], [5, 8, 2], [6, 9, 3], [7, 8, 1], [7, 9, 2], [8, 9, 3]]) == [True, False, False, True, False, False, True, False, False, False, True, False]\n assert candidate(n = 11,edges = [[0, 1, 2], [0, 2, 3], [1, 2, 1], [1, 3, 4], [1, 4, 5], [2, 5, 2], [2, 6, 3], [3, 6, 1], [3, 7, 4], [4, 8, 2], [4, 9, 3], [5, 9, 1], [5, 10, 2], [6, 10, 3], [7, 8, 1], [8, 9, 2], [8, 10, 1], [9, 10, 2]]) == [True, True, True, False, False, True, False, False, False, False, False, False, True, False, False, False, False, False]\n assert candidate(n = 12,edges = [[0, 1, 2], [0, 2, 3], [1, 3, 4], [1, 4, 5], [2, 3, 6], [2, 4, 7], [3, 5, 8], [4, 5, 9], [5, 6, 10], [5, 7, 11], [5, 8, 12], [6, 9, 13], [7, 10, 14], [8, 11, 15], [9, 10, 16], [10, 11, 17]]) == [True, False, True, False, False, False, True, False, False, False, True, False, False, True, False, False]\n assert candidate(n = 10,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [1, 4, 4], [2, 5, 5], [2, 6, 6], [3, 7, 7], [4, 8, 8], [5, 9, 9], [6, 9, 9], [7, 8, 10]]) == [False, True, False, False, True, False, False, False, True, False, False]\n assert candidate(n = 8,edges = [[0, 1, 1], [0, 2, 2], [0, 3, 3], [1, 4, 1], [2, 4, 1], [3, 4, 1], [4, 5, 2], [5, 6, 1], [6, 7, 2], [4, 7, 3]]) == [True, False, False, True, False, False, False, False, False, True]\n assert candidate(n = 10,edges = [[0, 1, 1], [0, 2, 1], [0, 3, 1], [1, 4, 1], [1, 5, 1], [2, 4, 1], [2, 6, 1], [3, 5, 1], [3, 7, 1], [4, 8, 1], [5, 8, 1], [6, 9, 1], [7, 9, 1], [8, 9, 1], [0, 4, 1], [0, 5, 1], [0, 6, 1], [0, 7, 1], [0, 8, 1], [0, 9, 1]]) == [False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True]\n assert candidate(n = 20,edges = [[0, 1, 2], [0, 2, 4], [1, 3, 1], [1, 4, 3], [2, 5, 2], [2, 6, 4], [3, 7, 1], [4, 8, 1], [5, 9, 2], [6, 10, 1], [7, 11, 3], [8, 12, 2], [9, 13, 3], [10, 14, 1], [11, 15, 2], [12, 16, 1], [13, 17, 3], [14, 18, 2], [15, 19, 1], [16, 18, 2], [17, 19, 3]]) == [True, False, True, False, False, False, True, False, False, False, True, False, False, False, True, False, False, False, True, False, False]\n assert candidate(n = 7,edges = [[0, 1, 1], [0, 2, 2], [1, 2, 1], [1, 3, 3], [2, 3, 1], [2, 4, 2], [3, 4, 1], [3, 5, 3], [4, 5, 1], [4, 6, 2], [5, 6, 1]]) == [True, True, True, False, True, True, True, False, True, True, True]\n assert candidate(n = 9,edges = [[0, 1, 1], [0, 2, 2], [0, 3, 3], [0, 4, 4], [1, 5, 1], [2, 5, 2], [3, 5, 3], [4, 5, 4], [5, 6, 5], [5, 7, 6], [5, 8, 7], [6, 8, 8], [7, 8, 9]]) == [True, False, False, False, True, False, False, False, False, False, True, False, False]\n assert candidate(n = 12,edges = [[0, 1, 2], [0, 2, 3], [1, 3, 4], [1, 4, 5], [2, 5, 6], [2, 6, 7], [3, 7, 8], [3, 8, 9], [4, 8, 10], [4, 9, 11], [5, 10, 12], [5, 11, 13], [6, 10, 14], [6, 11, 15], [7, 11, 16], [8, 11, 17], [9, 11, 18]]) == [False, True, False, False, True, False, False, False, False, False, False, True, False, False, False, False, False]\n assert candidate(n = 10,edges = [[0, 1, 5], [0, 2, 3], [1, 3, 2], [2, 4, 1], [3, 5, 4], [4, 6, 2], [5, 7, 3], [6, 8, 1], [7, 9, 2], [8, 9, 4]]) == [False, True, False, True, False, True, False, True, False, True]\n assert candidate(n = 8,edges = [[0, 1, 2], [0, 2, 3], [1, 3, 1], [1, 4, 4], [2, 5, 2], [3, 6, 3], [4, 7, 2], [5, 6, 1], [6, 7, 4]]) == [True, False, False, True, False, False, True, False, False]\n assert candidate(n = 9,edges = [[0, 1, 2], [0, 2, 1], [0, 3, 3], [1, 4, 2], [1, 5, 4], [2, 4, 1], [2, 6, 3], [3, 7, 2], [3, 8, 1], [4, 5, 2], [5, 6, 3], [6, 7, 2], [7, 8, 1], [8, 5, 1]]) == [False, False, True, False, False, False, False, False, True, False, False, False, False, False]\n assert candidate(n = 12,edges = [[0, 1, 2], [1, 2, 2], [2, 3, 2], [3, 4, 2], [4, 5, 2], [5, 6, 2], [6, 7, 2], [7, 8, 2], [8, 9, 2], [9, 10, 2], [10, 11, 2]]) == [True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 12,edges = [[0, 1, 3], [0, 2, 5], [0, 3, 4], [1, 4, 2], [1, 5, 6], [2, 4, 3], [2, 6, 4], [3, 7, 5], [3, 8, 7], [4, 9, 2], [5, 9, 1], [6, 9, 3], [7, 10, 2], [8, 10, 3], [9, 11, 2]]) == [True, False, False, True, False, False, False, False, False, True, False, False, False, False, True]\n assert candidate(n = 8,edges = [[0, 1, 10], [0, 2, 5], [1, 3, 4], [1, 4, 6], [2, 3, 3], [2, 4, 5], [3, 5, 2], [4, 5, 1], [5, 6, 7], [5, 7, 8], [6, 7, 9]]) == [False, True, False, False, True, False, True, False, False, True, False]\n assert candidate(n = 7,edges = [[0, 1, 5], [0, 2, 3], [1, 3, 2], [1, 4, 1], [2, 4, 1], [2, 5, 4], [3, 6, 3], [4, 6, 2], [5, 6, 1]]) == [False, True, False, False, True, False, False, True, False]\n assert candidate(n = 10,edges = [[0, 1, 5], [0, 2, 2], [1, 3, 3], [1, 4, 7], [2, 3, 1], [2, 4, 6], [3, 5, 4], [3, 6, 2], [4, 7, 5], [5, 8, 3], [6, 8, 2], [7, 9, 1], [8, 9, 4]]) == [False, True, False, False, True, False, False, True, False, False, True, False, True]\n assert candidate(n = 20,edges = [[0, 1, 10], [0, 2, 20], [1, 2, 5], [1, 3, 15], [2, 3, 10], [2, 4, 20], [3, 4, 5], [3, 5, 15], [4, 5, 10], [4, 6, 20], [5, 6, 5], [5, 7, 15], [6, 7, 10], [6, 8, 20], [7, 8, 5], [7, 9, 15], [8, 9, 10], [8, 10, 20], [9, 10, 5], [9, 11, 15], [10, 11, 10], [10, 12, 20], [11, 12, 5], [11, 13, 15], [12, 13, 10], [12, 14, 20], [13, 14, 5], [14, 15, 10], [14, 16, 20], [15, 16, 5], [15, 17, 15], [16, 17, 10], [16, 18, 20], [17, 18, 5], [17, 19, 15], [18, 19, 10]]) == [True, False, True, True, True, False, True, True, True, False, True, True, True, False, True, True, True, False, True, True, True, False, True, True, True, False, True, True, False, True, True, True, False, True, True, True]\n assert candidate(n = 9,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 1], [1, 4, 2], [2, 5, 1], [2, 6, 2], [3, 7, 1], [4, 7, 2], [5, 8, 1], [6, 8, 2], [7, 8, 1]]) == [True, True, True, False, True, False, True, False, True, False, True]\n assert candidate(n = 12,edges = [[0, 1, 10], [0, 2, 5], [1, 3, 2], [1, 4, 8], [2, 5, 3], [3, 6, 4], [4, 7, 3], [5, 8, 2], [6, 9, 5], [7, 10, 4], [8, 11, 3], [9, 11, 2]]) == [False, True, False, False, True, False, False, True, False, False, True, False]\n assert candidate(n = 30,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 15, 15], [15, 16, 16], [16, 17, 17], [17, 18, 18], [18, 19, 19], [19, 20, 20], [20, 21, 21], [21, 22, 22], [22, 23, 23], [23, 24, 24], [24, 25, 25], [25, 26, 26], [26, 27, 27], [27, 28, 28], [28, 29, 29], [0, 29, 100]]) == [False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True]\n assert candidate(n = 7,edges = [[0, 1, 2], [0, 2, 3], [1, 2, 1], [1, 3, 4], [1, 4, 6], [2, 4, 5], [2, 5, 3], [3, 5, 1], [3, 6, 2], [4, 6, 3], [5, 6, 4]]) == [True, False, False, True, False, False, False, False, True, False, False]\n assert candidate(n = 8,edges = [[0, 1, 4], [0, 2, 3], [1, 3, 2], [1, 4, 5], [2, 5, 1], [3, 6, 3], [4, 6, 2], [5, 7, 4], [6, 7, 1], [0, 3, 6], [1, 2, 7]]) == [False, True, False, False, True, False, False, True, False, False, False]\n assert candidate(n = 15,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 1], [1, 4, 3], [2, 5, 2], [2, 6, 4], [3, 7, 1], [4, 8, 1], [5, 9, 2], [6, 10, 1], [7, 11, 3], [8, 12, 2], [9, 13, 3], [10, 14, 1], [11, 12, 2], [12, 13, 1], [13, 14, 2]]) == [False, True, False, False, False, True, False, False, False, True, False, False, False, True, False, False, False]\n assert candidate(n = 15,edges = [[0, 1, 10], [0, 2, 15], [1, 2, 5], [1, 3, 20], [2, 3, 10], [2, 4, 15], [3, 4, 5], [3, 5, 25], [4, 5, 10], [4, 6, 15], [5, 6, 5], [5, 7, 20], [6, 7, 10], [6, 8, 15], [7, 8, 5], [7, 9, 25], [8, 9, 10], [8, 10, 15], [9, 10, 5], [9, 11, 20], [10, 11, 10], [10, 12, 15], [11, 12, 5], [11, 13, 20], [12, 13, 10], [12, 14, 15], [13, 14, 5]]) == [True, True, True, False, True, True, True, False, True, True, True, False, True, True, True, False, True, True, True, False, True, True, True, False, True, True, True]\n assert candidate(n = 7,edges = [[0, 1, 10], [0, 2, 5], [0, 3, 20], [1, 4, 2], [2, 4, 15], [2, 5, 1], [3, 6, 5], [4, 6, 10], [5, 6, 2]]) == [False, True, False, False, False, True, False, False, True]\n assert candidate(n = 8,edges = [[0, 1, 2], [0, 2, 3], [1, 3, 4], [1, 4, 5], [2, 3, 1], [2, 4, 6], [3, 5, 7], [3, 6, 8], [4, 5, 9], [4, 6, 10], [5, 7, 11], [6, 7, 12]]) == [False, True, False, False, True, False, True, False, False, False, True, False]\n assert candidate(n = 10,edges = [[0, 1, 5], [0, 2, 3], [1, 2, 2], [1, 3, 6], [2, 3, 1], [2, 4, 4], [3, 4, 2], [3, 5, 3], [4, 5, 1], [5, 6, 2], [6, 7, 3], [7, 8, 4], [8, 9, 5], [6, 9, 7]]) == [False, True, False, False, True, False, True, True, True, True, False, False, False, True]\n assert candidate(n = 8,edges = [[0, 1, 1], [0, 2, 4], [1, 2, 2], [1, 3, 5], [2, 3, 1], [2, 4, 2], [3, 4, 3], [3, 5, 6], [4, 5, 1], [4, 6, 4], [5, 6, 2], [5, 7, 3], [6, 7, 1]]) == [True, False, True, False, False, True, False, False, True, False, True, True, True]\n assert candidate(n = 15,edges = [[0, 1, 1], [0, 2, 2], [0, 3, 3], [1, 4, 1], [1, 5, 2], [2, 6, 1], [2, 7, 2], [3, 8, 1], [3, 9, 2], [4, 10, 1], [5, 11, 1], [6, 12, 1], [7, 13, 1], [8, 14, 1], [9, 14, 2], [10, 11, 1], [11, 12, 1], [12, 13, 1], [13, 14, 1]]) == [False, False, True, False, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False]\n assert candidate(n = 15,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 1], [1, 4, 1], [2, 4, 2], [2, 5, 2], [3, 6, 1], [4, 6, 1], [4, 7, 1], [5, 8, 2], [6, 9, 1], [7, 9, 1], [8, 10, 2], [9, 11, 1], [10, 12, 1], [11, 13, 2], [12, 13, 1], [13, 14, 1]]) == [True, False, True, True, False, False, True, True, True, False, True, True, False, True, False, True, False, True]\n assert candidate(n = 10,edges = [[0, 1, 5], [0, 2, 10], [1, 3, 3], [1, 4, 7], [2, 3, 2], [2, 5, 8], [3, 4, 1], [3, 6, 4], [4, 7, 6], [5, 6, 1], [6, 7, 2], [6, 8, 3], [7, 9, 5], [8, 9, 1]]) == [True, False, True, False, False, False, False, True, False, False, False, True, False, True]\n assert candidate(n = 7,edges = [[0, 1, 10], [0, 2, 20], [0, 3, 30], [1, 4, 10], [2, 4, 10], [3, 4, 10], [4, 5, 10], [4, 6, 20], [5, 6, 10]]) == [True, False, False, True, False, False, True, True, True]\n assert candidate(n = 9,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [1, 4, 1], [2, 4, 2], [2, 5, 2], [3, 6, 4], [4, 6, 3], [4, 7, 2], [5, 8, 3], [6, 8, 2], [7, 8, 1]]) == [True, False, False, True, False, False, False, False, True, False, False, True]\n assert candidate(n = 6,edges = [[0, 1, 1], [0, 2, 1], [1, 3, 1], [1, 4, 1], [2, 3, 1], [2, 4, 1], [3, 5, 1], [4, 5, 1]]) == [True, True, True, True, True, True, True, True]\n"}, "metadata": {"canonical_parameter_names": ["n", "edges"], "leetcode_dataset_entry_point": "Solution().findAnswer", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector findAnswer(int n, vector>& edges) {", "container": "Solution", "callable": "findAnswer", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "vector>&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3127, "task_id": "make-a-square-with-the-same-color", "difficulty": "Easy", "problem_description": "You are given a 2D matrix grid of size 3 x 3 consisting only of characters 'B' and 'W'. Character 'W' represents the white color, and character 'B' represents the black color.\nYour task is to change the color of at most one cell so that the matrix has a 2 x 2 square where all cells are of the same color.\nReturn true if it is possible to create a 2 x 2 square of the same color, otherwise, return false.\n \n\n\nExample 1:\n\n \n \n \n \n \n \n \n \n \n\n\nInput: grid = [[\"B\",\"W\",\"B\"],[\"B\",\"W\",\"W\"],[\"B\",\"W\",\"B\"]]\nOutput: true\nExplanation:\nIt can be done by changing the color of the grid[0][2].\n\nExample 2:\n\n \n \n \n \n \n \n \n \n \n\n\nInput: grid = [[\"B\",\"W\",\"B\"],[\"W\",\"B\",\"W\"],[\"B\",\"W\",\"B\"]]\nOutput: false\nExplanation:\nIt cannot be done by changing at most one cell.\n\nExample 3:\n\n \n \n \n \n \n \n \n \n \n\n\nInput: grid = [[\"B\",\"W\",\"B\"],[\"B\",\"W\",\"W\"],[\"B\",\"W\",\"W\"]]\nOutput: true\nExplanation:\nThe grid already contains a 2 x 2 square of the same color.\n\n \nConstraints:\n\ngrid.length == 3\ngrid[i].length == 3\ngrid[i][j] is either 'W' or 'B'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [['B', 'W', 'B'], ['W', 'B', 'W'], ['B', 'W', 'B']]) == False\n assert candidate(grid = [['B', 'B', 'W'], ['B', 'B', 'W'], ['B', 'B', 'W']]) == True\n assert candidate(grid = [['B', 'W', 'B'], ['B', 'W', 'W'], ['B', 'W', 'B']]) == True\n assert candidate(grid = [['B', 'B', 'B'], ['B', 'W', 'B'], ['B', 'B', 'B']]) == True\n assert candidate(grid = [['W', 'W', 'B'], ['W', 'W', 'B'], ['W', 'W', 'B']]) == True\n assert candidate(grid = [['W', 'W', 'W'], ['W', 'B', 'W'], ['W', 'W', 'W']]) == True\n assert candidate(grid = [['B', 'W', 'W'], ['W', 'W', 'W'], ['W', 'W', 'B']]) == True\n assert candidate(grid = [['W', 'B', 'W'], ['B', 'W', 'B'], ['W', 'B', 'W']]) == False\n assert candidate(grid = [['B', 'W', 'B'], ['B', 'W', 'W'], ['B', 'W', 'W']]) == True\n assert candidate(grid = [['W', 'B', 'B'], ['B', 'B', 'B'], ['B', 'B', 'W']]) == True\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().canMakeSquare", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool canMakeSquare(vector>& grid) {", "container": "Solution", "callable": "canMakeSquare", "parameters": [{"name": "grid", "type": "vector>&"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3128, "task_id": "right-triangles", "difficulty": "Medium", "problem_description": "You are given a 2D boolean matrix grid.\nA collection of 3 elements of grid is a right triangle if one of its elements is in the same row with another element and in the same column with the third element. The 3 elements may not be next to each other.\nReturn an integer that is the number of right triangles that can be made with 3 elements of grid such that all of them have a value of 1.\n \nExample 1:\n\n\n\n\n0\n1\n0\n\n\n0\n1\n1\n\n\n0\n1\n0\n\n\n\n\n\n\n0\n1\n0\n\n\n0\n1\n1\n\n\n0\n1\n0\n\n\n\n\n\n\n0\n1\n0\n\n\n0\n1\n1\n\n\n0\n1\n0\n\n\n\n\n\nInput: grid = [[0,1,0],[0,1,1],[0,1,0]]\nOutput: 2\nExplanation:\nThere are two right triangles with elements of the value 1. Notice that the blue ones do not form a right triangle because the 3 elements are in the same column.\n\nExample 2:\n\n\n\n\n1\n0\n0\n0\n\n\n0\n1\n0\n1\n\n\n1\n0\n0\n0\n\n\n\n\n\nInput: grid = [[1,0,0,0],[0,1,0,1],[1,0,0,0]]\nOutput: 0\nExplanation:\nThere are no right triangles with elements of the value 1.  Notice that the blue ones do not form a right triangle.\n\nExample 3:\n\n\n\n\n1\n0\n1\n\n\n1\n0\n0\n\n\n1\n0\n0\n\n\n\n\n\n\n1\n0\n1\n\n\n1\n0\n0\n\n\n1\n0\n0\n\n\n\n\n\nInput: grid = [[1,0,1],[1,0,0],[1,0,0]]\nOutput: 2\nExplanation:\nThere are two right triangles with elements of the value 1.\n\n \nConstraints:\n\n1 <= grid.length <= 1000\n1 <= grid[i].length <= 1000\n0 <= grid[i][j] <= 1\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 36\n assert candidate(grid = [[0, 1, 0], [0, 1, 1], [0, 1, 0]]) == 2\n assert candidate(grid = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1]]) == 8\n assert candidate(grid = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(grid = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]) == 0\n assert candidate(grid = [[1, 0, 1], [1, 0, 0], [1, 0, 0]]) == 2\n assert candidate(grid = [[1, 0, 0, 0], [0, 1, 0, 1], [1, 0, 0, 0]]) == 0\n assert candidate(grid = [[1, 0, 0, 0, 1], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [1, 0, 0, 0, 1]]) == 8\n assert candidate(grid = [[0, 1, 1, 0, 1], [1, 0, 0, 1, 0], [1, 0, 1, 0, 0], [0, 1, 0, 1, 0], [0, 0, 1, 0, 1]]) == 18\n assert candidate(grid = [[1, 0, 0, 0, 0], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [1, 0, 0, 0, 1]]) == 5\n assert candidate(grid = [[0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]]) == 144\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == 40\n assert candidate(grid = [[1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1]]) == 72\n assert candidate(grid = [[0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0]]) == 288\n assert candidate(grid = [[0, 1, 0, 0, 1], [1, 0, 1, 1, 0], [0, 1, 0, 1, 0], [0, 0, 1, 0, 1], [1, 0, 0, 1, 0]]) == 18\n assert candidate(grid = [[1, 1, 1, 1], [1, 0, 0, 1], [1, 0, 0, 1], [1, 1, 1, 1]]) == 60\n assert candidate(grid = [[1, 1, 0, 0, 1], [0, 0, 1, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 1, 0, 0, 1]]) == 39\n assert candidate(grid = [[1, 0, 0, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [0, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 0, 0, 1, 0, 1]]) == 109\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0, 0], [0, 0, 1, 0, 1, 0, 1, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 4\n assert candidate(grid = [[0, 0, 0, 0, 0], [0, 1, 1, 1, 0], [0, 1, 0, 1, 0], [0, 1, 1, 1, 0], [0, 0, 0, 0, 0]]) == 24\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 1, 0], [0, 0, 1, 0, 1, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 1, 0, 1, 0, 0], [0, 1, 0, 0, 0, 1, 0], [1, 0, 0, 0, 0, 0, 1]]) == 12\n assert candidate(grid = [[1, 1, 0, 0, 0], [0, 0, 1, 1, 0], [0, 0, 0, 0, 1], [1, 0, 0, 0, 1], [0, 1, 1, 1, 0]]) == 12\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1], [0, 0, 1, 0, 1, 0], [1, 0, 0, 1, 0, 1], [0, 1, 0, 0, 1, 0], [1, 0, 1, 0, 0, 1]]) == 28\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0]]) == 1\n assert candidate(grid = [[1, 1, 0, 0, 0], [1, 0, 1, 0, 0], [0, 1, 0, 1, 0], [0, 0, 1, 0, 1], [0, 0, 0, 1, 1]]) == 10\n assert candidate(grid = [[1, 1, 0, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0, 0], [1, 0, 0, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [0, 0, 1, 0, 0, 0, 1], [1, 0, 0, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]]) == 82\n assert candidate(grid = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]]) == 24\n assert candidate(grid = [[1, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 1, 0, 0], [0, 1, 0, 1, 0, 0, 1], [0, 0, 1, 0, 1, 0, 0], [1, 0, 0, 0, 0, 1, 0]]) == 8\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1]]) == 180\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 1, 0, 0], [0, 0, 1, 0, 0, 1, 0], [0, 0, 0, 1, 0, 0, 1], [0, 0, 1, 0, 0, 1, 0], [0, 1, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == 8\n assert candidate(grid = [[1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0]]) == 48\n assert candidate(grid = [[1, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1]]) == 44\n assert candidate(grid = [[0, 1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 400\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 1, 1, 0, 0, 0], [0, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 0], [0, 0, 0, 1, 1, 0], [0, 0, 0, 0, 0, 0]]) == 8\n assert candidate(grid = [[1, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 1], [1, 0, 1, 1, 0, 1], [1, 0, 1, 1, 0, 1], [1, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1]]) == 296\n assert candidate(grid = [[0, 1, 0, 0, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 0, 0, 1]]) == 28\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 160\n assert candidate(grid = [[1, 1, 0, 0, 0], [0, 0, 1, 1, 0], [0, 0, 0, 0, 1], [1, 0, 0, 0, 1], [0, 1, 0, 0, 1]]) == 8\n assert candidate(grid = [[1, 1, 0, 0], [1, 0, 1, 0], [0, 1, 0, 1], [0, 0, 1, 1]]) == 8\n assert candidate(grid = [[0, 1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1]]) == 36\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 0], [0, 1, 0, 0, 1, 0], [0, 1, 0, 0, 1, 0], [0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]]) == 60\n assert candidate(grid = [[0, 0, 0, 0], [0, 1, 1, 0], [1, 1, 1, 1], [0, 1, 1, 0], [0, 0, 0, 0]]) == 20\n assert candidate(grid = [[1, 0, 0, 0, 1], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [1, 0, 0, 0, 1]]) == 4\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 192\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 0, 0, 0], [0, 1, 1, 0, 0], [0, 0, 1, 1, 0], [0, 0, 0, 1, 1], [0, 0, 0, 0, 1]]) == 7\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1]]) == 12\n assert candidate(grid = [[1, 0, 0, 0, 0, 1], [0, 1, 0, 0, 1, 0], [0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0], [0, 1, 0, 0, 1, 0], [1, 0, 0, 0, 0, 1]]) == 12\n assert candidate(grid = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 1, 1, 1], [0, 0, 1, 1, 1], [0, 0, 1, 1, 1]]) == 36\n assert candidate(grid = [[0, 0, 1, 1, 0], [0, 1, 0, 0, 1], [1, 0, 0, 1, 0], [1, 0, 1, 0, 0], [0, 1, 0, 0, 1]]) == 10\n assert candidate(grid = [[1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 1, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 1, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 144\n assert candidate(grid = [[1, 0, 0, 0, 0, 1], [0, 1, 0, 0, 1, 0], [0, 0, 1, 1, 0, 0], [0, 1, 0, 0, 1, 0], [1, 0, 0, 0, 0, 1]]) == 8\n assert candidate(grid = [[0, 0, 1, 0, 1], [1, 0, 0, 1, 0], [0, 1, 0, 0, 1], [1, 0, 1, 0, 0], [0, 1, 0, 1, 0]]) == 10\n assert candidate(grid = [[1, 0, 0, 0, 1], [0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]]) == 12\n assert candidate(grid = [[1, 0, 0, 1], [0, 1, 1, 0], [1, 0, 0, 1], [0, 1, 1, 0]]) == 8\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 800\n assert candidate(grid = [[1, 1, 0, 0, 0], [1, 1, 0, 0, 0], [0, 0, 1, 1, 0], [0, 0, 1, 1, 0], [0, 0, 0, 0, 1]]) == 8\n assert candidate(grid = [[1, 1, 0, 0, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [0, 0, 1, 1, 0, 0], [1, 0, 0, 0, 1, 0], [0, 1, 0, 1, 0, 1]]) == 50\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 1, 0, 0], [0, 0, 1, 0, 0, 1, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 1, 0, 0, 1, 0], [0, 1, 0, 0, 1, 0, 0], [1, 0, 0, 0, 0, 0, 1]]) == 12\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 544\n assert candidate(grid = [[1, 1, 0, 0, 0, 0, 0, 1], [1, 1, 0, 0, 0, 0, 0, 1], [0, 0, 1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0, 1, 1], [0, 0, 0, 0, 1, 1, 0, 0], [0, 0, 0, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 1, 1]]) == 108\n assert candidate(grid = [[1, 0, 0, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0]]) == 36\n assert candidate(grid = [[0, 1, 0, 1, 0], [1, 0, 0, 0, 1], [0, 1, 1, 0, 0], [0, 0, 0, 1, 0], [1, 0, 0, 0, 1]]) == 7\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().numberOfRightTriangles", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "long long numberOfRightTriangles(vector>& grid) {", "container": "Solution", "callable": "numberOfRightTriangles", "parameters": [{"name": "grid", "type": "vector>&"}], "return_type": "long long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3129, "task_id": "find-all-possible-stable-binary-arrays-i", "difficulty": "Medium", "problem_description": "You are given 3 positive integers zero, one, and limit.\nA binary array arr is called stable if:\n\nThe number of occurrences of 0 in arr is exactly zero.\nThe number of occurrences of 1 in arr is exactly one.\nEach subarray of arr with a size greater than limit must contain both 0 and 1.\n\nReturn the total number of stable binary arrays.\nSince the answer may be very large, return it modulo 109 + 7.\n \nExample 1:\n\nInput: zero = 1, one = 1, limit = 2\nOutput: 2\nExplanation:\nThe two possible stable binary arrays are [1,0] and [0,1], as both arrays have a single 0 and a single 1, and no subarray has a length greater than 2.\n\nExample 2:\n\nInput: zero = 1, one = 2, limit = 1\nOutput: 1\nExplanation:\nThe only possible stable binary array is [1,0,1].\nNote that the binary arrays [1,1,0] and [0,1,1] have subarrays of length 2 with identical elements, hence, they are not stable.\n\nExample 3:\n\nInput: zero = 3, one = 3, limit = 2\nOutput: 14\nExplanation:\nAll the possible stable binary arrays are [0,0,1,0,1,1], [0,0,1,1,0,1], [0,1,0,0,1,1], [0,1,0,1,0,1], [0,1,0,1,1,0], [0,1,1,0,0,1], [0,1,1,0,1,0], [1,0,0,1,0,1], [1,0,0,1,1,0], [1,0,1,0,0,1], [1,0,1,0,1,0], [1,0,1,1,0,0], [1,1,0,0,1,0], and [1,1,0,1,0,0].\n\n \nConstraints:\n\n1 <= zero, one, limit <= 200\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(zero = 3,one = 5,limit = 3) == 40\n assert candidate(zero = 5,one = 5,limit = 4) == 242\n assert candidate(zero = 5,one = 5,limit = 2) == 84\n assert candidate(zero = 1,one = 1,limit = 1) == 2\n assert candidate(zero = 2,one = 2,limit = 3) == 6\n assert candidate(zero = 1,one = 5,limit = 1) == 0\n assert candidate(zero = 200,one = 200,limit = 200) == 587893473\n assert candidate(zero = 4,one = 4,limit = 2) == 34\n assert candidate(zero = 5,one = 4,limit = 2) == 45\n assert candidate(zero = 3,one = 4,limit = 2) == 18\n assert candidate(zero = 2,one = 3,limit = 3) == 10\n assert candidate(zero = 10,one = 10,limit = 5) == 165114\n assert candidate(zero = 4,one = 4,limit = 4) == 70\n assert candidate(zero = 2,one = 2,limit = 2) == 6\n assert candidate(zero = 6,one = 3,limit = 2) == 10\n assert candidate(zero = 1,one = 1,limit = 2) == 2\n assert candidate(zero = 2,one = 5,limit = 2) == 3\n assert candidate(zero = 4,one = 5,limit = 3) == 99\n assert candidate(zero = 3,one = 3,limit = 2) == 14\n assert candidate(zero = 5,one = 5,limit = 3) == 194\n assert candidate(zero = 7,one = 7,limit = 6) == 3418\n assert candidate(zero = 4,one = 3,limit = 2) == 18\n assert candidate(zero = 20,one = 20,limit = 10) == 431683431\n assert candidate(zero = 2,one = 3,limit = 2) == 7\n assert candidate(zero = 1,one = 2,limit = 1) == 1\n assert candidate(zero = 3,one = 4,limit = 3) == 31\n assert candidate(zero = 6,one = 6,limit = 5) == 912\n assert candidate(zero = 3,one = 2,limit = 2) == 7\n assert candidate(zero = 100,one = 100,limit = 50) == 375840050\n assert candidate(zero = 190,one = 10,limit = 2) == 0\n assert candidate(zero = 180,one = 120,limit = 15) == 662485902\n assert candidate(zero = 190,one = 10,limit = 5) == 0\n assert candidate(zero = 10,one = 15,limit = 5) == 2249276\n assert candidate(zero = 120,one = 180,limit = 15) == 662485902\n assert candidate(zero = 100,one = 150,limit = 5) == 357829666\n assert candidate(zero = 175,one = 125,limit = 30) == 482940468\n assert candidate(zero = 10,one = 20,limit = 2) == 66\n assert candidate(zero = 100,one = 200,limit = 10) == 796458380\n assert candidate(zero = 100,one = 50,limit = 15) == 814679806\n assert candidate(zero = 100,one = 50,limit = 2) == 1326\n assert candidate(zero = 200,one = 1,limit = 1) == 0\n assert candidate(zero = 100,one = 150,limit = 30) == 462327057\n assert candidate(zero = 100,one = 1,limit = 2) == 0\n assert candidate(zero = 200,one = 100,limit = 25) == 672942188\n assert candidate(zero = 15,one = 15,limit = 2) == 860142\n assert candidate(zero = 190,one = 10,limit = 4) == 0\n assert candidate(zero = 3,one = 7,limit = 4) == 80\n assert candidate(zero = 50,one = 50,limit = 1) == 2\n assert candidate(zero = 200,one = 200,limit = 2) == 609176335\n assert candidate(zero = 150,one = 50,limit = 10) == 701105470\n assert candidate(zero = 200,one = 1,limit = 200) == 201\n assert candidate(zero = 5,one = 4,limit = 4) == 121\n assert candidate(zero = 20,one = 180,limit = 4) == 0\n assert candidate(zero = 199,one = 199,limit = 199) == 387943228\n assert candidate(zero = 7,one = 3,limit = 4) == 80\n assert candidate(zero = 50,one = 50,limit = 2) == 642129773\n assert candidate(zero = 100,one = 100,limit = 2) == 572804009\n assert candidate(zero = 50,one = 50,limit = 10) == 430250984\n assert candidate(zero = 2,one = 100,limit = 3) == 0\n assert candidate(zero = 150,one = 50,limit = 1) == 0\n assert candidate(zero = 20,one = 10,limit = 4) == 3741210\n assert candidate(zero = 150,one = 100,limit = 50) == 746397052\n assert candidate(zero = 101,one = 100,limit = 3) == 922524303\n assert candidate(zero = 10,one = 190,limit = 2) == 0\n assert candidate(zero = 150,one = 150,limit = 5) == 670611061\n assert candidate(zero = 1,one = 200,limit = 200) == 201\n assert candidate(zero = 199,one = 200,limit = 100) == 287809711\n assert candidate(zero = 150,one = 200,limit = 75) == 592136303\n assert candidate(zero = 200,one = 200,limit = 10) == 346661055\n assert candidate(zero = 4,one = 4,limit = 3) == 62\n assert candidate(zero = 200,one = 199,limit = 100) == 287809711\n assert candidate(zero = 150,one = 120,limit = 10) == 860251283\n assert candidate(zero = 150,one = 150,limit = 10) == 966001232\n assert candidate(zero = 15,one = 15,limit = 4) == 77607590\n assert candidate(zero = 100,one = 100,limit = 200) == 407336795\n assert candidate(zero = 1,one = 200,limit = 1) == 0\n assert candidate(zero = 150,one = 150,limit = 1) == 2\n assert candidate(zero = 15,one = 10,limit = 5) == 2249276\n assert candidate(zero = 150,one = 5,limit = 10) == 0\n assert candidate(zero = 190,one = 10,limit = 10) == 0\n assert candidate(zero = 20,one = 20,limit = 3) == 702925689\n assert candidate(zero = 10,one = 20,limit = 1) == 0\n assert candidate(zero = 1,one = 1,limit = 200) == 2\n assert candidate(zero = 200,one = 100,limit = 10) == 796458380\n assert candidate(zero = 80,one = 20,limit = 5) == 666262799\n assert candidate(zero = 100,one = 101,limit = 3) == 922524303\n assert candidate(zero = 150,one = 50,limit = 8) == 139177940\n assert candidate(zero = 20,one = 20,limit = 6) == 140887996\n assert candidate(zero = 50,one = 50,limit = 200) == 538992043\n assert candidate(zero = 100,one = 100,limit = 10) == 474184186\n assert candidate(zero = 10,one = 10,limit = 1) == 2\n assert candidate(zero = 20,one = 20,limit = 5) == 89895606\n assert candidate(zero = 50,one = 50,limit = 20) == 644307023\n assert candidate(zero = 180,one = 20,limit = 4) == 0\n assert candidate(zero = 199,one = 199,limit = 198) == 387942830\n assert candidate(zero = 199,one = 199,limit = 100) == 541514263\n assert candidate(zero = 50,one = 150,limit = 2) == 0\n assert candidate(zero = 100,one = 10,limit = 3) == 0\n assert candidate(zero = 100,one = 50,limit = 150) == 713790273\n assert candidate(zero = 180,one = 150,limit = 60) == 850799592\n assert candidate(zero = 100,one = 100,limit = 1) == 2\n assert candidate(zero = 120,one = 80,limit = 6) == 885202743\n assert candidate(zero = 5,one = 150,limit = 10) == 0\n assert candidate(zero = 200,one = 200,limit = 3) == 894330409\n assert candidate(zero = 15,one = 15,limit = 3) == 24857864\n assert candidate(zero = 10,one = 190,limit = 10) == 0\n assert candidate(zero = 1,one = 100,limit = 2) == 0\n assert candidate(zero = 100,one = 100,limit = 5) == 20078082\n assert candidate(zero = 180,one = 20,limit = 200) == 680498188\n assert candidate(zero = 180,one = 20,limit = 2) == 0\n assert candidate(zero = 10,one = 15,limit = 4) == 1360424\n assert candidate(zero = 50,one = 150,limit = 5) == 245337662\n assert candidate(zero = 125,one = 175,limit = 80) == 30909440\n assert candidate(zero = 100,one = 1,limit = 50) == 1\n assert candidate(zero = 10,one = 190,limit = 5) == 0\n assert candidate(zero = 150,one = 50,limit = 5) == 245337662\n assert candidate(zero = 80,one = 120,limit = 9) == 674949759\n assert candidate(zero = 50,one = 150,limit = 10) == 701105470\n assert candidate(zero = 15,one = 10,limit = 4) == 1360424\n assert candidate(zero = 150,one = 100,limit = 5) == 357829666\n assert candidate(zero = 150,one = 50,limit = 2) == 0\n assert candidate(zero = 100,one = 100,limit = 20) == 294133308\n assert candidate(zero = 50,one = 100,limit = 10) == 10967566\n assert candidate(zero = 150,one = 200,limit = 199) == 777184933\n assert candidate(zero = 50,one = 150,limit = 7) == 536640420\n assert candidate(zero = 5,one = 200,limit = 4) == 0\n assert candidate(zero = 50,one = 200,limit = 20) == 192149064\n assert candidate(zero = 180,one = 180,limit = 50) == 911610311\n"}, "metadata": {"canonical_parameter_names": ["zero", "one", "limit"], "leetcode_dataset_entry_point": "Solution().numberOfStableArrays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int numberOfStableArrays(int zero, int one, int limit) {", "container": "Solution", "callable": "numberOfStableArrays", "parameters": [{"name": "zero", "type": "int"}, {"name": "one", "type": "int"}, {"name": "limit", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3130, "task_id": "find-all-possible-stable-binary-arrays-ii", "difficulty": "Hard", "problem_description": "You are given 3 positive integers zero, one, and limit.\nA binary array arr is called stable if:\n\nThe number of occurrences of 0 in arr is exactly zero.\nThe number of occurrences of 1 in arr is exactly one.\nEach subarray of arr with a size greater than limit must contain both 0 and 1.\n\nReturn the total number of stable binary arrays.\nSince the answer may be very large, return it modulo 109 + 7.\n \nExample 1:\n\nInput: zero = 1, one = 1, limit = 2\nOutput: 2\nExplanation:\nThe two possible stable binary arrays are [1,0] and [0,1].\n\nExample 2:\n\nInput: zero = 1, one = 2, limit = 1\nOutput: 1\nExplanation:\nThe only possible stable binary array is [1,0,1].\n\nExample 3:\n\nInput: zero = 3, one = 3, limit = 2\nOutput: 14\nExplanation:\nAll the possible stable binary arrays are [0,0,1,0,1,1], [0,0,1,1,0,1], [0,1,0,0,1,1], [0,1,0,1,0,1], [0,1,0,1,1,0], [0,1,1,0,0,1], [0,1,1,0,1,0], [1,0,0,1,0,1], [1,0,0,1,1,0], [1,0,1,0,0,1], [1,0,1,0,1,0], [1,0,1,1,0,0], [1,1,0,0,1,0], and [1,1,0,1,0,0].\n\n \nConstraints:\n\n1 <= zero, one, limit <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(zero = 5,one = 5,limit = 4) == 242\n assert candidate(zero = 100,one = 100,limit = 50) == 375840050\n assert candidate(zero = 5,one = 5,limit = 2) == 84\n assert candidate(zero = 4,one = 4,limit = 3) == 62\n assert candidate(zero = 2,one = 2,limit = 3) == 6\n assert candidate(zero = 3,one = 2,limit = 1) == 1\n assert candidate(zero = 5,one = 4,limit = 2) == 45\n assert candidate(zero = 4,one = 4,limit = 4) == 70\n assert candidate(zero = 10,one = 10,limit = 5) == 165114\n assert candidate(zero = 1,one = 1,limit = 2) == 2\n assert candidate(zero = 4,one = 5,limit = 3) == 99\n assert candidate(zero = 3,one = 3,limit = 2) == 14\n assert candidate(zero = 5,one = 5,limit = 3) == 194\n assert candidate(zero = 100,one = 100,limit = 10) == 474184186\n assert candidate(zero = 4,one = 3,limit = 4) == 35\n assert candidate(zero = 2,one = 3,limit = 2) == 7\n assert candidate(zero = 1,one = 2,limit = 1) == 1\n assert candidate(zero = 7,one = 8,limit = 4) == 5250\n assert candidate(zero = 100,one = 50,limit = 10) == 10967566\n assert candidate(zero = 75,one = 25,limit = 3) == 3276\n assert candidate(zero = 7,one = 10,limit = 4) == 12948\n assert candidate(zero = 9,one = 7,limit = 3) == 4848\n assert candidate(zero = 20,one = 15,limit = 4) == 30552957\n assert candidate(zero = 100,one = 100,limit = 100) == 407336795\n assert candidate(zero = 10,one = 15,limit = 3) == 378412\n assert candidate(zero = 9,one = 11,limit = 2) == 5344\n assert candidate(zero = 150,one = 150,limit = 25) == 469749347\n assert candidate(zero = 12,one = 9,limit = 4) == 174530\n assert candidate(zero = 10,one = 10,limit = 3) == 66486\n assert candidate(zero = 12,one = 12,limit = 10) == 2703832\n assert candidate(zero = 50,one = 50,limit = 10) == 430250984\n assert candidate(zero = 50,one = 50,limit = 5) == 256686735\n assert candidate(zero = 20,one = 10,limit = 4) == 3741210\n assert candidate(zero = 20,one = 18,limit = 6) == 378141764\n assert candidate(zero = 10,one = 5,limit = 3) == 546\n assert candidate(zero = 8,one = 6,limit = 4) == 2386\n assert candidate(zero = 20,one = 20,limit = 10) == 431683431\n assert candidate(zero = 14,one = 14,limit = 4) == 21533230\n assert candidate(zero = 15,one = 12,limit = 5) == 13147531\n assert candidate(zero = 20,one = 10,limit = 2) == 66\n assert candidate(zero = 200,one = 150,limit = 15) == 120261210\n assert candidate(zero = 150,one = 150,limit = 15) == 416993889\n assert candidate(zero = 75,one = 25,limit = 5) == 769798783\n assert candidate(zero = 15,one = 10,limit = 5) == 2249276\n assert candidate(zero = 7,one = 5,limit = 2) == 114\n assert candidate(zero = 13,one = 10,limit = 5) == 914333\n assert candidate(zero = 25,one = 25,limit = 1) == 2\n assert candidate(zero = 17,one = 15,limit = 7) == 539683360\n assert candidate(zero = 8,one = 12,limit = 2) == 1391\n assert candidate(zero = 20,one = 20,limit = 5) == 89895606\n assert candidate(zero = 12,one = 12,limit = 6) == 2555112\n assert candidate(zero = 20,one = 15,limit = 7) == 957788108\n assert candidate(zero = 8,one = 7,limit = 3) == 3296\n assert candidate(zero = 7,one = 5,limit = 1) == 0\n assert candidate(zero = 50,one = 50,limit = 4) == 507669790\n assert candidate(zero = 7,one = 8,limit = 2) == 720\n assert candidate(zero = 15,one = 20,limit = 5) == 983489078\n assert candidate(zero = 6,one = 8,limit = 2) == 300\n assert candidate(zero = 7,one = 5,limit = 4) == 664\n assert candidate(zero = 6,one = 6,limit = 1) == 2\n assert candidate(zero = 15,one = 15,limit = 5) == 119126132\n assert candidate(zero = 15,one = 8,limit = 5) == 277298\n assert candidate(zero = 9,one = 15,limit = 3) == 112216\n assert candidate(zero = 10,one = 8,limit = 3) == 16025\n assert candidate(zero = 12,one = 8,limit = 6) == 114332\n assert candidate(zero = 18,one = 12,limit = 5) == 52051889\n"}, "metadata": {"canonical_parameter_names": ["zero", "one", "limit"], "leetcode_dataset_entry_point": "Solution().numberOfStableArrays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int numberOfStableArrays(int zero, int one, int limit) {", "container": "Solution", "callable": "numberOfStableArrays", "parameters": [{"name": "zero", "type": "int"}, {"name": "one", "type": "int"}, {"name": "limit", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3131, "task_id": "find-the-integer-added-to-array-i", "difficulty": "Easy", "problem_description": "You are given two arrays of equal length, nums1 and nums2.\nEach element in nums1 has been increased (or decreased in the case of negative) by an integer, represented by the variable x.\nAs a result, nums1 becomes equal to nums2. Two arrays are considered equal when they contain the same integers with the same frequencies.\nReturn the integer x.\n \nExample 1:\n\nInput: nums1 = [2,6,4], nums2 = [9,7,5]\nOutput: 3\nExplanation:\nThe integer added to each element of nums1 is 3.\n\nExample 2:\n\nInput: nums1 = [10], nums2 = [5]\nOutput: -5\nExplanation:\nThe integer added to each element of nums1 is -5.\n\nExample 3:\n\nInput: nums1 = [1,1,1,1], nums2 = [1,1,1,1]\nOutput: 0\nExplanation:\nThe integer added to each element of nums1 is 0.\n\n \nConstraints:\n\n1 <= nums1.length == nums2.length <= 100\n0 <= nums1[i], nums2[i] <= 1000\nThe test cases are generated in a way that there is an integer x such that nums1 can become equal to nums2 by adding x to each element of nums1.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [10],nums2 = [5]) == -5\n assert candidate(nums1 = [100, 200, 300],nums2 = [150, 250, 350]) == 50\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [6, 7, 8, 9, 10]) == 5\n assert candidate(nums1 = [7, 7, 7],nums2 = [10, 10, 10]) == 3\n assert candidate(nums1 = [50, 50, 50, 50],nums2 = [55, 55, 55, 55]) == 5\n assert candidate(nums1 = [1000, 0, 500],nums2 = [900, 1000, 400]) == 400\n assert candidate(nums1 = [500, 500, 500],nums2 = [500, 500, 500]) == 0\n assert candidate(nums1 = [5, 10, 15],nums2 = [8, 13, 18]) == 3\n assert candidate(nums1 = [0, 0, 0],nums2 = [3, 3, 3]) == 3\n assert candidate(nums1 = [2, 6, 4],nums2 = [9, 7, 5]) == 3\n assert candidate(nums1 = [999, 999, 999],nums2 = [1000, 1000, 1000]) == 1\n assert candidate(nums1 = [500, 500, 500],nums2 = [400, 400, 400]) == -100\n assert candidate(nums1 = [1000, 0, 500],nums2 = [900, 100, 400]) == 100\n assert candidate(nums1 = [1, 1, 1, 1],nums2 = [1, 1, 1, 1]) == 0\n assert candidate(nums1 = [1, 2, 3],nums2 = [4, 5, 6]) == 3\n assert candidate(nums1 = [999, 999, 999, 999],nums2 = [899, 899, 899, 899]) == -100\n assert candidate(nums1 = [999, 999, 999, 999],nums2 = [994, 994, 994, 994]) == -5\n assert candidate(nums1 = [500, 500, 500, 500, 500],nums2 = [450, 450, 450, 450, 450]) == -50\n assert candidate(nums1 = [2, 4, 6, 8, 10],nums2 = [7, 9, 11, 13, 15]) == 5\n assert candidate(nums1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 10\n assert candidate(nums1 = [0, 0, 0, 0, 0, 0, 0],nums2 = [7, 7, 7, 7, 7, 7, 7]) == 7\n assert candidate(nums1 = [999, 998, 997, 996, 995],nums2 = [994, 993, 992, 991, 990]) == -5\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [20, 30, 40, 50, 60]) == 10\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900],nums2 = [90, 190, 290, 390, 490, 590, 690, 790, 890]) == -10\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60],nums2 = [15, 25, 35, 45, 55, 65]) == 5\n assert candidate(nums1 = [500, 500, 500, 500, 500],nums2 = [0, 0, 0, 0, 0]) == -500\n assert candidate(nums1 = [123, 456, 789],nums2 = [126, 459, 792]) == 3\n assert candidate(nums1 = [5, 15, 25, 35, 45],nums2 = [5, 15, 25, 35, 45]) == 0\n assert candidate(nums1 = [500, 600, 700, 800, 900],nums2 = [450, 550, 650, 750, 850]) == -50\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [1, 11, 21, 31, 41]) == -9\n assert candidate(nums1 = [999, 998, 997, 996],nums2 = [900, 899, 898, 897]) == -99\n assert candidate(nums1 = [7, 14, 21, 28, 35],nums2 = [12, 19, 26, 33, 40]) == 5\n assert candidate(nums1 = [100, 100, 100, 100],nums2 = [200, 200, 200, 200]) == 100\n assert candidate(nums1 = [990, 980, 970, 960, 950],nums2 = [1000, 990, 980, 970, 960]) == 10\n assert candidate(nums1 = [50, 25, 12, 6, 3, 1],nums2 = [100, 75, 62, 56, 53, 51]) == 50\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30],nums2 = [10, 15, 20, 25, 30, 35]) == 5\n assert candidate(nums1 = [123, 456, 789],nums2 = [128, 461, 794]) == 5\n assert candidate(nums1 = [800, 700, 600, 500, 400, 300],nums2 = [900, 800, 700, 600, 500, 400]) == 100\n assert candidate(nums1 = [2, 4, 6, 8, 10, 12, 14],nums2 = [7, 9, 11, 13, 15, 17, 19]) == 5\n assert candidate(nums1 = [999, 998, 997, 996],nums2 = [994, 993, 992, 991]) == -5\n assert candidate(nums1 = [250, 350, 450, 550, 650],nums2 = [245, 345, 445, 545, 645]) == -5\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30],nums2 = [0, 5, 10, 15, 20, 25]) == -5\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 10\n assert candidate(nums1 = [999, 998, 997, 996, 995],nums2 = [1000, 999, 998, 997, 996]) == 1\n assert candidate(nums1 = [300, 300, 300, 300, 300, 300],nums2 = [200, 200, 200, 200, 200, 200]) == -100\n assert candidate(nums1 = [7, 7, 7, 7, 7, 7],nums2 = [12, 12, 12, 12, 12, 12]) == 5\n assert candidate(nums1 = [123, 456, 789],nums2 = [130, 463, 796]) == 7\n assert candidate(nums1 = [5, 5, 5, 5, 5],nums2 = [0, 0, 0, 0, 0]) == -5\n assert candidate(nums1 = [100, 200, 300, 400],nums2 = [50, 150, 250, 350]) == -50\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [200, 300, 400, 500, 600]) == 100\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [50, 150, 250, 350, 450]) == -50\n assert candidate(nums1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],nums2 = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 10\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [50, 150, 250, 350, 450, 550, 650, 750, 850, 950]) == -50\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [6, 8, 10, 12, 14]) == 5\n assert candidate(nums1 = [450, 440, 430],nums2 = [400, 390, 380]) == -50\n assert candidate(nums1 = [0, 2, 4, 6, 8, 10],nums2 = [100, 102, 104, 106, 108, 110]) == 100\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [5, 15, 25, 35, 45]) == -5\n assert candidate(nums1 = [1000, 500, 250, 125, 62, 31, 15],nums2 = [1005, 505, 255, 130, 67, 36, 20]) == 5\n assert candidate(nums1 = [100, 200, 300],nums2 = [50, 150, 250]) == -50\n assert candidate(nums1 = [0, 100, 200, 300, 400],nums2 = [1, 101, 201, 301, 401]) == 1\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3],nums2 = [101, 101, 102, 102, 103, 103]) == 100\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums2 = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]) == 1\n assert candidate(nums1 = [999, 998, 997, 996],nums2 = [996, 995, 994, 993]) == -3\n assert candidate(nums1 = [50, 100, 150, 200, 250],nums2 = [40, 90, 140, 190, 240]) == -10\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 1\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900],nums2 = [105, 205, 305, 405, 505, 605, 705, 805, 905]) == 5\n assert candidate(nums1 = [50, 100, 150, 200, 250, 300],nums2 = [50, 100, 150, 200, 250, 300]) == 0\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [0, 10, 20, 30, 40]) == -10\n assert candidate(nums1 = [50, 150, 250, 350, 450, 550],nums2 = [100, 200, 300, 400, 500, 600]) == 50\n assert candidate(nums1 = [50, 100, 150, 200, 250],nums2 = [45, 95, 145, 195, 245]) == -5\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [101, 101, 101, 101, 101]) == 100\n assert candidate(nums1 = [500, 400, 300, 200, 100],nums2 = [510, 410, 310, 210, 110]) == 10\n assert candidate(nums1 = [250, 500, 750, 1000],nums2 = [300, 550, 800, 1050]) == 50\n assert candidate(nums1 = [0, 1, 2, 3, 4, 5],nums2 = [5, 6, 7, 8, 9, 10]) == 5\n assert candidate(nums1 = [200, 400, 600, 800, 1000],nums2 = [150, 350, 550, 750, 950]) == -50\n assert candidate(nums1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 5\n assert candidate(nums1 = [999, 998, 997, 996, 995, 994, 993],nums2 = [1000, 999, 998, 997, 996, 995, 994]) == 1\n assert candidate(nums1 = [5, 10, 15, 20, 25],nums2 = [0, 5, 10, 15, 20]) == -5\n assert candidate(nums1 = [5, 15, 25, 35, 45, 55, 65],nums2 = [-5, 5, 15, 25, 35, 45, 55]) == -10\n assert candidate(nums1 = [250, 250, 250, 250],nums2 = [300, 300, 300, 300]) == 50\n assert candidate(nums1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 100],nums2 = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 105]) == 5\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [90, 190, 290, 390, 490]) == -10\n assert candidate(nums1 = [7, 14, 21, 28, 35],nums2 = [0, 7, 14, 21, 28]) == -7\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [150, 250, 350, 450, 550]) == 50\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [6, 7, 8, 9, 10]) == 5\n assert candidate(nums1 = [250, 300, 350, 400, 450, 500],nums2 = [200, 250, 300, 350, 400, 450]) == -50\n assert candidate(nums1 = [123, 456, 789],nums2 = [223, 556, 889]) == 100\n assert candidate(nums1 = [999, 998, 997, 996],nums2 = [1000, 999, 998, 997]) == 1\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3],nums2 = [6, 6, 7, 7, 8, 8]) == 5\n assert candidate(nums1 = [5, 10, 15, 20, 25],nums2 = [15, 20, 25, 30, 35]) == 10\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [11, 12, 13, 14, 15]) == 10\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [15, 25, 35, 45, 55]) == 5\n assert candidate(nums1 = [500, 400, 300, 200, 100],nums2 = [400, 300, 200, 100, 0]) == -100\n assert candidate(nums1 = [250, 300, 350, 400],nums2 = [300, 350, 400, 450]) == 50\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [10, 10, 10, 10, 10]) == 9\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3],nums2 = [4, 4, 5, 5, 6, 6]) == 3\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600],nums2 = [95, 195, 295, 395, 495, 595]) == -5\n assert candidate(nums1 = [0, 100, 200, 300, 400],nums2 = [100, 200, 300, 400, 500]) == 100\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [6, 8, 10, 12, 14, 16, 18, 20, 22, 24]) == 5\n assert candidate(nums1 = [999, 888, 777, 666, 555],nums2 = [1000, 889, 778, 667, 556]) == 1\n"}, "metadata": {"canonical_parameter_names": ["nums1", "nums2"], "leetcode_dataset_entry_point": "Solution().addedInteger", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int addedInteger(vector& nums1, vector& nums2) {", "container": "Solution", "callable": "addedInteger", "parameters": [{"name": "nums1", "type": "vector&"}, {"name": "nums2", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3132, "task_id": "find-the-integer-added-to-array-ii", "difficulty": "Medium", "problem_description": "You are given two integer arrays nums1 and nums2.\nFrom nums1 two elements have been removed, and all other elements have been increased (or decreased in the case of negative) by an integer, represented by the variable x.\nAs a result, nums1 becomes equal to nums2. Two arrays are considered equal when they contain the same integers with the same frequencies.\nReturn the minimum possible integer x that achieves this equivalence.\n \nExample 1:\n\nInput: nums1 = [4,20,16,12,8], nums2 = [14,18,10]\nOutput: -2\nExplanation:\nAfter removing elements at indices [0,4] and adding -2, nums1 becomes [18,14,10].\n\nExample 2:\n\nInput: nums1 = [3,5,5,3], nums2 = [7,7]\nOutput: 2\nExplanation:\nAfter removing elements at indices [0,3] and adding 2, nums1 becomes [7,7].\n\n \nConstraints:\n\n3 <= nums1.length <= 200\nnums2.length == nums1.length - 2\n0 <= nums1[i], nums2[i] <= 1000\nThe test cases are generated in a way that there is an integer x such that nums1 can become equal to nums2 by removing two elements and adding x to each element of nums1.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [20, 30, 40]) == -10\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1],nums2 = [2, 2]) == 1\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [12, 22, 32]) == -18\n assert candidate(nums1 = [5, 5, 5, 5, 5],nums2 = [7, 7]) == 2\n assert candidate(nums1 = [10, 10, 20, 20, 30],nums2 = [15, 25]) == 5\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6],nums2 = [3, 4, 5]) == 0\n assert candidate(nums1 = [4, 20, 16, 12, 8],nums2 = [14, 18, 10]) == -2\n assert candidate(nums1 = [8, 16, 24, 32, 40],nums2 = [10, 18]) == -14\n assert candidate(nums1 = [0, 0, 0, 0, 0],nums2 = [1, 1]) == 1\n assert candidate(nums1 = [5, 15, 25, 35, 45],nums2 = [10, 20]) == -15\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [2, 3]) == -1\n assert candidate(nums1 = [0, 0, 0, 0],nums2 = [2, 2]) == 2\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [15, 25]) == -15\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5],nums2 = [7, 7]) == 2\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [4, 8]) == 1\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600],nums2 = [150, 250, 350]) == -150\n assert candidate(nums1 = [3, 5, 5, 3],nums2 = [7, 7]) == 2\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [3, 4]) == 0\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [150, 250]) == -150\n assert candidate(nums1 = [9, 7, 5, 3, 1, -1, -3, -5, -7, -9],nums2 = [5, 3, 1, -1, -3, -5]) == 0\n assert candidate(nums1 = [2, 4, 6, 8, 10, 12],nums2 = [6, 8, 10]) == 0\n assert candidate(nums1 = [0, 1, 2, 3, 4],nums2 = [2, 3, 4]) == 0\n assert candidate(nums1 = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500],nums2 = [150, 200, 250]) == 0\n assert candidate(nums1 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32],nums2 = [12, 14, 16, 18, 20, 22, 24, 26]) == 6\n assert candidate(nums1 = [15, 25, 35, 45, 55, 65, 75],nums2 = [25, 35, 45, 55, 65]) == -10\n assert candidate(nums1 = [9, 18, 27, 36, 45, 54],nums2 = [12, 21, 30]) == -15\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30],nums2 = [10, 15, 20]) == -5\n assert candidate(nums1 = [4, 8, 12, 16, 20, 24],nums2 = [8, 16, 24]) == 4\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [3, 4, 5, 6, 7]) == 0\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35],nums2 = [10, 15, 20]) == -5\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600],nums2 = [110, 210, 310, 410]) == -190\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],nums2 = [6, 7, 8]) == 3\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [7, 7, 7, 7, 7, 7, 7, 7]) == 2\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums2 = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 0\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [200, 300, 400]) == -100\n assert candidate(nums1 = [3, 6, 9, 12, 15, 18],nums2 = [6, 12, 18]) == 3\n assert candidate(nums1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],nums2 = [2, 3, 4, 5, 6]) == 0\n assert candidate(nums1 = [12, 24, 36, 48, 60, 72],nums2 = [24, 48, 72]) == 12\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600],nums2 = [200, 300, 400]) == -100\n assert candidate(nums1 = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65],nums2 = [25, 30, 35]) == 5\n assert candidate(nums1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],nums2 = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 3\n assert candidate(nums1 = [100, 100, 100, 100, 100, 100, 100],nums2 = [100, 100, 100]) == 0\n assert candidate(nums1 = [13, 26, 39, 52, 65, 78],nums2 = [26, 52, 78]) == 13\n assert candidate(nums1 = [12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12],nums2 = [14, 14, 14, 14, 14, 14, 14, 14, 14, 14]) == 2\n assert candidate(nums1 = [3, 6, 9, 12, 15, 18, 21],nums2 = [6, 9, 12, 15, 18]) == -3\n assert candidate(nums1 = [2, 5, 8, 11, 14, 17],nums2 = [8, 11, 14]) == 0\n assert candidate(nums1 = [15, 30, 45, 60, 75, 90],nums2 = [30, 45, 60]) == -15\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [3, 4, 5]) == 0\n assert candidate(nums1 = [1, 100, 2, 99, 3, 98],nums2 = [3, 100, 98]) == inf\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],nums2 = [10, 15, 20, 25, 30]) == -5\n assert candidate(nums1 = [21, 42, 63, 84, 105, 126],nums2 = [42, 84, 126]) == 21\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600],nums2 = [150, 250, 350, 450]) == -150\n assert candidate(nums1 = [7, 14, 21, 28, 35, 42, 49],nums2 = [14, 21, 28]) == -7\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35, 40, 45],nums2 = [10, 15, 20]) == -5\n assert candidate(nums1 = [10, 9, 8, 7, 6, 5, 4],nums2 = [8, 7, 6]) == 0\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600],nums2 = [300, 400, 500]) == 0\n assert candidate(nums1 = [2, 4, 6, 8, 10],nums2 = [4, 6, 8]) == -2\n assert candidate(nums1 = [50, 70, 90, 110, 130, 150],nums2 = [90, 110, 130, 150]) == 0\n assert candidate(nums1 = [0, 0, 0, 0, 0, 0],nums2 = [0, 0, 0]) == 0\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23],nums2 = [7, 9, 11]) == 2\n assert candidate(nums1 = [0, 1, 2, 3, 4, 5],nums2 = [2, 3, 4]) == 0\n assert candidate(nums1 = [1000, 2000, 3000, 4000, 5000, 6000],nums2 = [3000, 4000, 5000]) == 0\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600],nums2 = [200, 300, 400]) == -100\n assert candidate(nums1 = [6, 12, 18, 24, 30, 36],nums2 = [12, 24, 36]) == 6\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11],nums2 = [5, 7, 9]) == 0\n assert candidate(nums1 = [0, 1, 2, 3, 4, 5, 6],nums2 = [2, 3, 4]) == 0\n assert candidate(nums1 = [9, 18, 27, 36, 45, 54],nums2 = [18, 36, 54]) == 9\n assert candidate(nums1 = [123, 246, 369, 492, 615, 738],nums2 = [246, 369, 492]) == -123\n assert candidate(nums1 = [2, 4, 6, 8, 10, 12, 14, 16, 18],nums2 = [6, 8, 10]) == 0\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5],nums2 = [7, 7, 7]) == 2\n assert candidate(nums1 = [7, 14, 21, 28, 35, 42],nums2 = [14, 28, 42]) == 7\n assert candidate(nums1 = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],nums2 = [18, 27, 36, 45, 54]) == -9\n assert candidate(nums1 = [1, 2, 2, 3, 4, 5, 5, 6, 7, 8, 9],nums2 = [5, 6, 7]) == 3\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80],nums2 = [30, 40, 50]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7],nums2 = [5, 6, 7]) == 2\n assert candidate(nums1 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],nums2 = [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38]) == -2\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60],nums2 = [20, 30, 40]) == -10\n assert candidate(nums1 = [30, 29, 28, 27, 26, 25],nums2 = [28, 27, 26]) == -1\n assert candidate(nums1 = [5, 15, 25, 35, 45, 55, 65, 75],nums2 = [25, 35, 45]) == 0\n assert candidate(nums1 = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90],nums2 = [10, 20, 30, 40, 50, 60, 70, 80]) == -10\n assert candidate(nums1 = [50, 55, 60, 65, 70],nums2 = [55, 60, 65]) == -5\n assert candidate(nums1 = [11, 22, 33, 44, 55, 66],nums2 = [22, 33, 44]) == -11\n assert candidate(nums1 = [5, 6, 7, 8, 9, 10, 11, 12],nums2 = [7, 8, 9, 10, 11]) == 0\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4],nums2 = [2, 2, 3, 3, 4]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums2 = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 0\n assert candidate(nums1 = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],nums2 = [500, 400, 300, 200, 100]) == -200\n assert candidate(nums1 = [8, 15, 10, 20, 25],nums2 = [13, 18, 23]) == -2\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [3, 5, 7]) == -2\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],nums2 = [15, 20, 25]) == 0\n assert candidate(nums1 = [12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32],nums2 = [18, 20, 22, 24, 26, 28]) == 2\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6],nums2 = [3, 4, 5]) == 0\n assert candidate(nums1 = [8, 16, 24, 32, 40, 48],nums2 = [16, 24, 32]) == -8\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11],nums2 = [5, 7, 9]) == 0\n assert candidate(nums1 = [10, 15, 20, 25, 30, 35],nums2 = [15, 20, 25]) == -5\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [3, 3, 3, 3]) == 2\n assert candidate(nums1 = [25, 24, 23, 22, 21, 20],nums2 = [23, 22, 21]) == -1\n assert candidate(nums1 = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99],nums2 = [18, 27, 36, 45, 54, 63, 72, 81, 90]) == -9\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],nums2 = [30, 35, 40]) == 15\n assert candidate(nums1 = [2, 4, 6, 8, 10, 12, 14],nums2 = [8, 10, 12]) == 2\n assert candidate(nums1 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],nums2 = [8, 7, 6]) == 3\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [150, 250, 350, 450, 550]) == -150\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600],nums2 = [150, 250, 350]) == -150\n assert candidate(nums1 = [50, 100, 150, 200, 250, 300],nums2 = [75, 125, 175]) == -75\n assert candidate(nums1 = [35, 34, 33, 32, 31, 30],nums2 = [33, 32, 31]) == -1\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3],nums2 = [3, 3, 3]) == inf\n assert candidate(nums1 = [10, 15, 20, 25, 30, 35, 40, 45, 50],nums2 = [20, 25, 30]) == 0\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30],nums2 = [10, 15, 20, 25]) == -5\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110],nums2 = [20, 30, 40]) == -10\n assert candidate(nums1 = [12, 18, 24, 30, 36],nums2 = [18, 24, 30]) == -6\n assert candidate(nums1 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],nums2 = [12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12]) == 2\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [30, 40, 50, 60, 70]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [3, 4, 5, 6, 7, 8]) == 0\n assert candidate(nums1 = [15, 20, 25, 30, 35, 40],nums2 = [20, 25, 30]) == -5\n assert candidate(nums1 = [7, 14, 21, 28, 35, 42],nums2 = [14, 21, 28]) == -7\n assert candidate(nums1 = [1, 1, 1, 2, 2, 2, 3, 3, 4, 4],nums2 = [3, 3, 4, 4]) == 2\n assert candidate(nums1 = [8, 16, 24, 32, 40, 48, 56, 64],nums2 = [10, 18, 26, 34, 42, 50, 58]) == -14\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [4, 5, 6, 7, 8, 9]) == 1\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 1\n assert candidate(nums1 = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500],nums2 = [510, 510, 510, 510, 510, 510, 510, 510]) == 10\n assert candidate(nums1 = [9, 19, 29, 39, 49, 59, 69, 79, 89, 99, 109, 119, 129, 139, 149, 159, 169, 179, 189, 199],nums2 = [39, 49, 59]) == 10\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70],nums2 = [15, 25, 35, 45, 55]) == -15\n assert candidate(nums1 = [998, 999, 1000, 1001, 1002],nums2 = [999, 1000, 1001]) == -1\n assert candidate(nums1 = [8, 16, 24, 32, 40, 48],nums2 = [24, 32, 40]) == 0\n assert candidate(nums1 = [20, 19, 18, 17, 16, 15],nums2 = [18, 17, 16]) == -1\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [120, 220, 320, 420, 520, 620]) == -180\n assert candidate(nums1 = [1, 2, 3, 3, 4, 5, 5, 6, 7, 8],nums2 = [2, 3, 4, 4, 5, 6]) == 1\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6],nums2 = [4, 5, 6]) == 1\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25],nums2 = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == -2\n assert candidate(nums1 = [10, 10, 20, 20, 30, 30, 40, 40],nums2 = [20, 20, 30, 30, 40]) == 0\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],nums2 = [20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == -10\n assert candidate(nums1 = [5, 15, 25, 35, 45, 55],nums2 = [15, 25, 35]) == -10\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70],nums2 = [30, 40, 50]) == 0\n assert candidate(nums1 = [7, 14, 21, 28, 35],nums2 = [9, 16, 23]) == -12\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90],nums2 = [20, 30, 40]) == -10\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 0\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],nums2 = [3, 3, 4, 4]) == 1\n assert candidate(nums1 = [11, 22, 33, 44, 55, 66],nums2 = [22, 33, 44]) == -11\n assert candidate(nums1 = [12, 14, 16, 18, 20, 22, 24, 26, 28, 30],nums2 = [16, 18, 20, 22, 24]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9],nums2 = [5, 6, 7]) == 2\n assert candidate(nums1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],nums2 = [2, 3, 4]) == 0\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41],nums2 = [7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 2\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [5, 6, 7]) == 2\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums2 = [5, 6, 7]) == 2\n assert candidate(nums1 = [14, 28, 42, 56, 70, 84],nums2 = [28, 56, 84]) == 14\n assert candidate(nums1 = [15, 18, 21, 24, 27, 30],nums2 = [12, 15, 18, 21]) == -9\n assert candidate(nums1 = [15, 14, 13, 12, 11, 10],nums2 = [13, 12, 11]) == -1\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4],nums2 = [3, 3, 4, 4]) == 1\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7],nums2 = [5, 6, 7]) == 4\n assert candidate(nums1 = [9, 18, 27, 36, 45, 54],nums2 = [18, 27, 36]) == -9\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3],nums2 = [2, 2, 3]) == 0\n assert candidate(nums1 = [1, 2, 2, 3, 4, 5, 6],nums2 = [3, 4, 5]) == 1\n assert candidate(nums1 = [3, 6, 9, 12, 15],nums2 = [6, 9, 12]) == -3\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9],nums2 = [2, 3, 4, 5, 6, 7, 8]) == -1\n assert candidate(nums1 = [50, 100, 150, 200, 250, 300],nums2 = [150, 200, 250]) == 0\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700],nums2 = [200, 300, 400]) == -100\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [30, 40, 50]) == 0\n assert candidate(nums1 = [1000, 1000, 1000, 1000, 1000, 1000],nums2 = [1002, 1002, 1002]) == 2\n assert candidate(nums1 = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],nums2 = [25, 30, 35, 40, 45, 50]) == 5\n assert candidate(nums1 = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],nums2 = [10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 0\n assert candidate(nums1 = [7, 8, 9, 10, 11, 12, 13],nums2 = [9, 10, 11, 12]) == 0\n assert candidate(nums1 = [45, 47, 49, 51, 53, 55, 57],nums2 = [46, 48, 50, 52, 54]) == -3\n assert candidate(nums1 = [0, 0, 0, 0, 0, 0],nums2 = [0, 0]) == 0\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],nums2 = [3, 3, 4]) == 1\n assert candidate(nums1 = [999, 1000, 1001, 1002, 1003, 1004],nums2 = [1000, 1001, 1002, 1003]) == -1\n assert candidate(nums1 = [10, 9, 8, 7, 6, 5],nums2 = [8, 7, 6]) == -1\n"}, "metadata": {"canonical_parameter_names": ["nums1", "nums2"], "leetcode_dataset_entry_point": "Solution().minimumAddedInteger", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumAddedInteger(vector& nums1, vector& nums2) {", "container": "Solution", "callable": "minimumAddedInteger", "parameters": [{"name": "nums1", "type": "vector&"}, {"name": "nums2", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3133, "task_id": "minimum-array-end", "difficulty": "Medium", "problem_description": "You are given two integers n and x. You have to construct an array of positive integers nums of size n where for every 0 <= i < n - 1, nums[i + 1] is greater than nums[i], and the result of the bitwise AND operation between all elements of nums is x.\nReturn the minimum possible value of nums[n - 1].\n \nExample 1:\n\nInput: n = 3, x = 4\nOutput: 6\nExplanation:\nnums can be [4,5,6] and its last element is 6.\n\nExample 2:\n\nInput: n = 2, x = 7\nOutput: 15\nExplanation:\nnums can be [7,15] and its last element is 15.\n\n \nConstraints:\n\n1 <= n, x <= 108\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 4,x = 8) == 11\n assert candidate(n = 5,x = 1) == 9\n assert candidate(n = 10,x = 1) == 19\n assert candidate(n = 5,x = 3) == 19\n assert candidate(n = 2,x = 7) == 15\n assert candidate(n = 1,x = 10) == 10\n assert candidate(n = 10,x = 16) == 25\n assert candidate(n = 1,x = 5) == 5\n assert candidate(n = 1,x = 32) == 32\n assert candidate(n = 3,x = 4) == 6\n assert candidate(n = 500000,x = 256) == 1000223\n assert candidate(n = 30,x = 2048) == 2077\n assert candidate(n = 500000,x = 2047) == 1023999999\n assert candidate(n = 50,x = 512) == 561\n assert candidate(n = 100,x = 128) == 227\n assert candidate(n = 8,x = 4096) == 4103\n assert candidate(n = 20,x = 8) == 43\n assert candidate(n = 100000,x = 65535) == 6553599999\n assert candidate(n = 512,x = 32768) == 33279\n assert candidate(n = 7,x = 12) == 30\n assert candidate(n = 15,x = 8) == 30\n assert candidate(n = 4,x = 3) == 15\n assert candidate(n = 20,x = 16) == 51\n assert candidate(n = 8,x = 3) == 31\n assert candidate(n = 12,x = 3) == 47\n assert candidate(n = 1,x = 1073741824) == 1073741824\n assert candidate(n = 1000,x = 512) == 2023\n assert candidate(n = 8,x = 1023) == 8191\n assert candidate(n = 100000000,x = 1073741823) == 107374182399999999\n assert candidate(n = 100,x = 16) == 211\n assert candidate(n = 30,x = 17) == 123\n assert candidate(n = 30,x = 64) == 93\n assert candidate(n = 15,x = 31) == 479\n assert candidate(n = 100,x = 255) == 25599\n assert candidate(n = 4,x = 63) == 255\n assert candidate(n = 5,x = 1023) == 5119\n assert candidate(n = 10,x = 1024) == 1033\n assert candidate(n = 8,x = 7) == 63\n assert candidate(n = 5,x = 8) == 12\n assert candidate(n = 50000,x = 31) == 1599999\n assert candidate(n = 9,x = 512) == 520\n assert candidate(n = 4,x = 15) == 63\n assert candidate(n = 6,x = 2048) == 2053\n assert candidate(n = 7,x = 10) == 30\n assert candidate(n = 15,x = 100) == 126\n assert candidate(n = 6,x = 10) == 27\n assert candidate(n = 3,x = 16) == 18\n assert candidate(n = 50,x = 2048) == 2097\n assert candidate(n = 1000,x = 4096) == 5095\n assert candidate(n = 10,x = 1048575) == 10485759\n assert candidate(n = 15,x = 1024) == 1038\n assert candidate(n = 50,x = 128) == 177\n assert candidate(n = 20,x = 2047) == 40959\n assert candidate(n = 25,x = 2048) == 2072\n assert candidate(n = 6,x = 24) == 29\n assert candidate(n = 7,x = 128) == 134\n assert candidate(n = 100,x = 1047552) == 1047651\n assert candidate(n = 15,x = 512) == 526\n assert candidate(n = 3,x = 12) == 14\n assert candidate(n = 20,x = 512) == 531\n assert candidate(n = 1,x = 1023) == 1023\n assert candidate(n = 100000,x = 1023) == 102399999\n assert candidate(n = 3,x = 31) == 95\n assert candidate(n = 5,x = 31) == 159\n assert candidate(n = 50,x = 31) == 1599\n assert candidate(n = 500,x = 512) == 1011\n assert candidate(n = 10000000,x = 4095) == 40959999999\n assert candidate(n = 64,x = 2048) == 2111\n assert candidate(n = 8,x = 32) == 39\n assert candidate(n = 3,x = 13) == 29\n assert candidate(n = 8,x = 31) == 255\n assert candidate(n = 7,x = 64) == 70\n assert candidate(n = 1,x = 1024) == 1024\n assert candidate(n = 1024,x = 65535) == 67108863\n assert candidate(n = 100,x = 4096) == 4195\n assert candidate(n = 7,x = 1024) == 1030\n assert candidate(n = 9,x = 256) == 264\n assert candidate(n = 1000,x = 2048) == 3047\n assert candidate(n = 10,x = 32) == 41\n assert candidate(n = 50,x = 255) == 12799\n assert candidate(n = 100000,x = 128) == 200095\n assert candidate(n = 100000,x = 1) == 199999\n assert candidate(n = 8,x = 255) == 2047\n assert candidate(n = 5,x = 15) == 79\n assert candidate(n = 100,x = 256) == 355\n assert candidate(n = 25,x = 128) == 152\n assert candidate(n = 6,x = 64) == 69\n assert candidate(n = 7,x = 32) == 38\n assert candidate(n = 5,x = 12) == 28\n assert candidate(n = 1,x = 2048) == 2048\n assert candidate(n = 2,x = 1073741823) == 2147483647\n assert candidate(n = 14,x = 1023) == 14335\n assert candidate(n = 50,x = 1024) == 1073\n assert candidate(n = 200,x = 8192) == 8391\n assert candidate(n = 128,x = 16383) == 2097151\n assert candidate(n = 20,x = 3) == 79\n assert candidate(n = 11,x = 512) == 522\n assert candidate(n = 10,x = 256) == 265\n assert candidate(n = 1,x = 8191) == 8191\n assert candidate(n = 1,x = 1048575) == 1048575\n assert candidate(n = 30,x = 8191) == 245759\n assert candidate(n = 4,x = 17) == 23\n assert candidate(n = 5,x = 10) == 26\n assert candidate(n = 30,x = 512) == 541\n assert candidate(n = 15,x = 7) == 119\n assert candidate(n = 9,x = 255) == 2303\n"}, "metadata": {"canonical_parameter_names": ["n", "x"], "leetcode_dataset_entry_point": "Solution().minEnd", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "long long minEnd(int n, int x) {", "container": "Solution", "callable": "minEnd", "parameters": [{"name": "n", "type": "int"}, {"name": "x", "type": "int"}], "return_type": "long long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3134, "task_id": "find-the-median-of-the-uniqueness-array", "difficulty": "Hard", "problem_description": "You are given an integer array nums. The uniqueness array of nums is the sorted array that contains the number of distinct elements of all the subarrays of nums. In other words, it is a sorted array consisting of distinct(nums[i..j]), for all 0 <= i <= j < nums.length.\nHere, distinct(nums[i..j]) denotes the number of distinct elements in the subarray that starts at index i and ends at index j.\nReturn the median of the uniqueness array of nums.\nNote that the median of an array is defined as the middle element of the array when it is sorted in non-decreasing order. If there are two choices for a median, the smaller of the two values is taken.\n \nExample 1:\n\nInput: nums = [1,2,3]\nOutput: 1\nExplanation:\nThe uniqueness array of nums is [distinct(nums[0..0]), distinct(nums[1..1]), distinct(nums[2..2]), distinct(nums[0..1]), distinct(nums[1..2]), distinct(nums[0..2])] which is equal to [1, 1, 1, 2, 2, 3]. The uniqueness array has a median of 1. Therefore, the answer is 1.\n\nExample 2:\n\nInput: nums = [3,4,3,4,5]\nOutput: 2\nExplanation:\nThe uniqueness array of nums is [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3]. The uniqueness array has a median of 2. Therefore, the answer is 2.\n\nExample 3:\n\nInput: nums = [4,3,5,4]\nOutput: 2\nExplanation:\nThe uniqueness array of nums is [1, 1, 1, 1, 2, 2, 2, 3, 3, 3]. The uniqueness array has a median of 2. Therefore, the answer is 2.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996]) == 2\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 2\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4]) == 2\n assert candidate(nums = [1, 2, 3]) == 1\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 2\n assert candidate(nums = [1, 2, 3, 2, 1]) == 2\n assert candidate(nums = [10, 20, 30, 40, 50]) == 2\n assert candidate(nums = [4, 3, 5, 4]) == 2\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 4\n assert candidate(nums = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 4\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996]) == 2\n assert candidate(nums = [3, 4, 3, 4, 5]) == 2\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == 2\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 1\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 3\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 6\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == 5\n assert candidate(nums = [7, 8, 9, 10, 11, 12, 13, 14, 15]) == 3\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 4\n assert candidate(nums = [1, 1, 2, 1, 2, 2, 3, 1, 2, 3, 2, 3, 3, 4, 1, 2, 3, 4, 2, 3, 4, 3, 4, 4, 5, 1, 2, 3, 4, 5, 2, 3, 4, 5, 3, 4, 5, 4, 5, 5, 6]) == 4\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 9\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9]) == 3\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1, 2, 3, 4, 5]) == 1\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991]) == 4\n assert candidate(nums = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 4\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == 4\n assert candidate(nums = [1, 3, 2, 3, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1]) == 5\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4]) == 2\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == 3\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989, 99988, 99987, 99986, 99985, 99984, 99983, 99982, 99981, 99980]) == 7\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991]) == 4\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 2\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 4\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 4\n assert candidate(nums = [5, 1, 5, 1, 5, 1, 5, 1]) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [1, 2, 3, 2, 1, 4, 5, 4, 3, 2, 1, 6, 7, 6, 5, 4, 3, 2, 1]) == 5\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == 3\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 3\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 6\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5, 5, 5, 5]) == 2\n assert candidate(nums = [100, 200, 100, 200, 100, 200, 100, 200, 100, 200]) == 2\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10]) == 4\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995]) == 2\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 6\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1]) == 3\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 4\n assert candidate(nums = [100000, 100000, 100000, 99999, 99999, 99998, 99998, 99997, 99997, 99996]) == 2\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12, 11, 13, 12, 14, 13, 15, 14, 16, 15, 17, 16, 18, 17, 19, 18, 20]) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == 4\n assert candidate(nums = [1, 3, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 3, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 7\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 3, 2, 1, 5, 4, 3, 2, 1]) == 4\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == 2\n assert candidate(nums = [1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 6\n assert candidate(nums = [5, 4, 5, 4, 5, 4, 5, 4]) == 2\n assert candidate(nums = [1, 3, 2, 4, 5, 3, 2, 1, 5, 4, 3, 2, 1, 6, 7, 8, 9, 10]) == 5\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 2\n assert candidate(nums = [100000, 100000, 99999, 99999, 99998, 99998, 99997, 99997]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2]) == 5\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 10, 1, 2, 9, 3, 8, 4, 7, 5, 6]) == 6\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 7\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7]) == 3\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 3\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 4\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().medianOfUniquenessArray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int medianOfUniquenessArray(vector& nums) {", "container": "Solution", "callable": "medianOfUniquenessArray", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3136, "task_id": "valid-word", "difficulty": "Easy", "problem_description": "A word is considered valid if:\n\nIt contains a minimum of 3 characters.\nIt contains only digits (0-9), and English letters (uppercase and lowercase).\nIt includes at least one vowel.\nIt includes at least one consonant.\n\nYou are given a string word.\nReturn true if word is valid, otherwise, return false.\nNotes:\n\n'a', 'e', 'i', 'o', 'u', and their uppercases are vowels.\nA consonant is an English letter that is not a vowel.\n\n \nExample 1:\n\nInput: word = \"234Adas\"\nOutput: true\nExplanation:\nThis word satisfies the conditions.\n\nExample 2:\n\nInput: word = \"b3\"\nOutput: false\nExplanation:\nThe length of this word is fewer than 3, and does not have a vowel.\n\nExample 3:\n\nInput: word = \"a3$e\"\nOutput: false\nExplanation:\nThis word contains a '$' character and does not have a consonant.\n\n \nConstraints:\n\n1 <= word.length <= 20\nword consists of English uppercase and lowercase letters, digits, '@', '#', and '$'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word = \"234Adas\") == True\n assert candidate(word = \"b3\") == False\n assert candidate(word = \"a3$e\") == False\n"}, "metadata": {"canonical_parameter_names": ["word"], "leetcode_dataset_entry_point": "Solution().isValid", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool isValid(string word) {", "container": "Solution", "callable": "isValid", "parameters": [{"name": "word", "type": "string"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3137, "task_id": "minimum-number-of-operations-to-make-word-k-periodic", "difficulty": "Medium", "problem_description": "You are given a string word of size n, and an integer k such that k divides n.\nIn one operation, you can pick any two indices i and j, that are divisible by k, then replace the substring of length k starting at i with the substring of length k starting at j. That is, replace the substring word[i..i + k - 1] with the substring word[j..j + k - 1].\nReturn the minimum number of operations required to make word k-periodic.\nWe say that word is k-periodic if there is some string s of length k such that word can be obtained by concatenating s an arbitrary number of times. For example, if word == “ababab”, then word is 2-periodic for s = \"ab\".\n \nExample 1:\n\nInput: word = \"leetcodeleet\", k = 4\nOutput: 1\nExplanation:\nWe can obtain a 4-periodic string by picking i = 4 and j = 0. After this operation, word becomes equal to \"leetleetleet\".\n\nExample 2:\n\nInput: word = \"leetcoleet\", k = 2\nOutput: 3\nExplanation:\nWe can obtain a 2-periodic string by applying the operations in the table below.\n\n\n\ni\nj\nword\n\n\n0\n2\netetcoleet\n\n\n4\n0\netetetleet\n\n\n6\n0\netetetetet\n\n\n\n\n\n \n\n \nConstraints:\n\n1 <= n == word.length <= 105\n1 <= k <= word.length\nk divides word.length.\nword consists only of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word = \"xyzxyzxyzxyzxyzxyz\",k = 3) == 0\n assert candidate(word = \"xyzxyzxyzxyz\",k = 3) == 0\n assert candidate(word = \"abcdefghijabcdefghij\",k = 5) == 2\n assert candidate(word = \"abcabcabc\",k = 3) == 0\n assert candidate(word = \"aaaaaaa\",k = 1) == 0\n assert candidate(word = \"aaaa\",k = 1) == 0\n assert candidate(word = \"xyzxyzxyzxyzxyzxyz\",k = 6) == 0\n assert candidate(word = \"abcdabcdabcd\",k = 4) == 0\n assert candidate(word = \"mnopqrsmnopqrsmnopqrs\",k = 7) == 0\n assert candidate(word = \"leetcodeleet\",k = 4) == 1\n assert candidate(word = \"abababab\",k = 2) == 0\n assert candidate(word = \"zzzzzzzzzzzz\",k = 6) == 0\n assert candidate(word = \"abcdefabcdefabcdef\",k = 3) == 3\n assert candidate(word = \"leetcoleet\",k = 2) == 3\n assert candidate(word = \"abcabcabcabc\",k = 3) == 0\n assert candidate(word = \"abcdabcdabcdabcd\",k = 4) == 0\n assert candidate(word = \"abababababab\",k = 2) == 0\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 16) == 0\n assert candidate(word = \"aaaabbbbccccddddeeeeffff\",k = 4) == 5\n assert candidate(word = \"hellohellohellohellohellohellohellohello\",k = 5) == 0\n assert candidate(word = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\",k = 4) == 0\n assert candidate(word = \"qwertyqwertyqwertyqwertyqwertyqwerty\",k = 5) == 5\n assert candidate(word = \"abcdefabcdefabcdefabcdef\",k = 6) == 0\n assert candidate(word = \"abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef\",k = 6) == 0\n assert candidate(word = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\",k = 4) == 0\n assert candidate(word = \"abcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefgh\",k = 8) == 0\n assert candidate(word = \"mnopqrstuqponmlkjihgfedcbamnopqrstuqponmlkjihgfedcba\",k = 10) == 4\n assert candidate(word = \"abcdefgabcdefgabcdefgabcdefgabcdefg\",k = 7) == 0\n assert candidate(word = \"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\",k = 10) == 0\n assert candidate(word = \"mnopmnopmnopmnopmnopmnopmnopmnopmnopmnopmnopmnopmnopmnopmnopmnopmnopmnopmnopmnopmnopmnopmnopmnopmnopmnopmnopmnopmnopmnopmnopmnopmnopmnop\",k = 10) == 6\n assert candidate(word = \"qwertyuiopqwertyuiopqwertyuiopqwertyuiopqwertyuiop\",k = 10) == 0\n assert candidate(word = \"abcdefghabcdefghabcdefgh\",k = 8) == 0\n assert candidate(word = \"racecaracecaracecaracecaracecaracecaracecaracecaracecaracecaracecaracecaracecaracecaracecaracecar\",k = 7) == 10\n assert candidate(word = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 2) == 25\n assert candidate(word = \"mnopqrsmnopqrsmnopqrsmnopqrs\",k = 10) == 1\n assert candidate(word = \"aaaaaaaaaabbbbbbbbbbcccccccccc\",k = 9) == 2\n assert candidate(word = \"qwertyuiopasdfghjklzxcvbnm\",k = 1) == 25\n assert candidate(word = \"qwertyuiopqwertyuiopqwertyuiopqwertyuiop\",k = 12) == 2\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",k = 26) == 0\n assert candidate(word = \"abacabadabacabadabacabadabacaba\",k = 3) == 7\n assert candidate(word = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\",k = 3) == 0\n assert candidate(word = \"racecaracecaracecaracecaracecar\",k = 7) == 3\n assert candidate(word = \"aabbccddeeaabbccddee\",k = 5) == 2\n assert candidate(word = \"zyxwvutrsrqponmlkjihgfedcba\",k = 5) == 4\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 6) == 0\n assert candidate(word = \"abcdefabcdefabcdefabcdefabcdefabcdef\",k = 9) == 2\n assert candidate(word = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\",k = 3) == 0\n assert candidate(word = \"mnopqrstmnopqrstmnopqrstmnopqrst\",k = 10) == 2\n assert candidate(word = \"abcdefghijklmnopqrstabcdefghijklmnopqrst\",k = 5) == 6\n assert candidate(word = \"mnopmnopmnopmnopmnopmnopmnopmnop\",k = 8) == 0\n assert candidate(word = \"abracadabraabracadabraabracadabra\",k = 9) == 2\n assert candidate(word = \"mnopqrsmnopqrsmnopqrsmnopqrsmnopqrs\",k = 7) == 0\n assert candidate(word = \"abacabadabacabadabacaba\",k = 5) == 3\n assert candidate(word = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 20) == 3\n assert candidate(word = \"xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz\",k = 9) == 0\n assert candidate(word = \"abcdefabcdefabcdefabcdefabcdefabcdef\",k = 3) == 6\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 12) == 0\n assert candidate(word = \"abcabcabcabcabcabcabcabcabcabcabcabc\",k = 9) == 0\n assert candidate(word = \"xyzxyzxyzxyzxyzxyzxyzxyz\",k = 3) == 0\n assert candidate(word = \"mississippimississippimississippimississippi\",k = 4) == 9\n assert candidate(word = \"aaaaabbbbbcccccddddd\",k = 5) == 3\n assert candidate(word = \"abcabcabcabcabcabc\",k = 3) == 0\n assert candidate(word = \"aaaaaabbbbccccddddeeeeffff\",k = 4) == 5\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 7) == 0\n assert candidate(word = \"thisisaverylongstringthatrepeatseveryfivethis\",k = 5) == 8\n assert candidate(word = \"mississippiissippimississippi\",k = 4) == 6\n assert candidate(word = \"abacabadabacabad\",k = 4) == 2\n assert candidate(word = \"aabbccddeeffgghhaabbccddeeffgghh\",k = 6) == 4\n assert candidate(word = \"aabbccddeeffaabbccddeeffaabbccddeeff\",k = 6) == 3\n assert candidate(word = \"aabbccddeeffaabbccddeeff\",k = 6) == 2\n assert candidate(word = \"qwertyuiopqwertyuiopqwertyuiop\",k = 12) == 1\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 5) == 0\n assert candidate(word = \"qwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnm\",k = 10) == 4\n assert candidate(word = \"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\",k = 10) == 0\n assert candidate(word = \"abcdefghijabcdefghijabcdefghijabcdefghij\",k = 10) == 0\n assert candidate(word = \"qqrqqqrqqqrqqqrqqqrqqqrqqqr\",k = 3) == 6\n assert candidate(word = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 10) == 5\n assert candidate(word = \"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\",k = 15) == 1\n assert candidate(word = \"baaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaa\",k = 10) == 1\n assert candidate(word = \"mississippiissippiissippiissipp\",k = 4) == 6\n assert candidate(word = \"mississippimississippimississippimississippi\",k = 11) == 0\n assert candidate(word = \"12345678901234567890123456789012345678901234567890\",k = 10) == 0\n assert candidate(word = \"aabbccddaabbccddaabbccdd\",k = 4) == 3\n assert candidate(word = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\",k = 3) == 0\n assert candidate(word = \"abcabcabcabcabcabcabcabcabcabc\",k = 3) == 0\n assert candidate(word = \"qwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwertyqwerty\",k = 6) == 0\n assert candidate(word = \"abababababababababababababababab\",k = 2) == 0\n assert candidate(word = \"mnopqrstmnopqrstmnopqrstmnopqrst\",k = 8) == 0\n assert candidate(word = \"zyxwvutrsrqponmlkjihgfedcbazyxwvut\",k = 5) == 5\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 26) == 0\n assert candidate(word = \"zyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyx\",k = 3) == 0\n assert candidate(word = \"mnopqrstmnopqrstmnopqrst\",k = 10) == 1\n assert candidate(word = \"aaaaabaaaabaaaabaaaabaaaabaaaabaaaab\",k = 5) == 1\n assert candidate(word = \"lkjhlkjhlkjhlkjhlkjhlkjhlkjhlkjhlkjhlkjhlkjhlkjhlkjhlkjhlkjhlkjh\",k = 11) == 3\n assert candidate(word = \"zzzzyyyxxxyyyzzzzxxxxyyyy\",k = 5) == 4\n assert candidate(word = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",k = 5) == 0\n assert candidate(word = \"abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef\",k = 7) == 5\n assert candidate(word = \"aaaaabbbbbccccddddeeeeffffgggghhhh\",k = 4) == 7\n assert candidate(word = \"xyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy\",k = 11) == 2\n assert candidate(word = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",k = 12) == 0\n assert candidate(word = \"qwertyuiopqwertyuiopqwertyuiopqwertyuiop\",k = 10) == 0\n assert candidate(word = \"abcdefabcdefabcdefabcdefabcdefabcdef\",k = 6) == 0\n assert candidate(word = \"ababababababababababababababab\",k = 2) == 0\n assert candidate(word = \"hellohellohellohellohellohellohellohellohellohello\",k = 5) == 0\n assert candidate(word = \"abababababababababababababababababababab\",k = 4) == 0\n"}, "metadata": {"canonical_parameter_names": ["word", "k"], "leetcode_dataset_entry_point": "Solution().minimumOperationsToMakeKPeriodic", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumOperationsToMakeKPeriodic(string word, int k) {", "container": "Solution", "callable": "minimumOperationsToMakeKPeriodic", "parameters": [{"name": "word", "type": "string"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3138, "task_id": "minimum-length-of-anagram-concatenation", "difficulty": "Medium", "problem_description": "You are given a string s, which is known to be a concatenation of anagrams of some string t.\nReturn the minimum possible length of the string t.\nAn anagram is formed by rearranging the letters of a string. For example, \"aab\", \"aba\", and, \"baa\" are anagrams of \"aab\".\n \nExample 1:\n\nInput: s = \"abba\"\nOutput: 2\nExplanation:\nOne possible string t could be \"ba\".\n\nExample 2:\n\nInput: s = \"cdef\"\nOutput: 4\nExplanation:\nOne possible string t could be \"cdef\", notice that t can be equal to s.\n\nExample 2:\n\nInput: s = \"abcbcacabbaccba\"\nOutput: 3\n\n \nConstraints:\n\n1 <= s.length <= 105\ns consist only of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"zzzzzzzzz\") == 1\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 26\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 1\n assert candidate(s = \"abababab\") == 2\n assert candidate(s = \"a\") == 1\n assert candidate(s = \"abcabcabcabc\") == 3\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\") == 1\n assert candidate(s = \"aa\") == 1\n assert candidate(s = \"xyzxyzxyz\") == 3\n assert candidate(s = \"abba\") == 2\n assert candidate(s = \"abcdeedcba\") == 5\n assert candidate(s = \"abcdabcdabcd\") == 4\n assert candidate(s = \"abacabadabacabad\") == 8\n assert candidate(s = \"aabbccddeeffgghh\") == 16\n assert candidate(s = \"aaaa\") == 1\n assert candidate(s = \"abcbcacabbaccba\") == 3\n assert candidate(s = \"aabbcc\") == 6\n assert candidate(s = \"cdef\") == 4\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 52\n assert candidate(s = \"xyzxyzxyzxyz\") == 3\n assert candidate(s = \"abcdabcdabcdabcd\") == 4\n assert candidate(s = \"abcdefg\") == 7\n assert candidate(s = \"thisisaverylongstringthatwillrequireauniquestringtobeformedanditshouldbechecked\") == 79\n assert candidate(s = \"abacabadabacabadabacabadabacaba\") == 31\n assert candidate(s = \"abracadabrabracadabrabracadabrabracadabrabracadabraca\") == 53\n assert candidate(s = \"ninnininnininnininininininininininininininininininininininininin\") == 64\n assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcdefghij\") == 10\n assert candidate(s = \"mnopqrstmnopqrstmnopqrstmnopqrstmnopqrstmnopqrstmnopqrst\") == 8\n assert candidate(s = \"abcabcabcabcaa\") == 7\n assert candidate(s = \"tomatotomatotomatotomatotomatotomatotomatotomatotomato\") == 6\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 1\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\") == 3\n assert candidate(s = \"xyxxyxyxxyxxyxyxxyxxyxyxxyxxyxyxxyxxyxyxxyxxyxyxxyxxyxyxxyxxyxyxxyxxyxyx\") == 8\n assert candidate(s = \"mamamamamamamamamamamamamamamamamamamamamama\") == 2\n assert candidate(s = \"abracadabraacarbadrabracadabraacarbadrabracadabraacarbadrabracadabra\") == 68\n assert candidate(s = \"racecarracecarracecar\") == 7\n assert candidate(s = \"shortyetuniquestringwithanagramstestcase\") == 40\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnm\") == 26\n assert candidate(s = \"lollipoplollipoplollipoplollipoplollipoplollipoplollipoplollipop\") == 8\n assert candidate(s = \"abcdefgabcdefgabcdefgabcdefgabcdefgabcdefg\") == 7\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 4\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcd\") == 4\n assert candidate(s = \"mnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 66\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzabcdef\") == 58\n assert candidate(s = \"abcdefgabcdefgabcdefgabcdefg\") == 7\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 1\n assert candidate(s = \"mnopqrstmnopqrstmnopqrstmnopqrstmnopqrstmnopqrstmnopqrstmnopqrstmnopqrstu\") == 73\n assert candidate(s = \"ppppeeeaaaallllllaaaabbbbcccdddd\") == 32\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 26\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyza\") == 27\n assert candidate(s = \"abcdefghijabcdefghijabcdefghij\") == 10\n assert candidate(s = \"zyxzyxzyxzyxzyx\") == 3\n assert candidate(s = \"elephantelephantelephantelephantelephantelephant\") == 8\n assert candidate(s = \"abcdefabcdefabcdefabcdefabcdefabcdefabcdef\") == 6\n assert candidate(s = \"xyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyz\") == 63\n assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\") == 10\n assert candidate(s = \"aaabbbcccdddaa\") == 14\n assert candidate(s = \"mmnnooppqqrrssttuuvvwwxxyyzz\") == 28\n assert candidate(s = \"aabbaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 56\n assert candidate(s = \"qqwweerrttyyuuiiooppaassddffgg\") == 30\n assert candidate(s = \"abcabcabcabccbaabccbaabc\") == 3\n assert candidate(s = \"xyzxyzxyzxyzxyz\") == 3\n assert candidate(s = \"abcdefghijlmnopqrstuvwxyzmnopqrstuvwxyzabcdefghij\") == 49\n assert candidate(s = \"aaaaabbbbccccddddeeeeeffffffggggghhhhiiiiijjjjjkkkkklllllmmmmmnnnnnooooo\") == 72\n assert candidate(s = \"mississippimississippi\") == 11\n assert candidate(s = \"mnopqrstmnopqrstmnopqrstmnopqrst\") == 8\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 4\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabc\") == 3\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 1\n assert candidate(s = \"abcdefghijkabcdefghijkabcdefghijkabcdefghijkabcdefghijkabcdefghijkabcdefghijkabcdefghijk\") == 11\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 1\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 1\n assert candidate(s = \"bananaananabanana\") == 17\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().minAnagramLength", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minAnagramLength(string s) {", "container": "Solution", "callable": "minAnagramLength", "parameters": [{"name": "s", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3139, "task_id": "minimum-cost-to-equalize-array", "difficulty": "Hard", "problem_description": "You are given an integer array nums and two integers cost1 and cost2. You are allowed to perform either of the following operations any number of times:\n\nChoose an index i from nums and increase nums[i] by 1 for a cost of cost1.\nChoose two different indices i, j, from nums and increase nums[i] and nums[j] by 1 for a cost of cost2.\n\nReturn the minimum cost required to make all elements in the array equal. \nSince the answer may be very large, return it modulo 109 + 7.\n \nExample 1:\n\nInput: nums = [4,1], cost1 = 5, cost2 = 2\nOutput: 15\nExplanation: \nThe following operations can be performed to make the values equal:\n\nIncrease nums[1] by 1 for a cost of 5. nums becomes [4,2].\nIncrease nums[1] by 1 for a cost of 5. nums becomes [4,3].\nIncrease nums[1] by 1 for a cost of 5. nums becomes [4,4].\n\nThe total cost is 15.\n\nExample 2:\n\nInput: nums = [2,3,3,3,5], cost1 = 2, cost2 = 1\nOutput: 6\nExplanation: \nThe following operations can be performed to make the values equal:\n\nIncrease nums[0] and nums[1] by 1 for a cost of 1. nums becomes [3,4,3,3,5].\nIncrease nums[0] and nums[2] by 1 for a cost of 1. nums becomes [4,4,4,3,5].\nIncrease nums[0] and nums[3] by 1 for a cost of 1. nums becomes [5,4,4,4,5].\nIncrease nums[1] and nums[2] by 1 for a cost of 1. nums becomes [5,5,5,4,5].\nIncrease nums[3] by 1 for a cost of 2. nums becomes [5,5,5,5,5].\n\nThe total cost is 6.\n\nExample 3:\n\nInput: nums = [3,5,3], cost1 = 1, cost2 = 3\nOutput: 4\nExplanation:\nThe following operations can be performed to make the values equal:\n\nIncrease nums[0] by 1 for a cost of 1. nums becomes [4,5,3].\nIncrease nums[0] by 1 for a cost of 1. nums becomes [5,5,3].\nIncrease nums[2] by 1 for a cost of 1. nums becomes [5,5,4].\nIncrease nums[2] by 1 for a cost of 1. nums becomes [5,5,5].\n\nThe total cost is 4.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 106\n1 <= cost1 <= 106\n1 <= cost2 <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [4, 1],cost1 = 5,cost2 = 2) == 15\n assert candidate(nums = [1, 3, 5, 7, 9],cost1 = 2,cost2 = 4) == 40\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],cost1 = 1,cost2 = 2) == 0\n assert candidate(nums = [10, 10, 10, 10],cost1 = 100,cost2 = 50) == 0\n assert candidate(nums = [2, 3, 3, 3, 5],cost1 = 2,cost2 = 1) == 6\n assert candidate(nums = [1, 2, 3, 4, 5],cost1 = 1,cost2 = 2) == 10\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],cost1 = 7,cost2 = 3) == 0\n assert candidate(nums = [10, 10, 10, 10, 10],cost1 = 100,cost2 = 50) == 0\n assert candidate(nums = [1, 1, 1, 1],cost1 = 10,cost2 = 5) == 0\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],cost1 = 3,cost2 = 2) == 10\n assert candidate(nums = [1, 2, 3, 4, 5],cost1 = 10,cost2 = 5) == 25\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],cost1 = 1000000,cost2 = 500000) == 0\n assert candidate(nums = [1, 1000000],cost1 = 1,cost2 = 1000000) == 999999\n assert candidate(nums = [1, 1000000],cost1 = 1,cost2 = 1) == 999999\n assert candidate(nums = [1, 1000000],cost1 = 1,cost2 = 2) == 999999\n assert candidate(nums = [1000000, 1000000, 1000000],cost1 = 1000000,cost2 = 500000) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],cost1 = 5,cost2 = 2) == 49\n assert candidate(nums = [5, 5, 5, 5, 5],cost1 = 1,cost2 = 1) == 0\n assert candidate(nums = [1, 2],cost1 = 2,cost2 = 1) == 2\n assert candidate(nums = [100000, 100000, 100000],cost1 = 1,cost2 = 1) == 0\n assert candidate(nums = [3, 5, 3],cost1 = 1,cost2 = 3) == 4\n assert candidate(nums = [1, 2, 3],cost1 = 3,cost2 = 2) == 5\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5],cost1 = 3,cost2 = 2) == 30\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],cost1 = 100000,cost2 = 50000) == 10950000\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2],cost1 = 1,cost2 = 3) == 9\n assert candidate(nums = [1, 3, 3, 3, 5, 5, 7, 7, 9, 9, 11, 11, 13, 13, 15],cost1 = 1,cost2 = 1) == 55\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000],cost1 = 1,cost2 = 1) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],cost1 = 1,cost2 = 2) == 72\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],cost1 = 7,cost2 = 10) == 527\n assert candidate(nums = [1, 3, 5, 7, 9],cost1 = 3,cost2 = 5) == 50\n assert candidate(nums = [999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990, 999989, 999988, 999987, 999986, 999985],cost1 = 1000,cost2 = 500) == 27000\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000],cost1 = 123456,cost2 = 654321) == 18675295\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],cost1 = 10,cost2 = 5) == 1125\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],cost1 = 7,cost2 = 3) == 135\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],cost1 = 1,cost2 = 2) == 0\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],cost1 = 3,cost2 = 5) == 50\n assert candidate(nums = [1, 3, 5, 7, 9],cost1 = 2,cost2 = 3) == 30\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],cost1 = 1000000,cost2 = 500000) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],cost1 = 100000,cost2 = 50000) == 1200000\n assert candidate(nums = [1, 5, 9, 13, 17],cost1 = 3,cost2 = 5) == 100\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5],cost1 = 1,cost2 = 3) == 40\n assert candidate(nums = [100, 200, 300, 400, 500],cost1 = 10,cost2 = 7) == 3500\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],cost1 = 2,cost2 = 3) == 135\n assert candidate(nums = [5, 2, 3, 7, 1],cost1 = 3,cost2 = 5) == 43\n assert candidate(nums = [500000, 500001, 500002, 500003, 500004, 500005, 500006, 500007, 500008, 500009],cost1 = 1000000,cost2 = 2000000) == 45000000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],cost1 = 1000,cost2 = 500) == 12000\n assert candidate(nums = [1, 3, 5, 7, 9],cost1 = 7,cost2 = 3) == 30\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000],cost1 = 1000000,cost2 = 500000) == 0\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996],cost1 = 1,cost2 = 1) == 5\n assert candidate(nums = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],cost1 = 10,cost2 = 5) == 1170\n assert candidate(nums = [100, 200, 300, 400, 500],cost1 = 10,cost2 = 20) == 10000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],cost1 = 2,cost2 = 4) == 210\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],cost1 = 5,cost2 = 3) == 285\n assert candidate(nums = [5, 4, 3, 2, 1],cost1 = 5,cost2 = 10) == 50\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],cost1 = 50,cost2 = 20) == 45000\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],cost1 = 100,cost2 = 50) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],cost1 = 100,cost2 = 200) == 4500\n assert candidate(nums = [1000000, 500000, 250000, 125000, 62500, 31250, 15625],cost1 = 2,cost2 = 4) == 10031250\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991],cost1 = 1000,cost2 = 500) == 12000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],cost1 = 20,cost2 = 10) == 950\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],cost1 = 7,cost2 = 11) == 110\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],cost1 = 1000000,cost2 = 500000) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],cost1 = 5,cost2 = 10) == 5250\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 4, 5, 6],cost1 = 5,cost2 = 2) == 32\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],cost1 = 10,cost2 = 20) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],cost1 = 500000,cost2 = 1000000) == 52500000\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],cost1 = 2,cost2 = 1) == 105\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],cost1 = 2,cost2 = 1) == 10\n assert candidate(nums = [5, 3, 1, 2, 4],cost1 = 7,cost2 = 3) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],cost1 = 10,cost2 = 20) == 1900\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],cost1 = 3,cost2 = 5) == 113\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3],cost1 = 4,cost2 = 8) == 64\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],cost1 = 1,cost2 = 2) == 90\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],cost1 = 50,cost2 = 25) == 600\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996],cost1 = 1000,cost2 = 500) == 2500\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],cost1 = 2,cost2 = 4) == 20\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],cost1 = 1,cost2 = 1) == 45\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],cost1 = 10,cost2 = 5) == 120\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],cost1 = 1,cost2 = 2) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],cost1 = 50,cost2 = 25) == 5625\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],cost1 = 3,cost2 = 5) == 180\n assert candidate(nums = [1, 3, 5, 7, 9],cost1 = 2,cost2 = 4) == 40\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],cost1 = 1000,cost2 = 500) == 112500\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],cost1 = 1,cost2 = 2) == 10\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],cost1 = 1,cost2 = 2) == 0\n assert candidate(nums = [100, 200, 300, 400, 500],cost1 = 1000,cost2 = 500) == 250000\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991],cost1 = 1000000,cost2 = 500000) == 12000000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],cost1 = 4,cost2 = 8) == 760\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],cost1 = 1,cost2 = 1) == 225\n assert candidate(nums = [999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990],cost1 = 10,cost2 = 5) == 120\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],cost1 = 7,cost2 = 6) == 60\n assert candidate(nums = [1, 1000000, 1, 1000000, 1, 1000000],cost1 = 500000,cost2 = 250000) == 999997382\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5],cost1 = 7,cost2 = 3) == 45\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],cost1 = 1,cost2 = 2) == 0\n assert candidate(nums = [100, 200, 300, 400, 500],cost1 = 10,cost2 = 15) == 7500\n assert candidate(nums = [1, 3, 5, 7, 9],cost1 = 1000000,cost2 = 500000) == 5000000\n assert candidate(nums = [500000, 500000, 500000, 500000, 500000, 500000, 500000, 500000, 500000, 500000, 500000, 500000, 500000, 500000, 500000],cost1 = 1000,cost2 = 500) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],cost1 = 1000,cost2 = 500) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],cost1 = 10,cost2 = 3) == 30\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],cost1 = 5,cost2 = 2) == 450\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15],cost1 = 1,cost2 = 1) == 105\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000],cost1 = 1,cost2 = 1) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4],cost1 = 10,cost2 = 20) == 300\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],cost1 = 1,cost2 = 2) == 45\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],cost1 = 100,cost2 = 50) == 30700\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],cost1 = 2,cost2 = 1) == 525\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],cost1 = 10,cost2 = 5) == 50\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991],cost1 = 1,cost2 = 2) == 45\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],cost1 = 5,cost2 = 2) == 49\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],cost1 = 1000000,cost2 = 500000) == 27000000\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10],cost1 = 6,cost2 = 3) == 207\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],cost1 = 1,cost2 = 2) == 0\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5],cost1 = 3,cost2 = 5) == 100\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],cost1 = 2,cost2 = 4) == 0\n assert candidate(nums = [100000, 200000, 300000, 400000, 500000],cost1 = 10000,cost2 = 5000) == 499999986\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000],cost1 = 100,cost2 = 50) == 0\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],cost1 = 1,cost2 = 1) == 83\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],cost1 = 10,cost2 = 5) == 2625\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3],cost1 = 1000,cost2 = 500) == 4500\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],cost1 = 1,cost2 = 2) == 0\n assert candidate(nums = [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000],cost1 = 100,cost2 = 50) == 112500000\n assert candidate(nums = [7, 7, 8, 8, 8, 9, 9, 9, 9, 9],cost1 = 5,cost2 = 3) == 14\n"}, "metadata": {"canonical_parameter_names": ["nums", "cost1", "cost2"], "leetcode_dataset_entry_point": "Solution().minCostToEqualizeArray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minCostToEqualizeArray(vector& nums, int cost1, int cost2) {", "container": "Solution", "callable": "minCostToEqualizeArray", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "cost1", "type": "int"}, {"name": "cost2", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3142, "task_id": "check-if-grid-satisfies-conditions", "difficulty": "Easy", "problem_description": "You are given a 2D matrix grid of size m x n. You need to check if each cell grid[i][j] is:\n\nEqual to the cell below it, i.e. grid[i][j] == grid[i + 1][j] (if it exists).\nDifferent from the cell to its right, i.e. grid[i][j] != grid[i][j + 1] (if it exists).\n\nReturn true if all the cells satisfy these conditions, otherwise, return false.\n \nExample 1:\n\nInput: grid = [[1,0,2],[1,0,2]]\nOutput: true\nExplanation:\n\nAll the cells in the grid satisfy the conditions.\n\nExample 2:\n\nInput: grid = [[1,1,1],[0,0,0]]\nOutput: false\nExplanation:\n\nAll cells in the first row are equal.\n\nExample 3:\n\nInput: grid = [[1],[2],[3]]\nOutput: false\nExplanation:\n\nCells in the first column have different values.\n\n \nConstraints:\n\n1 <= n, m <= 10\n0 <= grid[i][j] <= 9\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1], [2], [3]]) == False\n assert candidate(grid = [[5, 4, 3], [5, 4, 3], [5, 4, 3]]) == True\n assert candidate(grid = [[5, 4, 3, 2, 1], [5, 4, 3, 2, 1]]) == True\n assert candidate(grid = [[5, 4], [5, 3]]) == False\n assert candidate(grid = [[1, 1, 1], [0, 0, 0]]) == False\n assert candidate(grid = [[9, 8], [9, 8], [9, 8], [9, 8]]) == True\n assert candidate(grid = [[0, 1, 2, 3], [0, 1, 2, 3], [0, 1, 2, 3]]) == True\n assert candidate(grid = [[6]]) == True\n assert candidate(grid = [[8, 8], [8, 8]]) == False\n assert candidate(grid = [[7]]) == True\n assert candidate(grid = [[7, 8, 9], [7, 8, 9], [7, 8, 9]]) == True\n assert candidate(grid = [[9, 8, 7], [9, 8, 7], [9, 8, 7], [9, 8, 7]]) == True\n assert candidate(grid = [[1, 2], [1, 2], [1, 2]]) == True\n assert candidate(grid = [[0, 0], [1, 1], [2, 2]]) == False\n assert candidate(grid = [[0, 1, 0], [0, 1, 0]]) == True\n assert candidate(grid = [[6], [6]]) == True\n assert candidate(grid = [[1, 1], [1, 1], [1, 1]]) == False\n assert candidate(grid = [[4, 4], [5, 5], [4, 4]]) == False\n assert candidate(grid = [[9, 8], [9, 8], [9, 7]]) == False\n assert candidate(grid = [[1, 2], [3, 4], [1, 2]]) == False\n assert candidate(grid = [[0, 1, 2, 3], [0, 1, 2, 3]]) == True\n assert candidate(grid = [[1, 0, 2], [1, 0, 2]]) == True\n assert candidate(grid = [[6, 5], [6, 4], [6, 3]]) == False\n assert candidate(grid = [[1, 2], [1, 3]]) == False\n assert candidate(grid = [[0, 1, 2], [0, 1, 2], [0, 1, 3]]) == False\n assert candidate(grid = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == False\n assert candidate(grid = [[7, 8, 9, 0], [7, 8, 9, 0], [7, 8, 9, 0], [7, 8, 9, 0]]) == True\n assert candidate(grid = [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]]) == False\n assert candidate(grid = [[1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]]) == True\n assert candidate(grid = [[1, 0, 1], [0, 1, 0], [1, 0, 1]]) == False\n assert candidate(grid = [[4, 5, 6, 7, 8], [4, 5, 6, 7, 9]]) == False\n assert candidate(grid = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]) == True\n assert candidate(grid = [[2, 3, 2], [2, 3, 2], [2, 3, 2]]) == True\n assert candidate(grid = [[0, 0, 0, 0, 0], [1, 1, 1, 1, 1]]) == False\n assert candidate(grid = [[1, 0, 1, 0, 1], [1, 0, 1, 0, 1]]) == True\n assert candidate(grid = [[5, 6, 7], [6, 7, 8], [7, 8, 9]]) == False\n assert candidate(grid = [[1, 0, 1, 0, 1], [1, 0, 1, 0, 1], [1, 0, 1, 0, 1]]) == True\n assert candidate(grid = [[9, 9, 9, 9], [8, 8, 8, 8], [7, 7, 7, 7], [6, 6, 6, 6]]) == False\n assert candidate(grid = [[4, 5, 6, 7], [4, 5, 6, 7], [4, 5, 6, 7], [4, 5, 6, 7]]) == True\n assert candidate(grid = [[5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5]]) == False\n assert candidate(grid = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == False\n assert candidate(grid = [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5]]) == True\n assert candidate(grid = [[1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]]) == True\n assert candidate(grid = [[1, 2, 1, 2], [1, 2, 1, 2], [1, 2, 1, 2]]) == True\n assert candidate(grid = [[9, 0, 1, 2], [9, 0, 1, 2], [9, 0, 1, 2]]) == True\n assert candidate(grid = [[7, 6, 5, 4, 3, 2, 1], [7, 6, 5, 4, 3, 2, 1]]) == True\n assert candidate(grid = [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5]]) == True\n assert candidate(grid = [[1, 0], [0, 1], [1, 0], [0, 1]]) == False\n assert candidate(grid = [[1, 0, 1], [1, 0, 1], [1, 0, 1]]) == True\n assert candidate(grid = [[1, 0, 2, 3], [1, 0, 2, 3], [1, 0, 2, 3], [1, 0, 2, 3]]) == True\n assert candidate(grid = [[0, 1, 2, 3, 4], [0, 1, 2, 3, 4], [0, 1, 2, 3, 4]]) == True\n assert candidate(grid = [[0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1]]) == True\n assert candidate(grid = [[4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5]]) == True\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == False\n assert candidate(grid = [[1, 2, 1, 2], [3, 4, 3, 4], [1, 2, 1, 2], [3, 4, 3, 4]]) == False\n assert candidate(grid = [[1, 0, 1], [1, 0, 1], [1, 0, 1]]) == True\n assert candidate(grid = [[3, 2, 3, 2, 3, 2, 3, 2, 3, 2], [3, 2, 3, 2, 3, 2, 3, 2, 3, 2], [3, 2, 3, 2, 3, 2, 3, 2, 3, 2], [3, 2, 3, 2, 3, 2, 3, 2, 3, 2]]) == True\n assert candidate(grid = [[5, 6, 7], [5, 6, 8], [5, 9, 7]]) == False\n assert candidate(grid = [[4, 5, 6], [4, 5, 6], [7, 8, 9]]) == False\n assert candidate(grid = [[1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0]]) == True\n assert candidate(grid = [[9, 0, 9, 0], [9, 0, 9, 0], [9, 0, 9, 0]]) == True\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]) == True\n assert candidate(grid = [[1, 2, 1, 2, 1, 2], [1, 2, 1, 2, 1, 2]]) == True\n assert candidate(grid = [[1, 1], [2, 2], [3, 3], [4, 4]]) == False\n assert candidate(grid = [[7, 8, 9], [7, 8, 9], [7, 8, 9], [7, 8, 9]]) == True\n assert candidate(grid = [[1, 0, 1, 0], [1, 0, 1, 0], [0, 1, 0, 1]]) == False\n assert candidate(grid = [[3, 2, 1], [2, 1, 0], [1, 0, 9], [0, 9, 8]]) == False\n assert candidate(grid = [[9, 8, 7], [6, 5, 4], [3, 2, 1]]) == False\n assert candidate(grid = [[0, 0, 0], [1, 1, 1], [0, 0, 0], [1, 1, 1]]) == False\n assert candidate(grid = [[1], [1], [1], [1], [1]]) == True\n assert candidate(grid = [[0, 1, 0, 1], [0, 1, 0, 1], [0, 1, 0, 1]]) == True\n assert candidate(grid = [[1, 1, 2, 2], [1, 1, 2, 2], [3, 3, 4, 4]]) == False\n assert candidate(grid = [[5, 6, 5, 6], [5, 6, 5, 6], [5, 6, 5, 6]]) == True\n assert candidate(grid = [[1, 0, 1, 0, 1], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [0, 1, 0, 1, 0]]) == False\n assert candidate(grid = [[7, 6, 5], [7, 8, 9], [7, 6, 5]]) == False\n assert candidate(grid = [[1, 2, 3], [1, 0, 2], [1, 1, 1]]) == False\n assert candidate(grid = [[9, 8, 7, 6, 5], [9, 8, 7, 6, 5], [9, 8, 7, 6, 5], [9, 8, 7, 6, 5]]) == True\n assert candidate(grid = [[0, 1, 0, 1], [0, 1, 0, 1], [1, 0, 1, 0]]) == False\n assert candidate(grid = [[3, 2, 1], [3, 2, 1], [3, 2, 1], [3, 2, 1], [3, 2, 1]]) == True\n assert candidate(grid = [[4, 5, 6], [7, 8, 9], [4, 5, 6]]) == False\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]) == True\n assert candidate(grid = [[9, 9, 9, 9], [8, 8, 8, 8], [7, 7, 7, 7]]) == False\n assert candidate(grid = [[3, 4, 5, 6, 7], [3, 4, 5, 6, 7], [3, 4, 5, 6, 7]]) == True\n assert candidate(grid = [[0, 1, 0, 1, 0], [0, 1, 0, 1, 0]]) == True\n assert candidate(grid = [[1, 2, 3], [1, 2, 3], [1, 2, 3]]) == True\n assert candidate(grid = [[1, 1, 2, 2, 3, 3], [1, 1, 2, 2, 3, 3]]) == False\n assert candidate(grid = [[9, 8, 7, 6], [9, 8, 7, 6], [9, 8, 7, 6]]) == True\n assert candidate(grid = [[3, 2, 1], [2, 1, 0], [1, 0, 3]]) == False\n assert candidate(grid = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5]]) == False\n assert candidate(grid = [[3, 2], [3, 2], [3, 2], [3, 2], [3, 2], [3, 2]]) == True\n assert candidate(grid = [[5, 5, 5, 5, 5], [5, 4, 4, 4, 4], [5, 4, 3, 3, 3], [5, 4, 3, 2, 2], [5, 4, 3, 2, 1]]) == False\n assert candidate(grid = [[1, 1, 0], [2, 2, 0], [3, 3, 0]]) == False\n assert candidate(grid = [[4, 5, 6], [4, 5, 6], [4, 5, 6], [4, 5, 6]]) == True\n assert candidate(grid = [[5, 3, 4, 4], [5, 6, 7, 8], [5, 9, 10, 11]]) == False\n assert candidate(grid = [[1, 0, 1, 0], [2, 1, 2, 1], [1, 0, 1, 0], [2, 1, 2, 1]]) == False\n assert candidate(grid = [[7, 8, 9], [7, 8, 9], [7, 8, 9], [7, 8, 9]]) == True\n assert candidate(grid = [[1, 2, 3, 4], [1, 2, 3, 4]]) == True\n assert candidate(grid = [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5]]) == True\n assert candidate(grid = [[9, 0, 9, 0], [9, 0, 9, 0], [9, 0, 9, 0]]) == True\n assert candidate(grid = [[0, 0, 0, 0], [1, 1, 1, 1], [2, 2, 2, 2]]) == False\n assert candidate(grid = [[5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5]]) == False\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [1, 2, 3]]) == False\n assert candidate(grid = [[3, 3, 3], [2, 2, 2], [1, 1, 1], [0, 0, 0]]) == False\n assert candidate(grid = [[5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5]]) == False\n assert candidate(grid = [[1, 2], [2, 1], [1, 2], [2, 1]]) == False\n assert candidate(grid = [[1, 2, 3], [1, 4, 5], [1, 6, 7], [1, 8, 9]]) == False\n assert candidate(grid = [[5, 5, 5, 5, 5], [4, 4, 4, 4, 4]]) == False\n assert candidate(grid = [[5, 6, 7], [5, 6, 7], [5, 6, 8]]) == False\n assert candidate(grid = [[1, 1, 2], [1, 2, 1], [2, 1, 2]]) == False\n assert candidate(grid = [[1, 2, 3, 4], [1, 5, 6, 7], [1, 8, 9, 0]]) == False\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 0], [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]]) == True\n assert candidate(grid = [[9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]]) == True\n assert candidate(grid = [[1, 2, 1, 2, 1, 2, 1, 2, 1, 2], [1, 2, 1, 2, 1, 2, 1, 2, 1, 2], [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]]) == True\n assert candidate(grid = [[5, 5, 5, 5], [6, 6, 6, 6], [7, 7, 7, 7]]) == False\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == False\n assert candidate(grid = [[1, 2, 3], [1, 2, 3], [4, 5, 6]]) == False\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().satisfiesConditions", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool satisfiesConditions(vector>& grid) {", "container": "Solution", "callable": "satisfiesConditions", "parameters": [{"name": "grid", "type": "vector>&"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3143, "task_id": "maximum-points-inside-the-square", "difficulty": "Medium", "problem_description": "You are given a 2D array points and a string s where, points[i] represents the coordinates of point i, and s[i] represents the tag of point i.\nA valid square is a square centered at the origin (0, 0), has edges parallel to the axes, and does not contain two points with the same tag.\nReturn the maximum number of points contained in a valid square.\nNote:\n\nA point is considered to be inside the square if it lies on or within the square's boundaries.\nThe side length of the square can be zero.\n\n \nExample 1:\n\n\nInput: points = [[2,2],[-1,-2],[-4,4],[-3,1],[3,-3]], s = \"abdca\"\nOutput: 2\nExplanation:\nThe square of side length 4 covers two points points[0] and points[1].\n\nExample 2:\n\n\nInput: points = [[1,1],[-2,-2],[-2,2]], s = \"abb\"\nOutput: 1\nExplanation:\nThe square of side length 2 covers one point, which is points[0].\n\nExample 3:\n\nInput: points = [[1,1],[-1,-1],[2,-2]], s = \"ccd\"\nOutput: 0\nExplanation:\nIt's impossible to make any valid squares centered at the origin such that it covers only one point among points[0] and points[1].\n\n \nConstraints:\n\n1 <= s.length, points.length <= 105\npoints[i].length == 2\n-109 <= points[i][0], points[i][1] <= 109\ns.length == points.length\npoints consists of distinct coordinates.\ns consists only of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(points = [[1, 1], [-1, -1], [2, -2]],s = \"ccd\") == 0\n assert candidate(points = [[0, 0], [1, 0], [-1, 0], [0, 1], [0, -1]],s = \"abcde\") == 5\n assert candidate(points = [[0, 1], [1, 0], [1, 1]],s = \"abc\") == 3\n assert candidate(points = [[10, 10], [-10, -10], [10, -10], [-10, 10]],s = \"abcd\") == 4\n assert candidate(points = [[0, 0], [0, 1], [1, 0], [1, 1]],s = \"abcd\") == 4\n assert candidate(points = [[1, 2], [2, 1], [3, 4], [4, 3]],s = \"abcd\") == 4\n assert candidate(points = [[3, 0], [-3, 0], [0, 3], [0, -3], [1, 1], [-1, -1]],s = \"abcdef\") == 6\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4]],s = \"abcd\") == 4\n assert candidate(points = [[0, 0], [1, 1], [2, 2]],s = \"abc\") == 3\n assert candidate(points = [[1, 2], [2, 1], [1, -2], [-2, 1], [-1, -2], [2, -1]],s = \"abcdef\") == 6\n assert candidate(points = [[0, 0], [1, 0], [0, 1], [-1, 0], [0, -1]],s = \"abcde\") == 5\n assert candidate(points = [[1, 2], [2, 1], [-1, -2], [-2, -1]],s = \"abcd\") == 4\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],s = \"abcde\") == 5\n assert candidate(points = [[1, 0], [0, 1], [-1, 0], [0, -1]],s = \"abcd\") == 4\n assert candidate(points = [[1, 1], [1, -1], [-1, 1], [-1, -1]],s = \"abcd\") == 4\n assert candidate(points = [[1, 1], [-2, -2], [-2, 2]],s = \"abb\") == 1\n assert candidate(points = [[0, 0], [1, 0], [0, 1]],s = \"abc\") == 3\n assert candidate(points = [[2, 2], [-1, -2], [-4, 4], [-3, 1], [3, -3]],s = \"abdca\") == 2\n assert candidate(points = [[5, 5], [5, -5], [-5, 5], [-5, -5]],s = \"abcd\") == 4\n assert candidate(points = [[5, 0], [0, 5], [-5, 0], [0, -5]],s = \"abcd\") == 4\n assert candidate(points = [[0, 0]],s = \"a\") == 1\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40]],s = \"abcd\") == 4\n assert candidate(points = [[0, 0], [1, 1], [-1, -1]],s = \"aaa\") == 1\n assert candidate(points = [[0, 0], [1, 1], [-1, -1], [2, 2], [-2, -2]],s = \"abcde\") == 5\n assert candidate(points = [[5, 5], [-5, -5], [0, 0]],s = \"aaa\") == 1\n assert candidate(points = [[1, 1], [2, 2], [3, 3]],s = \"abc\") == 3\n assert candidate(points = [[10, 0], [-10, 0], [0, 10], [0, -10]],s = \"abcd\") == 4\n assert candidate(points = [[-1, -1], [-2, -2], [-3, -3], [-4, -4]],s = \"abcd\") == 4\n assert candidate(points = [[5, 5], [-5, -5], [5, -5], [-5, 5]],s = \"abcd\") == 4\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3], [0, 0]],s = \"abcdefghij\") == 10\n assert candidate(points = [[10, 10], [10, -10], [-10, 10], [-10, -10], [20, 20], [20, -20], [-20, 20], [-20, -20], [30, 30], [30, -30], [-30, 30], [-30, -30]],s = \"abcdefghijklmno\") == 12\n assert candidate(points = [[0, 0], [1, 0], [0, 1], [-1, 0], [0, -1], [1, 1], [-1, -1], [2, 0], [0, 2], [-2, 0], [0, -2], [2, 1], [1, 2], [1, -1], [-1, 1], [-2, -1], [-1, -2], [1, -2], [-2, 1], [2, -1], [-1, 2]],s = \"abcdefghijklmnopqrstuvwxy\") == 21\n assert candidate(points = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20], [21, 22], [23, 24], [25, 26], [27, 28], [29, 30]],s = \"abcdefghijklmnopqrstuvwxyzz\") == 15\n assert candidate(points = [[10, 0], [0, 10], [-10, 0], [0, -10], [5, 5], [-5, -5], [5, -5], [-5, 5], [15, 15], [-15, -15], [15, -15], [-15, 15], [20, 20], [-20, -20], [20, -20], [-20, 20]],s = \"abcdefghijklmnopqrstuv\") == 16\n assert candidate(points = [[-1, 1], [1, -1], [2, 2], [-2, -2], [3, 3], [-3, -3], [4, 4], [-4, -4], [5, 5], [-5, -5]],s = \"abcdefghijkm\") == 10\n assert candidate(points = [[1, 0], [0, 1], [-1, 0], [0, -1], [2, 0], [0, 2], [-2, 0], [0, -2], [3, 0], [0, 3], [-3, 0], [0, -3], [4, 0], [0, 4], [-4, 0], [0, -4]],s = \"abcdefghijklmnop\") == 16\n assert candidate(points = [[0, 0], [1, 0], [-1, 0], [0, 1], [0, -1], [1, 1], [-1, -1], [1, -1], [-1, 1], [2, 2]],s = \"abcdefghij\") == 10\n assert candidate(points = [[1, 1], [1, -1], [-1, 1], [-1, -1], [2, 2], [2, -2], [-2, 2], [-2, -2], [3, 3], [3, -3], [-3, 3], [-3, -3]],s = \"abcdefghijkl\") == 12\n assert candidate(points = [[0, 1], [1, 0], [0, -1], [-1, 0], [2, 0], [0, 2], [-2, 0], [0, -2], [3, 0], [0, 3], [-3, 0], [0, -3]],s = \"abcdefghijkl\") == 12\n assert candidate(points = [[-1000000000, 1000000000], [1000000000, -1000000000], [0, 0], [100, 100], [-100, -100], [50, 50], [-50, -50]],s = \"abcdefghijkl\") == 7\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],s = \"abcdefghij\") == 10\n assert candidate(points = [[5, 5], [-5, -5], [5, -5], [-5, 5], [10, 10], [-10, -10], [10, -10], [-10, 10], [15, 15], [-15, -15], [15, -15], [-15, 15]],s = \"abcdefghijklmnopq\") == 12\n assert candidate(points = [[1, 2], [2, 1], [3, 4], [4, 3], [5, 6], [6, 5], [7, 8], [8, 7], [9, 10], [10, 9], [11, 12], [12, 11], [13, 14], [14, 13], [15, 16]],s = \"abcdefghijklmnop\") == 15\n assert candidate(points = [[1, 1], [-1, -1], [2, 2], [-2, -2], [3, 3], [-3, -3], [4, 4], [-4, -4], [5, 5], [-5, -5]],s = \"abcdefghij\") == 10\n assert candidate(points = [[1, 2], [2, 1], [-1, -2], [-2, -1], [3, 3], [-3, -3], [4, 4], [-4, -4], [5, 5], [-5, -5]],s = \"abcdefghij\") == 10\n assert candidate(points = [[1, 2], [2, 1], [-1, -2], [-2, -1], [1, -1], [-1, 1], [2, 2], [-2, -2], [2, -2], [-2, 2]],s = \"abcdefghij\") == 10\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]],s = \"abcdefghijklmno\") == 15\n assert candidate(points = [[0, 0], [1, 0], [0, 1], [1, 1], [-1, 0], [0, -1], [-1, -1], [-1, 1], [1, -1]],s = \"abcdefghi\") == 9\n assert candidate(points = [[1, 1], [1, 2], [2, 1], [2, 2], [2, 3], [3, 2], [3, 3], [4, 4]],s = \"abcdefgh\") == 8\n assert candidate(points = [[10, 10], [-10, -10], [5, 0], [-5, 0], [0, 5], [0, -5], [3, 4], [-3, -4], [4, -3], [-4, 3]],s = \"abcdefghij\") == 10\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 2], [2, 1], [-1, -2], [-2, -1]],s = \"abcdefghijk\") == 9\n assert candidate(points = [[-1, 0], [0, 1], [1, 0], [0, -1], [1, 1], [-1, -1], [2, 2], [-2, -2], [3, 3], [-3, -3], [4, 4], [-4, -4]],s = \"abcdefghijklmn\") == 12\n assert candidate(points = [[1, 0], [0, 1], [-1, 0], [0, -1], [1, 1], [1, -1], [-1, 1], [-1, -1], [2, 2], [-2, -2]],s = \"abcdefghij\") == 10\n assert candidate(points = [[1000000000, 1000000000], [-1000000000, -1000000000], [500000000, 0], [-500000000, 0], [0, 500000000], [0, -500000000], [300000000, 400000000], [-300000000, -400000000], [400000000, -300000000], [-400000000, 300000000]],s = \"abcdefghij\") == 10\n assert candidate(points = [[1, 1], [1, -1], [-1, 1], [-1, -1], [2, 2], [2, -2], [-2, 2], [-2, -2], [3, 3], [3, -3], [-3, 3], [-3, -3], [4, 4], [4, -4], [-4, 4], [-4, -4]],s = \"abcdefghijklmnop\") == 16\n assert candidate(points = [[999999999, 999999999], [-999999999, -999999999], [999999999, -999999999], [-999999999, 999999999]],s = \"abcd\") == 4\n assert candidate(points = [[1, 0], [0, 1], [-1, 0], [0, -1], [2, 0], [0, 2], [-2, 0], [0, -2], [1, 1], [1, -1], [-1, 1], [-1, -1]],s = \"abcdefghijkl\") == 12\n assert candidate(points = [[1, 1], [1, 2], [2, 1], [2, 2], [1, -1], [-1, 1], [-2, -2], [2, -2], [-2, 2], [1, -2], [-2, 1], [2, 1], [-1, -2], [2, 2], [-2, -1], [1, 2], [2, -1], [-1, 2], [3, 3], [3, -3], [-3, 3], [-3, -3]],s = \"abcdefghijklmnopqrstuvwxyz\") == 22\n assert candidate(points = [[10, 10], [-10, -10], [10, -10], [-10, 10], [1, 1], [-1, -1], [0, 0]],s = \"abcdefghijk\") == 7\n assert candidate(points = [[1, 0], [-1, 0], [0, 1], [0, -1], [1, 1], [-1, -1], [1, -1], [-1, 1], [2, 0], [-2, 0], [0, 2], [0, -2], [3, 0], [-3, 0], [0, 3], [0, -3]],s = \"abcdefghijklmnop\") == 16\n assert candidate(points = [[-1, -1], [-2, -2], [-3, -3], [-4, -4], [-5, -5], [-6, -6], [-7, -7], [-8, -8], [-9, -9], [-10, -10]],s = \"abcdefghijk\") == 10\n assert candidate(points = [[1, 2], [2, 1], [-1, -2], [-2, -1], [1, -1], [-1, 1], [2, -2], [-2, 2], [3, 3], [3, -3], [-3, 3], [-3, -3], [4, 4], [4, -4], [-4, 4], [-4, -4]],s = \"abcdefghijklmnopqr\") == 16\n assert candidate(points = [[1, 1], [1, 2], [2, 1], [2, 2], [1, -1], [-1, 1], [-2, -2], [2, -2], [-2, 2], [1, -2], [-2, 1], [2, 1], [-1, -2], [2, 2], [-2, -1], [1, 2], [2, -1], [-1, 2]],s = \"abcdefghijklmnopqrstuv\") == 18\n assert candidate(points = [[5, 0], [-5, 0], [0, 5], [0, -5], [2, 2], [-2, -2], [3, 3], [-3, -3], [1, 1], [-1, -1], [4, 4], [-4, -4], [6, 6], [-6, -6]],s = \"abcdefghijklmnopqr\") == 14\n assert candidate(points = [[1000000000, 1000000000], [-1000000000, -1000000000], [1000000000, -1000000000], [-1000000000, 1000000000], [500000000, 500000000], [-500000000, -500000000]],s = \"abcdef\") == 6\n assert candidate(points = [[1, 2], [2, 1], [3, 0], [0, 3], [-1, -2], [-2, -1], [-3, 0], [0, -3], [1, -1], [-1, 1], [2, -2], [-2, 2], [3, -3], [-3, 3]],s = \"abcdefghijklmno\") == 14\n assert candidate(points = [[10, 10], [-10, -10], [10, -10], [-10, 10], [5, 5], [-5, -5], [5, -5], [-5, 5], [0, 0], [3, 3], [-3, -3], [3, -3], [-3, 3], [7, 7], [-7, -7]],s = \"abcdefghijklmnopqrst\") == 15\n assert candidate(points = [[1, 1], [1, -1], [-1, 1], [-1, -1], [2, 2], [2, -2], [-2, 2], [-2, -2]],s = \"aaaaabbbbb\") == 0\n assert candidate(points = [[-7, -7], [-7, 7], [7, -7], [7, 7], [2, 2], [-2, -2], [2, -2], [-2, 2], [0, 0]],s = \"abcdefghij\") == 9\n assert candidate(points = [[1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0], [10, 0]],s = \"abcdefghij\") == 10\n assert candidate(points = [[0, 0], [1, 0], [-1, 0], [0, 1], [0, -1], [2, 0], [0, 2], [-2, 0], [0, -2], [3, 0], [0, 3], [-3, 0], [0, -3]],s = \"abcdefghijklm\") == 13\n assert candidate(points = [[0, 0], [1, 0], [0, 1], [-1, 0], [0, -1], [2, 2], [-2, -2], [2, -2], [-2, 2]],s = \"abcdefghi\") == 9\n assert candidate(points = [[1, 1], [1, -1], [-1, 1], [-1, -1], [2, 2], [2, -2], [-2, 2], [-2, -2], [3, 3], [3, -3], [-3, 3], [-3, -3], [0, 0]],s = \"abcdefghijklm\") == 13\n assert candidate(points = [[0, 0], [1, 1], [-1, -1], [2, 2], [-2, -2], [3, 3], [-3, -3], [4, 4], [-4, -4]],s = \"abcdefghi\") == 9\n assert candidate(points = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],s = \"abcdefghijk\") == 10\n assert candidate(points = [[1, 1], [1, 2], [2, 1], [2, 2], [3, 3], [3, 4], [4, 3], [4, 4], [5, 5], [5, 6], [6, 5], [6, 6]],s = \"abcdefghijkl\") == 12\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],s = \"abcdefghijk\") == 11\n assert candidate(points = [[1, 0], [-1, 0], [0, 1], [0, -1], [2, 0], [0, 2], [-2, 0], [0, -2], [3, 0], [0, 3], [-3, 0], [0, -3], [4, 0], [0, 4], [-4, 0], [0, -4]],s = \"abcdefghijklmnop\") == 16\n assert candidate(points = [[10, 10], [-10, -10], [10, -10], [-10, 10], [0, 0]],s = \"abcde\") == 5\n assert candidate(points = [[100, 0], [0, 100], [-100, 0], [0, -100], [50, 50], [50, -50], [-50, 50], [-50, -50], [25, 25], [25, -25], [-25, 25], [-25, -25]],s = \"abcdefghijkl\") == 12\n assert candidate(points = [[1000000000, 0], [-1000000000, 0], [0, 1000000000], [0, -1000000000], [500000000, 500000000]],s = \"abcde\") == 5\n assert candidate(points = [[10, 0], [0, 10], [-10, 0], [0, -10], [20, 0], [0, 20], [-20, 0], [0, -20], [10, 10], [10, -10], [-10, 10], [-10, -10]],s = \"abcdefghijkl\") == 12\n assert candidate(points = [[0, 0], [1, 1], [1, -1], [-1, 1], [-1, -1]],s = \"abcde\") == 5\n assert candidate(points = [[5, 5], [-5, -5], [4, 4], [-4, -4], [3, 3], [-3, -3], [2, 2], [-2, -2], [1, 1], [-1, -1]],s = \"abcdefghij\") == 10\n assert candidate(points = [[1, 1], [1, -1], [-1, 1], [-1, -1], [0, 0], [0, 1], [0, -1], [1, 0], [-1, 0]],s = \"abcdefghi\") == 9\n assert candidate(points = [[1000000000, 0], [0, 1000000000], [-1000000000, 0], [0, -1000000000]],s = \"abcd\") == 4\n assert candidate(points = [[5, 0], [0, 5], [-5, 0], [0, -5], [3, 4], [4, 3], [-3, -4], [-4, -3]],s = \"abcdefgh\") == 8\n assert candidate(points = [[1, 0], [0, 1], [-1, 0], [0, -1], [1, 1], [1, -1], [-1, 1], [-1, -1], [2, 2], [2, -2], [-2, 2], [-2, -2]],s = \"abcdefghijkl\") == 12\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]],s = \"abcdefghij\") == 10\n assert candidate(points = [[-10, 10], [10, -10], [10, 10], [-10, -10], [5, 5], [-5, -5], [5, -5], [-5, 5]],s = \"abcdefgh\") == 8\n assert candidate(points = [[100, 0], [0, 100], [-100, 0], [0, -100], [50, 50], [50, -50], [-50, 50], [-50, -50], [10, 10], [-10, -10]],s = \"abcdefghijklm\") == 10\n assert candidate(points = [[5, 0], [-5, 0], [0, 5], [0, -5], [2, 2], [-2, -2], [3, 3], [-3, -3]],s = \"abcdefgh\") == 8\n assert candidate(points = [[1000000000, 1000000000], [-1000000000, -1000000000], [1000000000, -1000000000], [-1000000000, 1000000000]],s = \"abcd\") == 4\n assert candidate(points = [[-1, -1], [1, 1], [-1, 1], [1, -1], [0, 0], [2, 0], [0, 2], [-2, 0], [0, -2], [3, 3], [-3, -3]],s = \"abcdefghijklm\") == 11\n assert candidate(points = [[0, 0], [1, 1], [1, -1], [-1, 1], [-1, -1], [2, 2], [2, -2], [-2, 2], [-2, -2]],s = \"abcdefghi\") == 9\n assert candidate(points = [[5, 5], [5, -5], [-5, 5], [-5, -5], [1, 1], [1, -1], [-1, 1], [-1, -1]],s = \"abcdefgh\") == 8\n assert candidate(points = [[1, 0], [0, 1], [-1, 0], [0, -1], [2, 0], [0, 2], [-2, 0], [0, -2], [3, 0], [0, 3], [-3, 0], [0, -3]],s = \"abcdefghijkl\") == 12\n assert candidate(points = [[1000000000, 1000000000], [1000000000, -1000000000], [-1000000000, 1000000000], [-1000000000, -1000000000], [0, 0]],s = \"abcde\") == 5\n assert candidate(points = [[1, 1], [1, -1], [-1, 1], [-1, -1], [2, 2], [2, -2], [-2, 2], [-2, -2], [3, 3], [3, -3]],s = \"abcdefghij\") == 10\n assert candidate(points = [[-9, -9], [-9, 9], [9, -9], [9, 9], [1, 2], [2, 1], [-1, -2], [-2, -1], [0, 0], [5, 5]],s = \"abcdefghijk\") == 10\n"}, "metadata": {"canonical_parameter_names": ["points", "s"], "leetcode_dataset_entry_point": "Solution().maxPointsInsideSquare", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxPointsInsideSquare(vector>& points, string s) {", "container": "Solution", "callable": "maxPointsInsideSquare", "parameters": [{"name": "points", "type": "vector>&"}, {"name": "s", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3144, "task_id": "minimum-substring-partition-of-equal-character-frequency", "difficulty": "Medium", "problem_description": "Given a string s, you need to partition it into one or more balanced substrings. For example, if s == \"ababcc\" then (\"abab\", \"c\", \"c\"), (\"ab\", \"abc\", \"c\"), and (\"ababcc\") are all valid partitions, but (\"a\", \"bab\", \"cc\"), (\"aba\", \"bc\", \"c\"), and (\"ab\", \"abcc\") are not. The unbalanced substrings are bolded.\nReturn the minimum number of substrings that you can partition s into.\nNote: A balanced string is a string where each character in the string occurs the same number of times.\n \nExample 1:\n\nInput: s = \"fabccddg\"\nOutput: 3\nExplanation:\nWe can partition the string s into 3 substrings in one of the following ways: (\"fab, \"ccdd\", \"g\"), or (\"fabc\", \"cd\", \"dg\").\n\nExample 2:\n\nInput: s = \"abababaccddb\"\nOutput: 2\nExplanation:\nWe can partition the string s into 2 substrings like so: (\"abab\", \"abaccddb\").\n\n \nConstraints:\n\n1 <= s.length <= 1000\ns consists only of English lowercase letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"zzzzzzzzz\") == 1\n assert candidate(s = \"aaabbbccc\") == 1\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 1\n assert candidate(s = \"aabbaabbccddccdd\") == 1\n assert candidate(s = \"abcdef\") == 1\n assert candidate(s = \"abababab\") == 1\n assert candidate(s = \"a\") == 1\n assert candidate(s = \"abcdefghi\") == 1\n assert candidate(s = \"abacabadabacaba\") == 8\n assert candidate(s = \"abab\") == 1\n assert candidate(s = \"abcabcabc\") == 1\n assert candidate(s = \"ab\") == 1\n assert candidate(s = \"aa\") == 1\n assert candidate(s = \"abcdefabcdef\") == 1\n assert candidate(s = \"abcde\") == 1\n assert candidate(s = \"abcabc\") == 1\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\") == 1\n assert candidate(s = \"abababaccddb\") == 2\n assert candidate(s = \"zzzzzzzzzz\") == 1\n assert candidate(s = \"abcdabcdabcd\") == 1\n assert candidate(s = \"fabccddg\") == 3\n assert candidate(s = \"aabbcc\") == 1\n assert candidate(s = \"abcdefghij\") == 1\n assert candidate(s = \"aabbccddeeffgghhiijj\") == 1\n assert candidate(s = \"abcdabcdabcdabcd\") == 1\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\") == 1\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 1\n assert candidate(s = \"abacabadabacabadabacabad\") == 12\n assert candidate(s = \"aabbaabbaabbaabbaabb\") == 1\n assert candidate(s = \"abcdefggfedcbafedcbafedcba\") == 2\n assert candidate(s = \"aabbcdeefgghhijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 6\n assert candidate(s = \"aabbaabbccddeeffgg\") == 2\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzaaa\") == 2\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 1\n assert candidate(s = \"abcdefghijklaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzyyyyxxxxwwwwvvvuuutttsssrqqppoonnmmllkkjjiihhhgggfffeeedddcccbbaa\") == 9\n assert candidate(s = \"aaabbbcccdddcccbbbbaaa\") == 4\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\") == 1\n assert candidate(s = \"zzzzzyyyyxxxxwwwwvvvuuutttsssrqqppoonnmmllkkjjiihhhgggfffeeedddcccbbaa\") == 7\n assert candidate(s = \"abcdefabcdefabcdefabcdefabcdef\") == 1\n assert candidate(s = \"abcdefghabcdefghabcdefghabcdefgh\") == 1\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\") == 1\n assert candidate(s = \"xyzxyzxyzxyzxyzxyzxyzxyz\") == 1\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbccccccccccdddddddddd\") == 1\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzabcdefghijklmnopqrstuvwxyz\") == 1\n assert candidate(s = \"aabbaaabbbaaaabbbcccdddeeefffggg\") == 3\n assert candidate(s = \"ababababababababababababababababab\") == 1\n assert candidate(s = \"abcdefgabcdefgabcdefgabcdefg\") == 1\n assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\") == 1\n assert candidate(s = \"aabbbccccddddeeeeeffffffgggggghhhhhiiiiijjjjjkkkkklllllmmmmmnnnnnooooo\") == 6\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzaabb\") == 2\n assert candidate(s = \"aabbaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzabcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == 2\n assert candidate(s = \"abcdefabcdefabcdefabcdef\") == 1\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 1\n assert candidate(s = \"qqwweerrttyyuuuuummmiiiinnnngggg\") == 3\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == 1\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 1\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz\") == 1\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzabcdefg\") == 2\n assert candidate(s = \"abcabcabcabcabcabc\") == 1\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzyyyyxxxxwwwwvvvuuutttsssrqqppoonnmmllkkjjiihhhgggfffeeedddcccbbaa\") == 8\n assert candidate(s = \"aabbaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzz\") == 3\n assert candidate(s = \"aabbaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzyxwvutsrqponmlkjihgfedcba\") == 2\n assert candidate(s = \"xyzzzyxzzzyxzzzyxzzzyxzzz\") == 10\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 1\n assert candidate(s = \"aaabbbcccddd\") == 1\n assert candidate(s = \"abcabcababcabc\") == 2\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabc\") == 1\n assert candidate(s = \"aaaaaaaaaaabbbbbbbbbc\") == 3\n assert candidate(s = \"abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef\") == 1\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba\") == 3\n assert candidate(s = \"aabbccddeeffaabbccddeeff\") == 1\n assert candidate(s = \"abcabcdabcabcdeabcdefabcdefg\") == 5\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().minimumSubstringsInPartition", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumSubstringsInPartition(string s) {", "container": "Solution", "callable": "minimumSubstringsInPartition", "parameters": [{"name": "s", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3146, "task_id": "permutation-difference-between-two-strings", "difficulty": "Easy", "problem_description": "You are given two strings s and t such that every character occurs at most once in s and t is a permutation of s.\nThe permutation difference between s and t is defined as the sum of the absolute difference between the index of the occurrence of each character in s and the index of the occurrence of the same character in t.\nReturn the permutation difference between s and t.\n \nExample 1:\n\nInput: s = \"abc\", t = \"bac\"\nOutput: 2\nExplanation:\nFor s = \"abc\" and t = \"bac\", the permutation difference of s and t is equal to the sum of:\n\nThe absolute difference between the index of the occurrence of \"a\" in s and the index of the occurrence of \"a\" in t.\nThe absolute difference between the index of the occurrence of \"b\" in s and the index of the occurrence of \"b\" in t.\nThe absolute difference between the index of the occurrence of \"c\" in s and the index of the occurrence of \"c\" in t.\n\nThat is, the permutation difference between s and t is equal to |0 - 1| + |1 - 0| + |2 - 2| = 2.\n\nExample 2:\n\nInput: s = \"abcde\", t = \"edbac\"\nOutput: 12\nExplanation: The permutation difference between s and t is equal to |0 - 3| + |1 - 2| + |2 - 4| + |3 - 1| + |4 - 0| = 12.\n\n \nConstraints:\n\n1 <= s.length <= 26\nEach character occurs at most once in s.\nt is a permutation of s.\ns consists only of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"zyxwvutsrqponmlkjihgfedcba\") == 338\n assert candidate(s = \"mnopqr\",t = \"qrpmno\") == 18\n assert candidate(s = \"abcde\",t = \"edbac\") == 12\n assert candidate(s = \"abcxyz\",t = \"xyzabc\") == 18\n assert candidate(s = \"qrstuv\",t = \"vutsrq\") == 18\n assert candidate(s = \"abc\",t = \"bac\") == 2\n assert candidate(s = \"mnopqr\",t = \"rqponm\") == 18\n assert candidate(s = \"uvwxy\",t = \"yxuvw\") == 12\n assert candidate(s = \"mnopqr\",t = \"qrponm\") == 18\n assert candidate(s = \"a\",t = \"a\") == 0\n assert candidate(s = \"abcd\",t = \"dcba\") == 8\n assert candidate(s = \"xyz\",t = \"zyx\") == 4\n assert candidate(s = \"ab\",t = \"ba\") == 2\n assert candidate(s = \"mnopqrstuvwxyzabcdefghijkl\",t = \"qrstuvwxyzabcdefghijklmno\") == 154\n assert candidate(s = \"abcdpqrs\",t = \"srqpdcba\") == 32\n assert candidate(s = \"qazwsxedcrfvtgbyhnujmiklop\",t = \"plokmijnuhbygvtfcrdxeszwaq\") == 338\n assert candidate(s = \"fedcba\",t = \"abcdef\") == 18\n assert candidate(s = \"lkjhgfedcba\",t = \"abcdefghjkl\") == 60\n assert candidate(s = \"abcdefg\",t = \"gfedcba\") == 24\n assert candidate(s = \"abcdfghijklmnopqrstuvwxyzef\",t = \"efghijklmnopqrstuvwxyzabcd\") == 198\n assert candidate(s = \"lmnopqrstuvwxy\",t = \"yxwvutsrqponml\") == 98\n assert candidate(s = \"mnopqrstu\",t = \"tusrqpmon\") == 40\n assert candidate(s = \"ijklmnopqr\",t = \"rqponmlkji\") == 50\n assert candidate(s = \"abcdefghijl\",t = \"ljihgfedcba\") == 60\n assert candidate(s = \"hijklmnop\",t = \"ponmlkjih\") == 40\n assert candidate(s = \"qzjrwbyfc\",t = \"bfywzcrjq\") == 38\n assert candidate(s = \"xyzabcdefghijklmnopqrstuvw\",t = \"wvutsrqponmlkjihgfedcbazyx\") == 338\n assert candidate(s = \"abcdefghijklmnop\",t = \"ponmlkjihgfedcba\") == 128\n assert candidate(s = \"abcdefghij\",t = \"ghijabcdfe\") == 48\n assert candidate(s = \"abcdefghijk\",t = \"kjihgfedcba\") == 60\n assert candidate(s = \"zabcdefghijklmnopqrstuvwxy\",t = \"yzxwvutsrqponmlkjihgfedcba\") == 314\n assert candidate(s = \"jklmnopqrabcdefghistuvwxy\",t = \"tuvxyabcdefghistuvwklmnoj\") == 267\n assert candidate(s = \"abcdefghij\",t = \"jabcdefghi\") == 18\n assert candidate(s = \"pqrstuv\",t = \"vutsrqp\") == 24\n assert candidate(s = \"vwxyzabcdefghijklmnopqrst\",t = \"rstqponmlkjihgfedcbazyxwv\") == 312\n assert candidate(s = \"asdfghjkl\",t = \"lkjhgfdsa\") == 40\n assert candidate(s = \"abcdefghij\",t = \"ihgfedcbaj\") == 40\n assert candidate(s = \"abcdefghij\",t = \"jihgfedcba\") == 50\n assert candidate(s = \"abcdef\",t = \"fedcba\") == 18\n assert candidate(s = \"pqrstuvw\",t = \"vutsrqwp\") == 26\n assert candidate(s = \"abcdefghijk\",t = \"fedcbaghijk\") == 18\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"abcdefghijklmnopqrstuvwxyza\") == 26\n assert candidate(s = \"xyzabcdefghijklmnopqrstuvw\",t = \"vutsrqponmlkjihgfedcbazyxw\") == 312\n assert candidate(s = \"thequickbrown\",t = \"nkbrohwiqctue\") == 82\n assert candidate(s = \"lmnopqrt\",t = \"tqrponml\") == 32\n assert candidate(s = \"abcdefghijkmnopqrstuvwxyzl\",t = \"lmnopqrstuvwxyzabcdefghijk\") == 330\n assert candidate(s = \"xyzuvw\",t = \"uvwzyx\") == 18\n assert candidate(s = \"abcdefghilmnopqrstuvwxyzjk\",t = \"jklmnopqrstuvwxyzabcdefghi\") == 306\n assert candidate(s = \"abc\",t = \"cba\") == 4\n assert candidate(s = \"abcdefghijkmnopqrstvuwxyz\",t = \"xyzuvwtpqrsmnkjihgfedcba\") == 297\n assert candidate(s = \"acdefghijklmnopqrstuvwxyzb\",t = \"bzabcdefghijklmnopqrstuvwxy\") == 141\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"qpjohuxivtnrckdsmgflweazyb\") == 246\n assert candidate(s = \"abcdxyz\",t = \"zyxcba\") == 21\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"qrstuvwxyabcdefghijklmnop\") == 288\n assert candidate(s = \"abcdefghijkmnopqrstuvwxyzl\",t = \"lnopqrstuvwxyzabcdefghijkml\") == 337\n assert candidate(s = \"qrstuv\",t = \"tvusqr\") == 18\n assert candidate(s = \"abcdefghijk\",t = \"kabcdefghij\") == 20\n assert candidate(s = \"rplumabc\",t = \"mucrlpba\") == 22\n assert candidate(s = \"mnopqrstuvwxyzabcde\",t = \"edcbamnopqrstuvwxyz\") == 140\n assert candidate(s = \"aeiouy\",t = \"uyioea\") == 16\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"bacdefghijklmnopqrstuvwxyza\") == 28\n assert candidate(s = \"abcdefghijklmnopqrstuvwxy\",t = \"yxwvutsrqponmlkjihgfedcba\") == 312\n assert candidate(s = \"zxcvbnm\",t = \"mnbvcxz\") == 24\n assert candidate(s = \"lkjhgfdsapoiuytrewqmnbvcxz\",t = \"xcvbnmqwertypoiuytsdfghjkl\") == 318\n assert candidate(s = \"xyzxyz\",t = \"zzzyyx\") == 15\n assert candidate(s = \"xyzabcdefghijklmnopqrstuvw\",t = \"stuvwxabcdefghijklmnopqrzy\") == 210\n assert candidate(s = \"abcdefghij\",t = \"ijhgfedcba\") == 50\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\",t = \"mnbvcxzlkjhgfdsapoiuytrewq\") == 338\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"bcazdefghijklmnopqrstuvwxy\") == 48\n assert candidate(s = \"tuvrstxyzwqpomnlkjihgfedcba\",t = \"cabfedghijklmnopqrstuvwxyz\") == 338\n assert candidate(s = \"abcxyz\",t = \"zyxcba\") == 18\n assert candidate(s = \"qwertyuiop\",t = \"poiuytrewq\") == 50\n assert candidate(s = \"abcdefghijk\",t = \"kijhgfedcba\") == 60\n assert candidate(s = \"abcdefghijlm\",t = \"mljihgfedcba\") == 72\n assert candidate(s = \"mnopqrstu\",t = \"ustqrpmno\") == 40\n assert candidate(s = \"abcdefgh\",t = \"hgfedcba\") == 32\n assert candidate(s = \"qrstuvw\",t = \"tuvwsrq\") == 24\n assert candidate(s = \"abcdefghijklm\",t = \"mlkjihgfedcba\") == 84\n assert candidate(s = \"abcdefghij\",t = \"abcdefghij\") == 0\n assert candidate(s = \"ghijklmn\",t = \"nmlkjihg\") == 32\n"}, "metadata": {"canonical_parameter_names": ["s", "t"], "leetcode_dataset_entry_point": "Solution().findPermutationDifference", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int findPermutationDifference(string s, string t) {", "container": "Solution", "callable": "findPermutationDifference", "parameters": [{"name": "s", "type": "string"}, {"name": "t", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3147, "task_id": "taking-maximum-energy-from-the-mystic-dungeon", "difficulty": "Medium", "problem_description": "In a mystic dungeon, n magicians are standing in a line. Each magician has an attribute that gives you energy. Some magicians can give you negative energy, which means taking energy from you.\nYou have been cursed in such a way that after absorbing energy from magician i, you will be instantly transported to magician (i + k). This process will be repeated until you reach the magician where (i + k) does not exist.\nIn other words, you will choose a starting point and then teleport with k jumps until you reach the end of the magicians' sequence, absorbing all the energy during the journey.\nYou are given an array energy and an integer k. Return the maximum possible energy you can gain.\nNote that when you are reach a magician, you must take energy from them, whether it is negative or positive energy.\n \nExample 1:\n\nInput: energy = [5,2,-10,-5,1], k = 3\nOutput: 3\nExplanation: We can gain a total energy of 3 by starting from magician 1 absorbing 2 + 1 = 3.\n\nExample 2:\n\nInput: energy = [-2,-3,-1], k = 2\nOutput: -1\nExplanation: We can gain a total energy of -1 by starting from magician 2.\n\n \nConstraints:\n\n1 <= energy.length <= 105\n-1000 <= energy[i] <= 1000\n1 <= k <= energy.length - 1\n\n \n​​​​​​", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(energy = [100, -100, 100, -100, 100, 100],k = 2) == 300\n assert candidate(energy = [-1, -2, -3, -4, -5],k = 3) == -3\n assert candidate(energy = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 2) == 30\n assert candidate(energy = [1, 2, 3, 4, 5],k = 1) == 15\n assert candidate(energy = [100, -100, 100, -100, 100],k = 1) == 100\n assert candidate(energy = [1, 2, 3, 4, 5, 6],k = 2) == 12\n assert candidate(energy = [-1, -2, -3, -4, -5],k = 2) == -4\n assert candidate(energy = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 4) == -7\n assert candidate(energy = [-2, -3, -1],k = 2) == -1\n assert candidate(energy = [100, -100, 50, -50, 25, -25, 10, -10, 5, -5],k = 2) == 190\n assert candidate(energy = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 1) == 0\n assert candidate(energy = [5, 2, -10, -5, 1],k = 3) == 3\n assert candidate(energy = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4) == 18\n assert candidate(energy = [100, -50, 200, -100, 300],k = 2) == 600\n assert candidate(energy = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 5) == -6\n assert candidate(energy = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],k = 6) == -1\n assert candidate(energy = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 14) == 2\n assert candidate(energy = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100, 110, -120, 130, -140, 150],k = 4) == 360\n assert candidate(energy = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10],k = 5) == 10\n assert candidate(energy = [1000, -500, 250, -125, 62, -31, 15, -7, 3, -1, 0, 1, -3, 7, -15, 31, -62, 125, -250, 500],k = 5) == 1000\n assert candidate(energy = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15],k = 3) == 15\n assert candidate(energy = [5, -1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19],k = 2) == 95\n assert candidate(energy = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 7) == 1\n assert candidate(energy = [100, -10, 50, -20, 30, -40, 20, -30, 10, -5],k = 4) == 140\n assert candidate(energy = [50, -20, 30, -10, 40, -30, 20],k = 3) == 60\n assert candidate(energy = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],k = 4) == 55\n assert candidate(energy = [10, 20, -30, 40, -50, 60, -70, 80],k = 3) == 80\n assert candidate(energy = [-5, -10, -15, -20, -25, -30, -35, -40, -45, -50, -55, -60, -65, -70, -75, -80, -85, -90, -95, -100, -105, -110, -115, -120, -125, -130, -135, -140, -145, -150],k = 11) == -100\n assert candidate(energy = [50, -50, 50, -50, 50, -50, 50, -50, 50, -50],k = 5) == 50\n assert candidate(energy = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 150\n assert candidate(energy = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, -1000, -900, -800, -700, -600, -500, -400, -300, -200, -100],k = 8) == 900\n assert candidate(energy = [-10, 20, -30, 40, -50, 60, -70, 80, -90, 100],k = 3) == 100\n assert candidate(energy = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50],k = 2) == 150\n assert candidate(energy = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 5) == 0\n assert candidate(energy = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 12\n assert candidate(energy = [2, 3, 5, 8, 13, 21, -34, 55, -89, 144, -233, 377],k = 4) == 440\n assert candidate(energy = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10],k = 4) == 15\n assert candidate(energy = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],k = 5) == 3000\n assert candidate(energy = [-5, -10, -15, -20, -25, -30, -35, -40, -45, -50, -55, -60, -65, -70, -75, -80, -85, -90, -95, -100],k = 5) == -80\n assert candidate(energy = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100],k = 3) == 90\n assert candidate(energy = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 1) == 100\n assert candidate(energy = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4) == 18\n assert candidate(energy = [-10, 50, -30, 20, -10, 40, -50, 60, -70, 80],k = 5) == 80\n assert candidate(energy = [-5, -4, -3, -2, -1, 1, 2, 3, 4, 5],k = 2) == 9\n assert candidate(energy = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100, 110, -120, 130, -140, 150],k = 7) == 150\n assert candidate(energy = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 8) == 1192\n assert candidate(energy = [10, -20, 30, -40, 50, -60, 70, -80],k = 3) == 70\n assert candidate(energy = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 15\n assert candidate(energy = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000, 1100, -1200, 1300, -1400],k = 4) == 2800\n assert candidate(energy = [500, 400, 300, 200, 100, 0, -100, -200, -300, -400, -500],k = 5) == 300\n assert candidate(energy = [10, 20, -30, 40, -50, 60, -70, 80, -90, 100, -110, 120, -130, 140, -150, 160, -170, 180, -190, 200],k = 9) == 200\n assert candidate(energy = [50, -20, 30, -10, 40, -30, 20, -10, 50],k = 3) == 60\n assert candidate(energy = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100, 10, 20, 30, 40, 50],k = 6) == 50\n assert candidate(energy = [500, -100, 200, -300, 400, -500, 600, -700, 800, -900],k = 6) == 1100\n assert candidate(energy = [3, 4, -2, 5, -7, 10, -15, 20],k = 3) == 20\n assert candidate(energy = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],k = 9) == 10\n assert candidate(energy = [-100, -200, -300, -400, -500, -600, -700, -800, -900, -1000],k = 2) == -900\n assert candidate(energy = [1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000],k = 8) == 2000\n assert candidate(energy = [100, -50, 200, -100, 300, 400, -200, 500, -300, 600, 700, -400, 800, 900, -500, 1000],k = 8) == 1500\n assert candidate(energy = [5, 10, -20, 15, -10, 5, 25, -20, 30],k = 3) == 45\n assert candidate(energy = [1000, -900, 800, -700, 600, -500, 400, -300, 200, -100],k = 7) == 700\n assert candidate(energy = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 9) == 110\n assert candidate(energy = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1],k = 9) == 1\n assert candidate(energy = [50, 20, -10, 5, -30, 25, 15, -5, 10, 5, -15],k = 6) == 65\n assert candidate(energy = [100, 0, -100, 200, 0, -200, 300, 0, -300, 400, 0, -400, 500, 0, -500, 600, 0, -600, 700, 0],k = 10) == 700\n assert candidate(energy = [10, -5, 15, -10, 20, -25, 30],k = 2) == 75\n assert candidate(energy = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 7) == 39\n assert candidate(energy = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500],k = 3) == 500\n assert candidate(energy = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 9) == 1100\n assert candidate(energy = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15],k = 6) == 27\n assert candidate(energy = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50, 60, -60, 70, -70, 80, -80, 90, -90, 100, -100],k = 3) == 100\n assert candidate(energy = [1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000],k = 2) == 5000\n assert candidate(energy = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300],k = 10) == 600\n assert candidate(energy = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 1) == 5500\n assert candidate(energy = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 5\n assert candidate(energy = [1000, -500, 250, -125, 62, -31, 15, -7, 3, -1, 0, 1, -2, 3, -4, 5, -6, 7, -8, 9],k = 7) == 989\n assert candidate(energy = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 7) == 80\n assert candidate(energy = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 4) == 180\n assert candidate(energy = [1000, -500, 250, -125, 62, -31, 15, -7, 3, -1, 0, 1, -2, 4, -8],k = 5) == 969\n assert candidate(energy = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 3) == 1\n assert candidate(energy = [5, -1, 4, -2, 3, -3, 2, -1, 1, -2],k = 2) == 15\n assert candidate(energy = [-100, 200, -300, 400, -500, 600, -700, 800, -900, 1000],k = 5) == 1000\n assert candidate(energy = [1000, -1000, 500, -500, 250, -250, 125, -125],k = 2) == 1875\n assert candidate(energy = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 4) == 4\n assert candidate(energy = [900, 800, 700, 600, 500, 400, 300, 200, 100, 0, -100, -200, -300, -400, -500],k = 5) == 1200\n assert candidate(energy = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1],k = 7) == 9\n assert candidate(energy = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 2) == 10\n assert candidate(energy = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 4\n assert candidate(energy = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 9) == 330\n assert candidate(energy = [1000, -1000, 500, -500, 250, -250, 125, -125, 63, -63, 32, -32, 16, -16, 8, -8, 4, -4, 2, -2, 1, -1],k = 5) == 775\n assert candidate(energy = [1000, -1000, 500, -500, 250, -250, 125, -125, 62, -62, 31, -31, 15, -15, 7, -7, 3, -3, 1, -1],k = 7) == 882\n assert candidate(energy = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],k = 3) == -80\n assert candidate(energy = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, -10, -20, -30, -40, -50, -60, -70, -80, -90, -100],k = 5) == 60\n assert candidate(energy = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 19) == 21\n assert candidate(energy = [-100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100],k = 6) == 300\n assert candidate(energy = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20],k = 10) == -11\n assert candidate(energy = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 15\n assert candidate(energy = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50],k = 5) == 50\n assert candidate(energy = [500, -500, 500, -500, 500, -500, 500, -500, 500],k = 2) == 2500\n assert candidate(energy = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 6) == 440\n assert candidate(energy = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20, 21, -22, 23, -24, 25, -26, 27, -28, 29, -30],k = 10) == 57\n assert candidate(energy = [-500, -400, -300, -200, -100, 0, 100, 200, 300, 400, 500, 600, 700, 800, 900],k = 6) == 1200\n assert candidate(energy = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 9) == 1\n assert candidate(energy = [100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100],k = 7) == 100\n assert candidate(energy = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],k = 1) == 1500\n assert candidate(energy = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 4) == 5\n assert candidate(energy = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],k = 5) == -60\n assert candidate(energy = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 4) == 180\n assert candidate(energy = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],k = 1) == -100\n assert candidate(energy = [5, 15, -25, 35, -45, 55, -65, 75, -85, 95, -105],k = 5) == 95\n assert candidate(energy = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 6) == 44\n assert candidate(energy = [-5, 5, -10, 10, -15, 15, -20, 20, -25, 25, -30, 30, -35, 35, -40],k = 5) == 35\n assert candidate(energy = [-5, 10, -15, 20, -25, 30, -35, 40, -45, 50, -55, 60, -65, 70, -75, 80, -85, 90, -95, 100],k = 5) == 100\n assert candidate(energy = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100],k = 4) == 150\n assert candidate(energy = [-100, -200, -300, -400, -500, -600, -700, -800, -900, -1000],k = 9) == -200\n assert candidate(energy = [-10, 20, -30, 40, -50, 60, -70, 80],k = 4) == 120\n assert candidate(energy = [0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20],k = 12) == 44\n assert candidate(energy = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 5) == 300\n assert candidate(energy = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20],k = 7) == 19\n assert candidate(energy = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20],k = 8) == 36\n"}, "metadata": {"canonical_parameter_names": ["energy", "k"], "leetcode_dataset_entry_point": "Solution().maximumEnergy", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maximumEnergy(vector& energy, int k) {", "container": "Solution", "callable": "maximumEnergy", "parameters": [{"name": "energy", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3148, "task_id": "maximum-difference-score-in-a-grid", "difficulty": "Medium", "problem_description": "You are given an m x n matrix grid consisting of positive integers. You can move from a cell in the matrix to any other cell that is either to the bottom or to the right (not necessarily adjacent). The score of a move from a cell with the value c1 to a cell with the value c2 is c2 - c1.\nYou can start at any cell, and you have to make at least one move.\nReturn the maximum total score you can achieve.\n \nExample 1:\n\n\nInput: grid = [[9,5,7,3],[8,9,6,1],[6,7,14,3],[2,5,3,1]]\nOutput: 9\nExplanation: We start at the cell (0, 1), and we perform the following moves:\n- Move from the cell (0, 1) to (2, 1) with a score of 7 - 5 = 2.\n- Move from the cell (2, 1) to (2, 2) with a score of 14 - 7 = 7.\nThe total score is 2 + 7 = 9.\n\nExample 2:\n\n\nInput: grid = [[4,3,2],[3,2,1]]\nOutput: -1\nExplanation: We start at the cell (0, 0), and we perform one move: (0, 0) to (0, 1). The score is 3 - 4 = -1.\n\n \nConstraints:\n\nm == grid.length\nn == grid[i].length\n2 <= m, n <= 1000\n4 <= m * n <= 105\n1 <= grid[i][j] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7]]) == 6\n assert candidate(grid = [[4, 3, 2], [3, 2, 1]]) == -1\n assert candidate(grid = [[100, 90, 80], [70, 60, 50], [40, 30, 20]]) == -10\n assert candidate(grid = [[9, 5, 7, 3], [8, 9, 6, 1], [6, 7, 14, 3], [2, 5, 3, 1]]) == 9\n assert candidate(grid = [[5, 1, 3], [4, 1, 5], [7, 9, 3]]) == 8\n assert candidate(grid = [[1, 2, 3, 4, 5], [10, 9, 8, 7, 6], [11, 12, 13, 14, 15]]) == 14\n assert candidate(grid = [[10, 15, 20], [5, 9, 12], [3, 6, 8]]) == 10\n assert candidate(grid = [[10, 20, 30], [40, 50, 60], [70, 80, 90]]) == 80\n assert candidate(grid = [[5, 3, 6, 2], [9, 1, 8, 4], [7, 10, 11, 5]]) == 10\n assert candidate(grid = [[1, 10, 3, 8], [12, 2, 9, 6], [5, 7, 1, 11], [3, 4, 13, 4]]) == 12\n assert candidate(grid = [[5, 3, 11, 12], [9, 10, 13, 14], [1, 2, 4, 8]]) == 11\n assert candidate(grid = [[1, 2], [3, 4], [5, 6], [7, 8]]) == 7\n assert candidate(grid = [[5, 3, 10, 7], [6, 4, 8, 2], [7, 5, 9, 3]]) == 7\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [20, 19, 18, 17, 16, 15, 14, 13, 12, 11]]) == 19\n assert candidate(grid = [[100, 99, 98, 97, 96], [95, 94, 93, 92, 91], [90, 89, 88, 87, 86], [85, 84, 83, 82, 81], [80, 79, 78, 77, 76]]) == -1\n assert candidate(grid = [[99999, 99998, 99997, 99996], [99995, 99994, 99993, 99992], [99991, 99990, 99989, 99988], [99987, 99986, 99985, 99984], [99983, 99982, 99981, 99980]]) == -1\n assert candidate(grid = [[1, 100000], [100000, 1], [1, 100000], [100000, 1], [1, 100000], [100000, 1]]) == 99999\n assert candidate(grid = [[1, 1, 1, 1, 1000], [1, 1, 1, 1000, 1], [1, 1, 1000, 1, 1], [1, 1000, 1, 1, 1], [1000, 1, 1, 1, 1]]) == 999\n assert candidate(grid = [[50, 40, 30, 20, 10, 5], [45, 35, 25, 15, 5, 0], [40, 30, 20, 10, 5, 0], [35, 25, 15, 5, 0, 1000], [30, 20, 10, 5, 0, 500], [25, 15, 5, 0, 1000, 250]]) == 1000\n assert candidate(grid = [[8, 2, 10, 14, 11], [13, 5, 12, 3, 18], [9, 7, 15, 17, 6], [4, 16, 1, 19, 20]]) == 19\n assert candidate(grid = [[100, 99, 98, 97], [96, 95, 94, 93], [92, 91, 90, 89], [88, 87, 86, 85], [84, 83, 82, 81]]) == -1\n assert candidate(grid = [[100, 90, 80, 70, 60], [50, 40, 30, 20, 10], [10, 20, 30, 40, 50], [95, 85, 75, 65, 55], [5, 15, 25, 35, 45]]) == 85\n assert candidate(grid = [[99, 98, 97, 96, 95, 94, 93, 92, 91, 90], [90, 91, 92, 93, 94, 95, 96, 97, 98, 99], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 9\n assert candidate(grid = [[1, 3, 5, 7, 9, 11, 13, 15, 17], [17, 15, 13, 11, 9, 7, 5, 3, 1], [2, 4, 6, 8, 10, 12, 14, 16, 18], [18, 16, 14, 12, 10, 8, 6, 4, 2]]) == 17\n assert candidate(grid = [[1, 3, 5, 7, 9, 11, 13], [2, 4, 6, 8, 10, 12, 14], [15, 17, 19, 21, 23, 25, 27], [16, 18, 20, 22, 24, 26, 28]]) == 27\n assert candidate(grid = [[1, 100000, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 100000]]) == 99999\n assert candidate(grid = [[100, 90, 80, 70, 60, 50], [95, 85, 75, 65, 55, 45], [92, 82, 72, 62, 52, 42], [89, 79, 69, 59, 49, 39], [86, 76, 66, 56, 46, 36], [83, 73, 63, 53, 43, 33]]) == -3\n assert candidate(grid = [[10, 20, 30, 40], [40, 30, 20, 10], [10, 20, 30, 40], [40, 30, 20, 10]]) == 30\n assert candidate(grid = [[9, 7, 5, 3, 1], [8, 6, 4, 2, 0], [7, 5, 3, 1, 9], [6, 4, 2, 0, 8], [5, 3, 1, 9, 7]]) == 9\n assert candidate(grid = [[5, 1, 2, 3], [4, 6, 1, 5], [7, 1, 8, 9], [3, 2, 6, 4]]) == 8\n assert candidate(grid = [[5, 15, 25, 35, 45], [45, 35, 25, 15, 5], [10, 20, 30, 40, 50], [50, 40, 30, 20, 10], [15, 25, 35, 45, 55]]) == 50\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1000], [1, 1, 1, 1000, 1], [1, 1, 1000, 1, 1], [1, 1000, 1, 1, 1], [1000, 1, 1, 1, 1]]) == 999\n assert candidate(grid = [[9, 8, 7, 6, 5], [4, 3, 2, 1, 0], [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]]) == 15\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [20, 18, 16, 14, 12, 10, 8, 6, 4, 2]]) == 19\n assert candidate(grid = [[9, 8, 7, 6, 5], [4, 3, 2, 1, 0], [0, 1, 2, 3, 4], [5, 6, 7, 8, 9], [9, 8, 7, 6, 5]]) == 9\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == 39\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48, 49, 50]]) == 49\n assert candidate(grid = [[5, 2, 3, 8, 1], [9, 6, 7, 4, 10], [15, 12, 13, 14, 11], [1, 8, 5, 2, 6], [7, 4, 3, 9, 12]]) == 12\n assert candidate(grid = [[50, 40, 30, 20, 10], [5, 15, 25, 35, 45], [60, 70, 80, 90, 100], [10, 20, 30, 40, 50], [15, 25, 35, 45, 55]]) == 95\n assert candidate(grid = [[9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [8, 7, 6, 5, 4, 3, 2, 1, 0, 9], [7, 6, 5, 4, 3, 2, 1, 0, 9, 8], [6, 5, 4, 3, 2, 1, 0, 9, 8, 7]]) == 9\n assert candidate(grid = [[30, 25, 20, 15, 10, 5], [29, 24, 19, 14, 9, 4], [28, 23, 18, 13, 8, 3], [27, 22, 17, 12, 7, 2], [26, 21, 16, 11, 6, 1]]) == -1\n assert candidate(grid = [[1, 3, 5, 7, 9, 11], [2, 4, 6, 8, 10, 12], [3, 6, 9, 12, 15, 18], [4, 8, 12, 16, 20, 24], [5, 10, 15, 20, 25, 30], [6, 12, 18, 24, 30, 36]]) == 35\n assert candidate(grid = [[25, 15, 5, 30, 20], [10, 40, 60, 50, 55], [5, 1, 2, 3, 4], [22, 28, 24, 18, 26], [19, 30, 21, 27, 33]]) == 55\n assert candidate(grid = [[9, 7, 5, 3, 1], [8, 6, 4, 2, 0], [7, 5, 3, 1, -1], [6, 4, 2, 0, -2], [5, 3, 1, -1, -3]]) == -1\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]]) == 19\n assert candidate(grid = [[1, 1, 1, 1000], [1, 1, 1000, 1], [1, 1000, 1, 1], [1000, 1, 1, 1], [1, 1, 1, 1]]) == 999\n assert candidate(grid = [[5, 4, 3, 2, 1, 0], [6, 7, 8, 9, 10, 11], [12, 13, 14, 15, 16, 17], [18, 19, 20, 21, 22, 23], [24, 25, 26, 27, 28, 29], [30, 31, 32, 33, 34, 35]]) == 35\n assert candidate(grid = [[100, 200, 150, 250, 300], [120, 170, 220, 180, 230], [130, 160, 210, 240, 190], [140, 150, 200, 260, 210], [160, 140, 190, 270, 220]]) == 200\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 2, 2, 2, 1], [1, 2, 3, 2, 1], [1, 2, 2, 2, 1], [1, 1, 1, 1, 1]]) == 2\n assert candidate(grid = [[10, 10, 10, 10], [10, 20, 30, 40], [10, 30, 50, 70], [10, 40, 70, 100], [10, 50, 100, 150]]) == 140\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 100], [1, 1, 1, 1, 1, 1, 1, 1, 100, 1], [1, 1, 1, 1, 1, 1, 1, 100, 1, 1], [1, 1, 1, 1, 1, 1, 100, 1, 1, 1], [1, 1, 1, 1, 1, 100, 1, 1, 1, 1], [1, 1, 1, 1, 100, 1, 1, 1, 1, 1], [1, 1, 1, 100, 1, 1, 1, 1, 1, 1], [1, 1, 100, 1, 1, 1, 1, 1, 1, 1], [1, 100, 1, 1, 1, 1, 1, 1, 1, 1], [100, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 99\n assert candidate(grid = [[3, 2, 1, 5, 4], [6, 5, 4, 3, 2], [7, 8, 9, 10, 11], [12, 13, 14, 15, 16], [17, 18, 19, 20, 21]]) == 20\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 3, 4, 5, 6, 7, 8, 9, 10, 1], [3, 4, 5, 6, 7, 8, 9, 10, 1, 2], [4, 5, 6, 7, 8, 9, 10, 1, 2, 3]]) == 9\n assert candidate(grid = [[2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]]) == 9\n assert candidate(grid = [[9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 1, 9, 1, 9, 1, 9, 1, 9]]) == 8\n assert candidate(grid = [[5, 8, 6, 2, 9], [4, 1, 7, 10, 3], [12, 11, 14, 13, 15], [6, 7, 5, 8, 1], [9, 3, 2, 4, 10]]) == 14\n assert candidate(grid = [[100, 200, 150, 300, 100], [50, 250, 350, 500, 400], [450, 550, 600, 650, 700], [350, 250, 300, 350, 400], [400, 450, 500, 550, 600]]) == 650\n assert candidate(grid = [[1, 2, 3], [2, 1, 3], [3, 2, 1], [1, 3, 2], [2, 1, 3], [3, 2, 1]]) == 2\n assert candidate(grid = [[9, 8, 7, 6, 5, 4, 3, 2, 1], [10, 9, 8, 7, 6, 5, 4, 3, 2], [11, 10, 9, 8, 7, 6, 5, 4, 3], [12, 11, 10, 9, 8, 7, 6, 5, 4], [13, 12, 11, 10, 9, 8, 7, 6, 5], [14, 13, 12, 11, 10, 9, 8, 7, 6]]) == 5\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [20, 18, 16, 14, 12, 10, 8, 6, 4, 2], [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]]) == 29\n assert candidate(grid = [[1000, 100, 10, 1], [999, 99, 9, 2], [998, 98, 8, 3], [997, 97, 7, 4], [996, 96, 6, 5], [995, 95, 5, 6], [994, 94, 4, 7], [993, 93, 3, 8], [992, 92, 2, 9], [991, 91, 1, 10]]) == 9\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 7, 9], [9, 7, 5, 3, 1], [1, 2, 3, 4, 5]]) == 8\n assert candidate(grid = [[90, 85, 70, 65, 55, 50, 45], [80, 75, 60, 50, 40, 35, 30], [70, 65, 60, 50, 45, 40, 35], [60, 55, 50, 45, 40, 35, 30], [50, 45, 40, 35, 30, 25, 20]]) == 5\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]]) == 3\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 3, 4, 5, 6], [6, 5, 4, 3, 2], [3, 4, 5, 6, 7]]) == 6\n assert candidate(grid = [[100, 200, 300, 400], [200, 100, 400, 300], [300, 400, 100, 200], [400, 300, 200, 100]]) == 300\n assert candidate(grid = [[5, 15, 25, 35, 45], [10, 20, 30, 40, 50], [5, 10, 15, 20, 25], [45, 40, 35, 30, 25], [50, 45, 40, 35, 30]]) == 45\n assert candidate(grid = [[5, 3, 10, 6, 7], [1, 4, 8, 9, 2], [7, 6, 5, 4, 3], [10, 9, 8, 7, 6], [1, 2, 3, 4, 5]]) == 9\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]]) == 18\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 3, 4, 5, 6, 7, 8, 9, 10, 1], [3, 4, 5, 6, 7, 8, 9, 10, 1, 2], [4, 5, 6, 7, 8, 9, 10, 1, 2, 3], [5, 6, 7, 8, 9, 10, 1, 2, 3, 4]]) == 9\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [20, 19, 18, 17, 16, 15, 14, 13, 12, 11]]) == 19\n assert candidate(grid = [[50, 40, 30, 20, 10], [90, 80, 70, 60, 50], [130, 120, 110, 100, 90], [170, 160, 150, 140, 130], [210, 200, 190, 180, 170]]) == 160\n assert candidate(grid = [[9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9], [2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2]]) == 9\n assert candidate(grid = [[10, 20, 30, 40, 50], [15, 25, 35, 45, 55], [20, 30, 40, 50, 60], [25, 35, 45, 55, 65], [30, 40, 50, 60, 70]]) == 60\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 9, 1, 9, 1, 9, 1, 9, 1, 9], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [9, 1, 9, 1, 9, 1, 9, 1, 9, 1]]) == 8\n assert candidate(grid = [[1, 1000, 2, 1000, 3, 1000, 4, 1000, 5, 1000], [1000, 1, 1000, 2, 1000, 3, 1000, 4, 1000, 5], [5, 1000, 4, 1000, 3, 1000, 2, 1000, 1, 1000]]) == 999\n assert candidate(grid = [[4, 1, 9, 13, 17, 20], [5, 2, 11, 14, 18, 21], [6, 3, 12, 15, 19, 22], [7, 4, 10, 16, 23, 24]]) == 23\n assert candidate(grid = [[1000, 999, 998, 997, 996, 995, 994, 993, 992, 991], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 20, 30, 40, 50, 60, 70, 80, 90, 100], [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]]) == 999\n assert candidate(grid = [[5, 10, 15, 20, 25, 30], [1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [7, 14, 21, 28, 35, 42], [8, 16, 24, 32, 40, 48], [9, 18, 27, 36, 45, 54]]) == 53\n assert candidate(grid = [[23, 18, 15, 25, 16], [20, 5, 9, 11, 21], [30, 3, 14, 22, 24], [28, 27, 26, 29, 31], [19, 17, 13, 8, 7]]) == 28\n assert candidate(grid = [[1, 100, 2, 99, 3, 98, 4, 97, 5, 96], [95, 94, 93, 92, 91, 90, 89, 88, 87, 86], [101, 102, 103, 104, 105, 106, 107, 108, 109, 110], [85, 84, 83, 82, 81, 80, 79, 78, 77, 76], [111, 112, 113, 114, 115, 116, 117, 118, 119, 120]]) == 119\n assert candidate(grid = [[100, 90, 80, 70, 60, 50, 40], [95, 85, 75, 65, 55, 45, 35], [90, 80, 70, 60, 50, 40, 30], [85, 75, 65, 55, 45, 35, 25], [80, 70, 60, 50, 40, 30, 20], [75, 65, 55, 45, 35, 25, 15]]) == -5\n assert candidate(grid = [[25, 17, 11, 22, 5, 3], [2, 18, 14, 23, 7, 16], [8, 20, 9, 21, 12, 10]]) == 21\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().maxScore", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxScore(vector>& grid) {", "container": "Solution", "callable": "maxScore", "parameters": [{"name": "grid", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3149, "task_id": "find-the-minimum-cost-array-permutation", "difficulty": "Hard", "problem_description": "You are given an array nums which is a permutation of [0, 1, 2, ..., n - 1]. The score of any permutation of [0, 1, 2, ..., n - 1] named perm is defined as:\nscore(perm) = |perm[0] - nums[perm[1]]| + |perm[1] - nums[perm[2]]| + ... + |perm[n - 1] - nums[perm[0]]|\nReturn the permutation perm which has the minimum possible score. If multiple permutations exist with this score, return the one that is lexicographically smallest among them.\n \nExample 1:\n\nInput: nums = [1,0,2]\nOutput: [0,1,2]\nExplanation:\n\nThe lexicographically smallest permutation with minimum cost is [0,1,2]. The cost of this permutation is |0 - 0| + |1 - 2| + |2 - 1| = 2.\n\nExample 2:\n\nInput: nums = [0,2,1]\nOutput: [0,2,1]\nExplanation:\n\nThe lexicographically smallest permutation with minimum cost is [0,2,1]. The cost of this permutation is |0 - 1| + |2 - 2| + |1 - 0| = 2.\n\n \nConstraints:\n\n2 <= n == nums.length <= 14\nnums is a permutation of [0, 1, 2, ..., n - 1].\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [0, 7, 6, 8, 5, 9, 4, 10, 3, 11, 2, 12, 1, 13]\n assert candidate(nums = [2, 0, 1, 3]) == [0, 1, 2, 3]\n assert candidate(nums = [0, 2, 1]) == [0, 2, 1]\n assert candidate(nums = [1, 2, 0, 3]) == [0, 2, 3, 1]\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 0, 13, 12, 11, 10, 9, 8]) == [0, 4, 3, 5, 2, 6, 1, 7, 11, 10, 12, 9, 13, 8]\n assert candidate(nums = [3, 1, 2, 0]) == [0, 1, 2, 3]\n assert candidate(nums = [2, 0, 3, 1]) == [0, 1, 3, 2]\n assert candidate(nums = [1, 0, 2]) == [0, 1, 2]\n assert candidate(nums = [3, 2, 0, 1]) == [0, 2, 1, 3]\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]\n assert candidate(nums = [3, 0, 2, 1, 7, 4, 6, 5, 11, 8, 10, 9, 13, 12]) == [0, 1, 2, 3, 5, 6, 7, 9, 10, 11, 13, 12, 8, 4]\n assert candidate(nums = [6, 10, 1, 13, 2, 3, 11, 4, 9, 5, 0, 12, 8, 7]) == [0, 10, 1, 2, 4, 7, 13, 3, 5, 9, 8, 12, 11, 6]\n assert candidate(nums = [11, 0, 9, 1, 8, 2, 7, 3, 6, 4, 5, 12, 13, 10]) == [0, 1, 3, 7, 6, 8, 4, 9, 2, 5, 10, 13, 12, 11]\n assert candidate(nums = [12, 10, 8, 6, 4, 2, 0, 14, 1, 3, 5, 7, 9, 11]) == [0, 6, 2, 5, 4, 10, 1, 8, 11, 13, 7, 3, 9, 12]\n assert candidate(nums = [1, 13, 11, 12, 9, 10, 7, 8, 5, 6, 3, 4, 14, 2, 0]) == [0, 14, 12, 3, 10, 5, 8, 7, 6, 9, 4, 11, 2, 13, 1]\n assert candidate(nums = [11, 7, 8, 5, 6, 2, 4, 10, 3, 0, 9, 1, 12, 13]) == [0, 9, 2, 5, 3, 6, 4, 8, 10, 7, 1, 11, 12, 13]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 11, 12, 13]) == [0, 5, 6, 4, 7, 3, 8, 2, 9, 1, 10, 11, 12, 13]\n assert candidate(nums = [1, 3, 2, 0, 7, 5, 6, 4, 13, 11, 12, 10, 8, 9]) == [0, 3, 2, 5, 6, 7, 12, 10, 11, 9, 13, 8, 4, 1]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 0, 2, 4, 6, 8, 10, 12]) == [0, 7, 2, 8, 4, 9, 11, 5, 10, 12, 13, 6, 3, 1]\n assert candidate(nums = [10, 6, 2, 14, 0, 9, 5, 11, 13, 3, 7, 1, 8, 4, 12]) == [0, 4, 13, 8, 12, 14, 3, 2, 9, 5, 6, 1, 11, 7, 10]\n assert candidate(nums = [13, 11, 9, 7, 5, 3, 1, 12, 10, 8, 6, 4, 2, 0]) == [0, 6, 10, 8, 9, 2, 12, 7, 3, 5, 4, 11, 1, 13]\n assert candidate(nums = [12, 0, 7, 9, 5, 10, 2, 13, 6, 3, 11, 4, 8, 1]) == [0, 1, 13, 7, 2, 6, 4, 9, 3, 11, 10, 5, 8, 12]\n assert candidate(nums = [10, 0, 9, 1, 8, 2, 7, 3, 6, 4, 5, 13, 12, 11]) == [0, 1, 3, 7, 6, 8, 4, 9, 2, 5, 10, 12, 13, 11]\n assert candidate(nums = [6, 12, 4, 8, 0, 10, 13, 2, 3, 9, 7, 1, 5, 11]) == [0, 4, 2, 7, 3, 8, 9, 10, 5, 12, 1, 11, 13, 6]\n assert candidate(nums = [1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12]) == [0, 1, 3, 5, 7, 9, 11, 13, 12, 10, 8, 6, 4, 2]\n assert candidate(nums = [2, 11, 8, 0, 7, 10, 3, 6, 13, 1, 9, 5, 12, 4]) == [0, 3, 6, 7, 4, 11, 1, 9, 10, 5, 13, 12, 8, 2]\n assert candidate(nums = [5, 7, 10, 1, 13, 3, 9, 0, 6, 4, 2, 8, 11, 12]) == [0, 7, 1, 3, 5, 8, 11, 2, 10, 12, 13, 4, 9, 6]\n assert candidate(nums = [1, 3, 2, 0, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12]) == [0, 3, 2, 5, 7, 9, 11, 13, 12, 10, 8, 6, 4, 1]\n assert candidate(nums = [0, 2, 4, 6, 8, 10, 12, 1, 3, 5, 7, 9, 11, 13]) == [0, 7, 10, 5, 9, 11, 12, 13, 6, 3, 8, 4, 2, 1]\n assert candidate(nums = [13, 9, 3, 2, 6, 1, 0, 12, 5, 4, 8, 7, 11, 10]) == [0, 6, 4, 2, 3, 9, 1, 5, 8, 10, 12, 7, 11, 13]\n assert candidate(nums = [12, 8, 5, 0, 7, 2, 9, 13, 1, 10, 4, 6, 11, 3]) == [0, 3, 5, 2, 8, 1, 13, 7, 4, 10, 9, 6, 11, 12]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 0, 3, 5, 7, 9, 11, 13, 1]) == [0, 6, 2, 7, 9, 10, 4, 1, 13, 12, 11, 5, 8, 3]\n assert candidate(nums = [13, 8, 10, 12, 2, 3, 5, 9, 4, 0, 6, 7, 11, 1]) == [0, 9, 7, 11, 12, 3, 5, 6, 10, 2, 4, 8, 1, 13]\n assert candidate(nums = [3, 2, 13, 9, 1, 10, 8, 7, 12, 6, 5, 4, 0, 11]) == [0, 4, 10, 5, 11, 13, 2, 1, 12, 8, 6, 7, 9, 3]\n assert candidate(nums = [10, 13, 3, 5, 9, 1, 6, 11, 0, 8, 7, 12, 4, 2]) == [0, 5, 3, 2, 13, 1, 8, 9, 4, 12, 11, 7, 6, 10]\n assert candidate(nums = [13, 0, 11, 2, 9, 4, 7, 6, 1, 10, 3, 8, 5, 12]) == [0, 1, 8, 6, 7, 11, 2, 3, 10, 9, 4, 5, 12, 13]\n assert candidate(nums = [3, 6, 13, 7, 11, 0, 8, 12, 2, 1, 4, 9, 5, 10]) == [0, 5, 1, 9, 11, 4, 10, 13, 2, 8, 6, 12, 7, 3]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 13, 12, 11]) == [0, 5, 6, 4, 7, 3, 8, 2, 9, 1, 10, 12, 13, 11]\n assert candidate(nums = [4, 0, 8, 2, 12, 6, 10, 3, 1, 7, 13, 5, 11, 9]) == [0, 1, 8, 2, 3, 7, 9, 13, 10, 6, 5, 11, 12, 4]\n assert candidate(nums = [4, 5, 13, 0, 2, 7, 10, 9, 12, 6, 11, 3, 1, 8]) == [0, 3, 11, 10, 6, 9, 7, 5, 1, 12, 8, 13, 2, 4]\n assert candidate(nums = [14, 13, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == [0, 2, 3, 5, 7, 9, 11, 13, 1, 4, 6, 8, 10, 12, 14]\n assert candidate(nums = [0, 3, 7, 2, 5, 13, 8, 10, 4, 6, 11, 9, 1, 12]) == [0, 12, 13, 5, 4, 8, 6, 9, 11, 10, 7, 2, 3, 1]\n assert candidate(nums = [0, 14, 1, 13, 2, 12, 3, 11, 4, 10, 5, 9, 6, 8, 7]) == [0, 2, 4, 8, 13, 3, 6, 12, 5, 10, 9, 11, 7, 14, 1]\n assert candidate(nums = [10, 8, 13, 11, 1, 9, 0, 2, 4, 3, 7, 5, 6, 12]) == [0, 4, 8, 1, 6, 11, 3, 9, 5, 12, 13, 2, 7, 10]\n assert candidate(nums = [5, 0, 11, 3, 8, 10, 7, 4, 2, 12, 9, 13, 1, 6]) == [0, 1, 3, 8, 4, 7, 6, 13, 11, 2, 12, 9, 10, 5]\n assert candidate(nums = [2, 5, 1, 6, 3, 4, 0, 13, 10, 11, 8, 9, 7, 12]) == [0, 6, 10, 8, 11, 9, 12, 13, 7, 3, 4, 5, 1, 2]\n assert candidate(nums = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13]) == [0, 1, 3, 5, 7, 9, 11, 13, 12, 10, 8, 6, 4, 2]\n assert candidate(nums = [4, 7, 11, 1, 13, 2, 8, 0, 10, 9, 12, 3, 6, 5]) == [0, 7, 1, 3, 11, 2, 5, 12, 10, 8, 9, 6, 13, 4]\n assert candidate(nums = [11, 12, 13, 0, 7, 10, 2, 9, 3, 1, 6, 5, 8, 4]) == [0, 3, 8, 12, 1, 9, 7, 4, 13, 2, 6, 10, 5, 11]\n assert candidate(nums = [6, 5, 4, 3, 2, 1, 0, 7, 8, 9, 10, 11, 12, 13]) == [0, 3, 4, 2, 5, 1, 6, 7, 8, 9, 10, 11, 12, 13]\n assert candidate(nums = [13, 11, 9, 7, 5, 3, 1, 0, 2, 4, 6, 8, 10, 12]) == [0, 7, 3, 5, 4, 9, 2, 8, 11, 1, 6, 10, 12, 13]\n assert candidate(nums = [1, 3, 0, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12]) == [0, 2, 3, 5, 7, 9, 11, 13, 12, 10, 8, 6, 4, 1]\n assert candidate(nums = [9, 5, 1, 3, 0, 4, 7, 11, 2, 8, 6, 12, 10, 13]) == [0, 4, 3, 5, 1, 2, 8, 6, 10, 12, 13, 11, 7, 9]\n assert candidate(nums = [13, 0, 5, 2, 10, 14, 1, 3, 4, 7, 6, 9, 12, 8, 11]) == [0, 1, 3, 7, 9, 11, 12, 14, 5, 2, 6, 10, 4, 8, 13]\n assert candidate(nums = [9, 3, 0, 7, 6, 13, 10, 4, 8, 1, 12, 5, 11, 2]) == [0, 2, 13, 5, 11, 12, 10, 6, 4, 7, 3, 1, 9, 8]\n assert candidate(nums = [12, 11, 7, 9, 4, 6, 0, 3, 1, 8, 13, 10, 5, 2]) == [0, 6, 2, 13, 10, 11, 1, 8, 9, 3, 4, 7, 5, 12]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 0, 3, 5, 7, 9, 11, 13, 1]) == [0, 7, 3, 8, 10, 4, 1, 14, 5, 9, 11, 12, 13, 6, 2]\n assert candidate(nums = [13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [0, 7, 6, 8, 5, 9, 4, 10, 3, 11, 2, 12, 1, 13]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 0, 2, 4, 6, 8, 10, 12]) == [0, 7, 2, 8, 4, 9, 11, 5, 10, 12, 13, 6, 3, 1]\n assert candidate(nums = [13, 11, 12, 10, 8, 9, 6, 7, 4, 5, 2, 3, 0, 1]) == [0, 12, 2, 10, 3, 6, 7, 9, 5, 8, 4, 11, 1, 13]\n assert candidate(nums = [8, 10, 12, 14, 0, 2, 4, 6, 1, 3, 5, 7, 9, 11, 13]) == [0, 4, 6, 7, 11, 13, 14, 3, 9, 12, 2, 5, 10, 1, 8]\n assert candidate(nums = [7, 0, 14, 5, 2, 8, 11, 13, 4, 12, 6, 1, 10, 3, 9]) == [0, 1, 11, 6, 10, 12, 9, 14, 2, 4, 8, 5, 3, 13, 7]\n assert candidate(nums = [12, 1, 4, 8, 3, 7, 10, 5, 2, 11, 9, 6, 0, 13]) == [0, 1, 8, 3, 4, 2, 12, 9, 10, 6, 5, 7, 11, 13]\n assert candidate(nums = [1, 4, 2, 13, 7, 9, 12, 5, 3, 11, 6, 0, 8, 10]) == [0, 11, 6, 10, 13, 3, 2, 8, 12, 9, 5, 7, 4, 1]\n assert candidate(nums = [2, 3, 1, 0, 6, 7, 5, 4, 10, 11, 9, 8, 14, 13, 12]) == [0, 3, 7, 11, 13, 14, 12, 9, 10, 8, 5, 6, 4, 1, 2]\n assert candidate(nums = [6, 0, 3, 5, 2, 8, 1, 7, 9, 13, 10, 4, 11, 12]) == [0, 1, 4, 11, 10, 12, 13, 9, 8, 5, 3, 2, 6, 7]\n assert candidate(nums = [2, 4, 1, 6, 12, 0, 3, 9, 10, 13, 5, 8, 7, 11]) == [0, 5, 3, 6, 10, 8, 11, 13, 9, 7, 12, 4, 1, 2]\n assert candidate(nums = [1, 12, 6, 3, 7, 2, 0, 9, 5, 8, 13, 10, 4, 11]) == [0, 6, 2, 3, 5, 8, 9, 7, 4, 12, 10, 11, 13, 1]\n assert candidate(nums = [10, 8, 6, 4, 2, 0, 13, 11, 9, 7, 5, 3, 1, 12]) == [0, 5, 2, 4, 3, 11, 7, 9, 8, 1, 12, 13, 6, 10]\n assert candidate(nums = [9, 7, 13, 5, 1, 0, 6, 2, 12, 3, 11, 4, 8, 10]) == [0, 4, 11, 8, 12, 10, 13, 2, 7, 1, 5, 6, 3, 9]\n assert candidate(nums = [1, 2, 0, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 13]) == [0, 2, 4, 6, 8, 10, 12, 13, 11, 9, 7, 5, 3, 1]\n assert candidate(nums = [4, 5, 6, 7, 0, 1, 2, 3, 12, 13, 14, 8, 9, 10, 11]) == [0, 4, 1, 5, 2, 6, 3, 7, 11, 14, 10, 13, 9, 12, 8]\n assert candidate(nums = [1, 7, 0, 12, 9, 3, 11, 5, 8, 2, 6, 13, 4, 10]) == [0, 2, 9, 4, 12, 3, 5, 7, 8, 10, 13, 11, 6, 1]\n assert candidate(nums = [11, 1, 6, 13, 4, 10, 3, 8, 0, 9, 5, 7, 2, 12]) == [0, 1, 8, 5, 2, 12, 13, 3, 4, 6, 10, 9, 7, 11]\n assert candidate(nums = [7, 8, 9, 10, 11, 12, 13, 0, 1, 2, 3, 4, 5, 6]) == [0, 7, 1, 8, 2, 9, 3, 10, 4, 11, 5, 12, 6, 13]\n assert candidate(nums = [7, 1, 6, 2, 5, 3, 4, 0, 13, 12, 11, 10, 9, 8]) == [0, 1, 3, 5, 4, 6, 2, 7, 11, 10, 12, 9, 13, 8]\n assert candidate(nums = [0, 3, 2, 1, 5, 4, 7, 6, 10, 9, 12, 11, 14, 13]) == [0, 2, 3, 5, 7, 9, 11, 13, 12, 10, 8, 6, 4, 1]\n assert candidate(nums = [10, 11, 12, 13, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 14]) == [0, 4, 7, 11, 1, 5, 9, 13, 14, 3, 8, 12, 2, 6, 10]\n assert candidate(nums = [14, 12, 10, 8, 6, 4, 2, 0, 13, 11, 9, 7, 5, 3, 1]) == [0, 7, 3, 13, 8, 11, 9, 10, 2, 6, 4, 5, 12, 1, 14]\n assert candidate(nums = [3, 0, 1, 2, 7, 4, 5, 6, 11, 8, 9, 10, 13, 12]) == [0, 1, 2, 3, 5, 6, 7, 9, 10, 11, 13, 12, 8, 4]\n assert candidate(nums = [0, 2, 4, 6, 8, 10, 12, 14, 1, 3, 5, 7, 9, 11]) == [0, 8, 3, 9, 5, 10, 12, 6, 11, 13, 7, 4, 2, 1]\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 11, 10, 9, 8, 7, 6, 13, 12]) == [0, 3, 2, 4, 1, 5, 9, 8, 10, 7, 11, 13, 12, 6]\n assert candidate(nums = [4, 6, 8, 10, 12, 14, 0, 2, 1, 3, 5, 7, 9, 11]) == [0, 6, 1, 8, 2, 7, 11, 13, 5, 10, 3, 9, 12, 4]\n assert candidate(nums = [8, 0, 4, 3, 2, 1, 7, 5, 13, 6, 9, 12, 10, 11]) == [0, 1, 3, 4, 2, 5, 7, 6, 9, 10, 12, 11, 13, 8]\n assert candidate(nums = [2, 0, 3, 1, 6, 4, 5, 8, 10, 12, 7, 9, 13, 11]) == [0, 1, 3, 5, 6, 10, 8, 11, 13, 12, 9, 7, 4, 2]\n assert candidate(nums = [11, 9, 8, 7, 13, 12, 0, 3, 2, 1, 6, 5, 4, 10]) == [0, 6, 1, 9, 2, 8, 3, 7, 10, 13, 4, 12, 5, 11]\n assert candidate(nums = [6, 0, 13, 7, 2, 8, 1, 5, 10, 12, 4, 3, 11, 9]) == [0, 1, 4, 10, 8, 5, 7, 3, 11, 12, 9, 13, 2, 6]\n assert candidate(nums = [13, 2, 6, 10, 9, 8, 5, 11, 0, 3, 12, 7, 4, 1]) == [0, 8, 4, 12, 7, 11, 10, 3, 9, 5, 6, 2, 1, 13]\n assert candidate(nums = [0, 2, 4, 6, 8, 10, 12, 14, 1, 3, 5, 7, 9, 11, 13]) == [0, 8, 3, 9, 5, 10, 12, 6, 11, 13, 14, 7, 4, 2, 1]\n assert candidate(nums = [1, 5, 3, 7, 9, 2, 8, 0, 6, 4, 13, 11, 10, 12]) == [0, 7, 3, 2, 5, 8, 4, 9, 11, 12, 13, 10, 6, 1]\n assert candidate(nums = [4, 10, 6, 2, 0, 7, 1, 8, 11, 5, 3, 9, 13, 12]) == [0, 4, 2, 3, 10, 1, 6, 9, 11, 13, 12, 8, 7, 5]\n assert candidate(nums = [1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 14]) == [0, 1, 3, 5, 7, 9, 11, 13, 14, 12, 10, 8, 6, 4, 2]\n assert candidate(nums = [8, 6, 4, 2, 0, 1, 3, 5, 7, 9, 11, 13, 10, 12]) == [0, 4, 2, 3, 6, 1, 5, 7, 8, 9, 12, 13, 11, 10]\n assert candidate(nums = [5, 3, 4, 1, 2, 0, 13, 11, 12, 10, 8, 9, 6, 7]) == [0, 3, 1, 4, 2, 5, 12, 8, 10, 9, 11, 7, 13, 6]\n assert candidate(nums = [12, 10, 8, 6, 4, 2, 0, 13, 11, 9, 7, 5, 3, 1]) == [0, 5, 4, 11, 8, 2, 13, 7, 10, 9, 1, 6, 3, 12]\n assert candidate(nums = [5, 4, 10, 11, 7, 12, 6, 0, 13, 2, 1, 8, 9, 3]) == [0, 7, 4, 1, 10, 2, 9, 11, 3, 13, 8, 12, 5, 6]\n assert candidate(nums = [6, 4, 2, 0, 1, 3, 8, 5, 7, 10, 12, 9, 14, 11]) == [0, 2, 4, 1, 3, 5, 7, 8, 11, 13, 12, 10, 9, 6]\n assert candidate(nums = [0, 11, 1, 9, 3, 5, 2, 7, 12, 4, 10, 6, 8, 13]) == [0, 2, 4, 5, 9, 3, 6, 7, 11, 8, 12, 13, 10, 1]\n assert candidate(nums = [2, 9, 13, 0, 6, 11, 7, 4, 12, 5, 8, 3, 10, 1]) == [0, 3, 7, 6, 4, 11, 5, 9, 1, 13, 8, 10, 12, 2]\n assert candidate(nums = [7, 0, 1, 2, 3, 4, 5, 6, 14, 13, 12, 11, 8, 9, 10]) == [0, 1, 2, 3, 4, 5, 6, 7, 12, 9, 13, 10, 11, 14, 8]\n assert candidate(nums = [2, 0, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 13]) == [0, 1, 2, 4, 6, 8, 10, 12, 13, 11, 9, 7, 5, 3]\n assert candidate(nums = [6, 0, 13, 1, 11, 5, 3, 4, 9, 7, 2, 12, 10, 8]) == [0, 1, 3, 5, 7, 9, 8, 13, 2, 10, 12, 11, 4, 6]\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 7, 6, 9, 8, 11, 10, 13, 12]) == [0, 3, 2, 4, 1, 5, 7, 9, 11, 13, 12, 10, 8, 6]\n assert candidate(nums = [13, 1, 5, 2, 9, 6, 3, 7, 11, 8, 10, 0, 12, 4]) == [0, 1, 3, 6, 5, 2, 11, 8, 7, 9, 10, 4, 13, 12]\n assert candidate(nums = [12, 13, 6, 10, 1, 9, 3, 5, 7, 11, 2, 4, 8, 0]) == [0, 13, 1, 4, 6, 2, 10, 3, 11, 9, 5, 7, 8, 12]\n assert candidate(nums = [13, 0, 1, 12, 2, 11, 3, 10, 4, 9, 5, 8, 6, 7]) == [0, 1, 2, 4, 6, 12, 3, 8, 9, 11, 5, 10, 7, 13]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 13, 12, 11, 0]) == [0, 5, 6, 4, 7, 3, 8, 2, 9, 1, 13, 10, 12, 11]\n assert candidate(nums = [0, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1]\n assert candidate(nums = [9, 4, 6, 0, 7, 5, 3, 2, 1, 8]) == [0, 3, 6, 2, 7, 4, 5, 1, 8, 9]\n assert candidate(nums = [1, 12, 7, 4, 10, 6, 13, 3, 5, 8, 2, 11, 0, 9]) == [0, 12, 1, 10, 11, 4, 3, 7, 5, 8, 9, 13, 6, 2]\n assert candidate(nums = [3, 12, 1, 5, 11, 8, 0, 13, 6, 10, 4, 7, 9, 2]) == [0, 2, 13, 7, 11, 4, 10, 9, 12, 1, 6, 8, 5, 3]\n assert candidate(nums = [12, 0, 1, 13, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2]) == [0, 1, 2, 13, 3, 8, 7, 9, 6, 10, 5, 11, 4, 12]\n assert candidate(nums = [13, 0, 14, 1, 12, 2, 11, 3, 10, 4, 9, 5, 8, 6, 7]) == [0, 1, 3, 7, 12, 4, 9, 10, 8, 14, 2, 5, 11, 6, 13]\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().findPermutation", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector findPermutation(vector& nums) {", "container": "Solution", "callable": "findPermutation", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3151, "task_id": "special-array-i", "difficulty": "Easy", "problem_description": "An array is considered special if the parity of every pair of adjacent elements is different. In other words, one element in each pair must be even, and the other must be odd.\nYou are given an array of integers nums. Return true if nums is a special array, otherwise, return false.\n \nExample 1:\n\nInput: nums = [1]\nOutput: true\nExplanation:\nThere is only one element. So the answer is true.\n\nExample 2:\n\nInput: nums = [2,1,4]\nOutput: true\nExplanation:\nThere is only two pairs: (2,1) and (1,4), and both of them contain numbers with different parity. So the answer is true.\n\nExample 3:\n\nInput: nums = [4,3,1,6]\nOutput: false\nExplanation:\nnums[1] and nums[2] are both odd. So the answer is false.\n\n \nConstraints:\n\n1 <= nums.length <= 100\n1 <= nums[i] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [100, 99, 100]) == True\n assert candidate(nums = [5, 2, 7, 8]) == True\n assert candidate(nums = [20, 30, 40, 50, 60]) == False\n assert candidate(nums = [3, 8, 3, 8, 3, 8]) == True\n assert candidate(nums = [2, 3, 4, 5]) == True\n assert candidate(nums = [10, 11, 12, 13]) == True\n assert candidate(nums = [3, 6, 3, 6]) == True\n assert candidate(nums = [2, 4, 6, 8, 10]) == False\n assert candidate(nums = [1, 3, 5, 7, 9]) == False\n assert candidate(nums = [1]) == True\n assert candidate(nums = [2, 3]) == True\n assert candidate(nums = [100]) == True\n assert candidate(nums = [10, 11, 10, 11]) == True\n assert candidate(nums = [1, 2, 3, 4, 5]) == True\n assert candidate(nums = [4, 3, 1, 6]) == False\n assert candidate(nums = [50, 51, 50, 51, 50]) == True\n assert candidate(nums = [15, 14, 13, 12, 11]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6]) == True\n assert candidate(nums = [2, 1, 4]) == True\n assert candidate(nums = [20, 19, 18, 17, 16]) == True\n assert candidate(nums = [5, 8, 7, 2]) == True\n assert candidate(nums = [15]) == True\n assert candidate(nums = [50, 51, 50, 51]) == True\n assert candidate(nums = [2, 3, 2, 3]) == True\n assert candidate(nums = [1, 2]) == True\n assert candidate(nums = [1, 3, 5, 7]) == False\n assert candidate(nums = [98, 99]) == True\n assert candidate(nums = [100, 99, 100, 99]) == True\n assert candidate(nums = [5]) == True\n assert candidate(nums = [2, 4, 6, 8]) == False\n assert candidate(nums = [7, 2, 7, 2, 7, 2, 7, 2, 7, 2, 7, 2, 7, 2, 7, 2, 7, 2, 7, 2, 7, 2, 7, 2, 7, 2, 7, 2, 7, 2]) == True\n assert candidate(nums = [101, 102, 103, 104, 105, 106, 107, 108, 109, 110]) == True\n assert candidate(nums = [37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48]) == True\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70]) == True\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(nums = [7, 2, 9, 4, 11, 6, 13, 8, 15, 10]) == True\n assert candidate(nums = [60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50]) == True\n assert candidate(nums = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5]) == False\n assert candidate(nums = [89, 90, 91, 92, 93, 94, 95, 96, 97, 98]) == True\n assert candidate(nums = [89, 90, 89, 90, 89, 90, 89, 90, 89, 90]) == True\n assert candidate(nums = [25, 50, 25, 50, 25, 50, 25, 50, 25]) == True\n assert candidate(nums = [99, 2, 97, 4, 95, 6, 93, 8, 91, 10]) == True\n assert candidate(nums = [61, 62, 63, 64, 65, 66, 67, 68, 69, 70]) == True\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 6]) == False\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == True\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == True\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225]) == True\n assert candidate(nums = [10, 1, 20, 3, 40, 5, 60, 7, 80, 9]) == True\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == False\n assert candidate(nums = [10, 20, 30, 40, 50, 51, 52, 53, 54, 55]) == False\n assert candidate(nums = [1, 4, 3, 8, 5, 12, 7, 16, 9, 20]) == True\n assert candidate(nums = [2, 1, 4, 3, 6, 5, 8, 7]) == True\n assert candidate(nums = [10, 20, 30, 40, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65]) == False\n assert candidate(nums = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == True\n assert candidate(nums = [13, 24, 35, 46, 57, 68, 79, 80, 91, 102]) == True\n assert candidate(nums = [25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]) == True\n assert candidate(nums = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) == True\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == False\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == True\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == False\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == False\n assert candidate(nums = [99, 100, 101, 102, 103, 104, 105]) == True\n assert candidate(nums = [97, 98, 99, 100, 101, 102, 103, 104, 105, 106]) == True\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == True\n assert candidate(nums = [45, 46, 47, 48, 49, 50, 51]) == True\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23]) == False\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]) == False\n assert candidate(nums = [2, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == True\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == True\n assert candidate(nums = [61, 62, 63, 64, 65, 66, 67, 68, 69]) == True\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11]) == True\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 0]) == True\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16]) == False\n assert candidate(nums = [83, 84, 85, 86, 87, 88, 89, 90, 91, 92]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == True\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010]) == True\n assert candidate(nums = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59]) == True\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81]) == True\n assert candidate(nums = [25, 26, 27, 28, 29, 30]) == True\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == True\n assert candidate(nums = [101, 100, 99, 98, 97, 96, 95, 94, 93, 92]) == True\n assert candidate(nums = [5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5]) == True\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41]) == True\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22]) == False\n assert candidate(nums = [100, 99, 100, 99, 100, 99]) == True\n assert candidate(nums = [23, 22, 25, 24, 27, 26, 29, 28, 31, 30]) == True\n assert candidate(nums = [31, 22, 33, 24, 35, 26, 37, 28, 39, 20]) == True\n assert candidate(nums = [100, 99, 98, 97, 96]) == True\n assert candidate(nums = [47, 48, 49, 50, 51, 52, 53, 54, 55, 56]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == True\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(nums = [5, 4, 3, 2, 1]) == True\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == True\n assert candidate(nums = [97, 98, 95, 96, 93, 94]) == True\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == True\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 100]) == True\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15]) == False\n assert candidate(nums = [99, 100, 99, 100, 99, 100, 99, 100, 99, 100]) == True\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31]) == True\n assert candidate(nums = [100, 99, 100, 99, 100, 99, 100, 99, 100, 99, 100, 99, 100, 99]) == True\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70]) == True\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14]) == False\n assert candidate(nums = [49, 50, 49, 50, 49, 50, 49, 50, 49, 50]) == True\n assert candidate(nums = [42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30]) == True\n assert candidate(nums = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]) == True\n assert candidate(nums = [99, 2, 99, 2, 99, 2, 99, 2, 99, 2]) == True\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == True\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13]) == False\n assert candidate(nums = [97, 98, 99, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == True\n assert candidate(nums = [3, 2, 3, 2, 3, 2, 3, 2, 3, 2]) == True\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == False\n assert candidate(nums = [51, 52, 51, 52, 51, 52, 51, 52, 51, 52, 51, 52]) == True\n assert candidate(nums = [5, 8, 3, 12, 7, 14, 9, 16, 11, 18]) == True\n assert candidate(nums = [7, 8, 7, 8, 7, 8, 7]) == True\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]) == False\n assert candidate(nums = [97, 98, 99, 100, 1, 2, 3, 4]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6]) == True\n assert candidate(nums = [82, 81, 82, 83, 82, 81, 82, 83, 82, 81]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == False\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == True\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == False\n assert candidate(nums = [100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1]) == True\n assert candidate(nums = [31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == True\n assert candidate(nums = [50, 51, 50, 51, 50, 51, 50, 51, 50, 51, 50, 51, 50, 51, 50, 51, 50, 51]) == True\n assert candidate(nums = [5, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == True\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().isArraySpecial", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool isArraySpecial(vector& nums) {", "container": "Solution", "callable": "isArraySpecial", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3152, "task_id": "special-array-ii", "difficulty": "Medium", "problem_description": "An array is considered special if every pair of its adjacent elements contains two numbers with different parity.\nYou are given an array of integer nums and a 2D integer matrix queries, where for queries[i] = [fromi, toi] your task is to check that subarray nums[fromi..toi] is special or not.\nReturn an array of booleans answer such that answer[i] is true if nums[fromi..toi] is special.\n \nExample 1:\n\nInput: nums = [3,4,1,2,6], queries = [[0,4]]\nOutput: [false]\nExplanation:\nThe subarray is [3,4,1,2,6]. 2 and 6 are both even.\n\nExample 2:\n\nInput: nums = [4,3,1,6], queries = [[0,2],[2,3]]\nOutput: [false,true]\nExplanation:\n\nThe subarray is [4,3,1]. 3 and 1 are both odd. So the answer to this query is false.\nThe subarray is [1,6]. There is only one pair: (1,6) and it contains numbers with different parity. So the answer to this query is true.\n\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 105\n1 <= queries.length <= 105\nqueries[i].length == 2\n0 <= queries[i][0] <= queries[i][1] <= nums.length - 1\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [2, 2, 2, 2, 2],queries = [[0, 4]]) == [False]\n assert candidate(nums = [2, 4, 6, 8, 10],queries = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [0, 4]]) == [True, True, True, True, True, False]\n assert candidate(nums = [1, 3, 5, 7, 9],queries = [[0, 1], [1, 2], [2, 3], [3, 4]]) == [False, False, False, False]\n assert candidate(nums = [1, 3, 5, 7, 9],queries = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [0, 4]]) == [True, True, True, True, True, False]\n assert candidate(nums = [1, 2, 3, 4, 5],queries = [[0, 1], [1, 2], [2, 3], [3, 4]]) == [True, True, True, True]\n assert candidate(nums = [1, 2, 3, 4, 5],queries = [[0, 0], [1, 2], [2, 4]]) == [True, True, True]\n assert candidate(nums = [3, 4, 1, 2, 6],queries = [[0, 4]]) == [False]\n assert candidate(nums = [1, 3, 5, 7, 9],queries = [[0, 4]]) == [False]\n assert candidate(nums = [4, 3, 1, 6],queries = [[0, 2], [2, 3]]) == [False, True]\n assert candidate(nums = [10, 15, 20, 25, 30],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [0, 4]]) == [True, True, True, True, True]\n assert candidate(nums = [2, 2, 2, 2],queries = [[0, 1], [1, 2], [2, 3]]) == [False, False, False]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [True, True, True, True, True]\n assert candidate(nums = [2, 4, 6, 8, 10],queries = [[0, 4]]) == [False]\n assert candidate(nums = [1, 2, 3, 4, 5, 6],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == [True, True, True, True, True]\n assert candidate(nums = [1, 2, 1, 2, 1],queries = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [0, 4]]) == [True, True, True, True, True, True]\n assert candidate(nums = [10, 21, 32, 43, 54, 65, 76, 87, 98, 109, 120, 131, 142, 153, 164, 175, 186, 197, 208, 219],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15]]) == [True, True, True, True, True]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],queries = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15], [16, 17], [18, 19]]) == [False, False, False, False, False, False, False, False, False, False]\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11],queries = [[0, 9], [2, 7], [4, 5], [1, 8], [3, 6]]) == [False, True, True, True, True]\n assert candidate(nums = [42, 23, 17, 34, 19, 28, 39, 44, 27, 56, 65, 74, 83, 92, 101],queries = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [0, 7], [8, 14]]) == [False, False, True, True, True, True, True, False, True]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],queries = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == [True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == [False, False, False, False, False, False, False, False, False, False]\n assert candidate(nums = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],queries = [[0, 13], [2, 5], [6, 8], [10, 12]]) == [True, True, True, True]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115],queries = [[0, 15], [0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [7, 7], [0, 0], [15, 15]]) == [True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1],queries = [[0, 4], [5, 9], [10, 14], [2, 8]]) == [False, False, False, False]\n assert candidate(nums = [2, 3, 5, 8, 10, 13, 17, 20, 22, 25],queries = [[0, 9], [1, 3], [5, 7], [8, 9]]) == [False, False, False, True]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],queries = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15], [0, 15], [1, 4], [2, 9]]) == [False, False, False, False, False, False, False, False, False, False, False]\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],queries = [[0, 5], [5, 10], [10, 15], [15, 20], [20, 25], [0, 29]]) == [True, True, True, True, True, True]\n assert candidate(nums = [8, 10, 12, 14, 16, 18, 20, 22, 24],queries = [[0, 1], [2, 3], [4, 5], [6, 7], [0, 8], [1, 6]]) == [False, False, False, False, False, False]\n assert candidate(nums = [10, 11, 10, 11, 10, 11, 10, 11, 10, 11],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [True, True, True, True, True]\n assert candidate(nums = [2, 5, 8, 3, 6, 7, 9, 10],queries = [[0, 3], [1, 5], [4, 7], [0, 7]]) == [True, True, False, False]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [False, False, False, False, False]\n assert candidate(nums = [100000, 99999, 100000, 99999, 100000, 99999, 100000, 99999, 100000, 99999],queries = [[0, 4], [5, 9], [0, 9]]) == [True, True, True]\n assert candidate(nums = [2, 4, 6, 8, 10, 1, 3, 5, 7, 9],queries = [[0, 9], [0, 2], [4, 5], [6, 8]]) == [False, False, True, False]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 9], [2, 7], [4, 5], [1, 8]]) == [True, True, True, True]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(nums = [2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14]]) == [False, False, False, False, False, False]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15]]) == [True, True, True, True, True]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10], [0, 1], [1, 0], [18, 19], [0, 19], [1, 18]]) == [False, False, False, False, False, False, False, False, False, False, False, True, False, False, False]\n assert candidate(nums = [2, 3, 5, 7, 11, 13],queries = [[0, 5], [1, 4], [2, 3], [0, 1], [3, 5]]) == [False, False, False, True, False]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],queries = [[0, 19], [5, 15], [10, 14], [0, 0], [19, 19]]) == [True, True, True, True, True]\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 6, 6, 7, 8, 8, 9, 10, 10, 11, 12, 12, 13, 14],queries = [[0, 19], [1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15], [16, 17], [18, 19]]) == [False, False, True, True, False, True, True, False, True, True, True, True, False, True, True, False, True, True, False, True]\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 8], [1, 7], [2, 6], [3, 5], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8]]) == [True, True, True, True, True, True, True, True, True]\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114],queries = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8]]) == [True, True, True, True, True, True, True]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],queries = [[0, 29], [1, 28], [2, 27], [3, 26], [4, 25], [5, 24], [6, 23], [7, 22], [8, 21], [9, 20]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32],queries = [[0, 15], [1, 14], [2, 13], [3, 12], [4, 11], [5, 10], [6, 9], [7, 8], [0, 7], [7, 14], [1, 6], [8, 15]]) == [False, False, False, False, False, False, False, False, False, False, False, False]\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],queries = [[0, 21], [1, 20], [2, 19], [3, 18], [4, 17]]) == [False, False, False, False, False]\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],queries = [[0, 29], [1, 28], [2, 27], [3, 26], [4, 25]]) == [True, True, True, True, True]\n assert candidate(nums = [99999, 1, 99998, 2, 99997, 3, 99996, 4, 99995, 5],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 4], [5, 9]]) == [False, False, False, False, False, False, False]\n assert candidate(nums = [2, 3, 4, 3, 2, 3, 4, 3, 2, 3],queries = [[0, 9], [2, 7], [4, 5], [1, 8]]) == [True, True, True, True]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],queries = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [0, 7], [8, 14]]) == [True, True, True, True, True, True, True, True, True]\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991],queries = [[0, 9], [1, 8], [3, 7], [5, 9]]) == [True, True, True, True]\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],queries = [[0, 29], [1, 28], [2, 27], [3, 26], [4, 25], [5, 24], [6, 23], [7, 22], [8, 21], [9, 20]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == [False, False, False, False, False, False, False, False, False, False]\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],queries = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9]]) == [False, False, False, False, False, False]\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15]]) == [True, True, True, True, True]\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19],queries = [[0, 1], [1, 2], [0, 3], [3, 7], [0, 7]]) == [True, False, False, False, False]\n assert candidate(nums = [100, 201, 102, 203, 104, 205, 106, 207, 108, 209, 110],queries = [[0, 10], [1, 9], [2, 8], [3, 7], [4, 6], [0, 1], [5, 5]]) == [True, True, True, True, True, True, True]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],queries = [[0, 29], [1, 28], [2, 27], [3, 26], [4, 25]]) == [True, True, True, True, True]\n assert candidate(nums = [10, 11, 12, 13, 14, 15, 16, 17],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [0, 7]]) == [True, True, True, True, True, True, True, True]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9]]) == [False, False, False, False, False, False, False, False, False, False]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9]]) == [False, False, False, False, False, False, False, False, False, False]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],queries = [[0, 9], [1, 3], [2, 5], [3, 7], [4, 9]]) == [False, False, False, False, False]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],queries = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [0, 9]]) == [False, False, False, False, False, False]\n assert candidate(nums = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195],queries = [[0, 9], [1, 3], [4, 7], [6, 8]]) == [False, False, True, True]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [False, False, False, False, False]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],queries = [[0, 3], [4, 7], [5, 9], [1, 8]]) == [False, False, False, False]\n assert candidate(nums = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22],queries = [[0, 9], [5, 14], [10, 19], [0, 19], [1, 18]]) == [True, True, True, True, True]\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],queries = [[0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9]]) == [False, False, False, False, False, False, False, False]\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010],queries = [[0, 9], [2, 7], [4, 5], [1, 8]]) == [True, True, True, True]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],queries = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8]]) == [True, True, True, True, True, True, True]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],queries = [[0, 9], [9, 18], [0, 18], [8, 10], [1, 17], [2, 16], [3, 15], [4, 14], [5, 13], [6, 12], [7, 11], [0, 1], [1, 0], [17, 18], [0, 18]]) == [True, True, True, True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(nums = [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],queries = [[0, 29], [10, 29], [1, 28], [2, 27], [3, 26]]) == [True, True, True, True, True]\n assert candidate(nums = [101, 102, 103, 104, 105, 106, 107, 108, 109, 110],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 5], [5, 9]]) == [True, True, True, True, True, True, True]\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2],queries = [[0, 4], [1, 5], [2, 6], [3, 7], [4, 8], [5, 9]]) == [True, True, True, True, True, True]\n assert candidate(nums = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == [True, True, True, True, True, True, True, True, True]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],queries = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == [False, False, False, False, False, False, False, False, False]\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],queries = [[0, 2], [2, 4], [4, 6], [6, 8], [8, 10], [10, 12], [12, 14]]) == [False, False, False, False, False, False, False]\n assert candidate(nums = [1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, 5, 6, 7],queries = [[0, 2], [2, 4], [4, 6], [6, 8], [8, 10], [10, 12], [12, 14]]) == [True, True, True, True, True, True, True]\n assert candidate(nums = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3],queries = [[0, 9], [5, 14], [10, 19], [0, 19], [1, 18]]) == [True, True, True, True, True]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],queries = [[0, 3], [4, 7], [5, 9], [1, 8]]) == [False, False, False, False]\n"}, "metadata": {"canonical_parameter_names": ["nums", "queries"], "leetcode_dataset_entry_point": "Solution().isArraySpecial", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector isArraySpecial(vector& nums, vector>& queries) {", "container": "Solution", "callable": "isArraySpecial", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "queries", "type": "vector>&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3153, "task_id": "sum-of-digit-differences-of-all-pairs", "difficulty": "Medium", "problem_description": "You are given an array nums consisting of positive integers where all integers have the same number of digits.\nThe digit difference between two integers is the count of different digits that are in the same position in the two integers.\nReturn the sum of the digit differences between all pairs of integers in nums.\n \nExample 1:\n\nInput: nums = [13,23,12]\nOutput: 4\nExplanation:\nWe have the following:\n- The digit difference between 13 and 23 is 1.\n- The digit difference between 13 and 12 is 1.\n- The digit difference between 23 and 12 is 2.\nSo the total sum of digit differences between all pairs of integers is 1 + 1 + 2 = 4.\n\nExample 2:\n\nInput: nums = [10,10,10,10]\nOutput: 0\nExplanation:\nAll the integers in the array are the same. So the total sum of digit differences between all pairs of integers will be 0.\n\n \nConstraints:\n\n2 <= nums.length <= 105\n1 <= nums[i] < 109\nAll integers in nums have the same number of digits.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [12345, 54321, 13245]) == 11\n assert candidate(nums = [10, 10, 10, 10]) == 0\n assert candidate(nums = [123, 234, 345]) == 9\n assert candidate(nums = [123, 456, 789]) == 9\n assert candidate(nums = [987, 876, 765, 654]) == 18\n assert candidate(nums = [99999, 99999, 99999]) == 0\n assert candidate(nums = [13, 23, 12]) == 4\n assert candidate(nums = [123, 321, 213]) == 7\n assert candidate(nums = [987, 876, 765, 654, 543]) == 30\n assert candidate(nums = [111, 222, 333, 444]) == 18\n assert candidate(nums = [5678, 6789, 7890]) == 12\n assert candidate(nums = [123456, 234561, 345612, 456123, 561234, 612345]) == 90\n assert candidate(nums = [191919191, 282828282, 373737373, 464646464, 555555555]) == 90\n assert candidate(nums = [123, 456, 789, 987, 654, 321, 111, 222, 333, 444, 555, 666, 777, 888, 999]) == 294\n assert candidate(nums = [56789, 98765, 58679, 67985]) == 24\n assert candidate(nums = [1234, 2345, 3456, 4567, 5678]) == 40\n assert candidate(nums = [987654, 876543, 765432, 654321, 543210, 432109, 321098, 210987, 109876]) == 216\n assert candidate(nums = [1000001, 2000002, 3000003, 4000004, 5000005, 6000006, 7000007]) == 42\n assert candidate(nums = [55555, 55554, 55545, 55455, 54555, 45555, 55555, 55555, 55555, 55555, 55555, 55555]) == 55\n assert candidate(nums = [101010, 202020, 303030, 404040, 505050, 606060, 707070, 808080, 909090]) == 108\n assert candidate(nums = [999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111]) == 324\n assert candidate(nums = [121212, 212121, 121211, 212112, 112121, 221212, 122121, 211221]) == 95\n assert candidate(nums = [56789, 56788, 56787, 56786, 56785]) == 10\n assert candidate(nums = [1999999, 2999998, 3999997, 4999996, 5999995, 6999994, 7999993, 8999992, 9999991]) == 72\n assert candidate(nums = [1234567, 7654321, 1357924, 8642035, 9876543, 3210987]) == 96\n assert candidate(nums = [123456789, 111222333, 222333444, 333444555, 444555666]) == 85\n assert candidate(nums = [112233, 223344, 334455, 445566, 556677, 667788, 778899, 889900, 990011]) == 216\n assert candidate(nums = [55555, 54445, 53335, 52225, 51115, 50005, 49995, 48885, 47775, 46665]) == 159\n assert candidate(nums = [123456789, 987654321, 111222333, 333222111]) == 46\n assert candidate(nums = [123123123, 234234234, 345345345, 456456456, 567567567, 678678678, 789789789, 890890890, 901901901]) == 324\n assert candidate(nums = [101010, 202020, 303030, 404040, 505050]) == 30\n assert candidate(nums = [1001, 1100, 1110, 1111, 1011, 1101]) == 25\n assert candidate(nums = [100000000, 99999999, 88888888, 77777777, 66666666, 55555555]) == 125\n assert candidate(nums = [100000000, 200000000, 300000000, 400000000, 500000000]) == 10\n assert candidate(nums = [987654321, 876543219, 765432198, 654321987, 543219876, 432198765, 321987654, 219876543, 198765432]) == 324\n assert candidate(nums = [999999999, 111111111, 222222222, 333333333, 444444444]) == 90\n assert candidate(nums = [900000, 899999, 889998, 879997, 869996, 859995, 849994, 839993, 829992]) == 104\n assert candidate(nums = [11122, 22233, 33344, 44455, 55566]) == 50\n assert candidate(nums = [111111111, 222222222, 333333333, 444444444, 555555555, 666666666, 777777777, 888888888, 999999999, 123456789]) == 396\n assert candidate(nums = [555555555, 444444444, 333333333, 222222222, 111111111]) == 90\n assert candidate(nums = [123123, 321321, 213213, 132132, 312312, 231231, 123123]) == 96\n assert candidate(nums = [98765, 87654, 76543, 65432, 54321, 43210, 32109, 21098, 10987]) == 180\n assert candidate(nums = [123, 321, 213, 132, 231, 312, 456, 654, 564, 546, 465, 645, 789, 987, 897, 879, 798, 978]) == 432\n assert candidate(nums = [11112222, 22223333, 33334444, 44445555]) == 48\n assert candidate(nums = [199991, 299992, 399993, 499994, 599995, 699996, 799997, 899998, 999999]) == 72\n assert candidate(nums = [123456, 234567, 345678, 456789, 567890]) == 60\n assert candidate(nums = [123123, 234234, 345345, 456456, 567567, 678678, 789789, 890890, 901901]) == 216\n assert candidate(nums = [9876543, 8765432, 7654321, 6543210, 5432109, 4321098, 3210987, 2109876, 1098765]) == 252\n assert candidate(nums = [987654, 876543, 765432, 654321, 543210, 432109, 321098, 210987, 109876]) == 216\n assert candidate(nums = [987654, 876543, 765432, 654321, 543210, 432109, 321098, 210987]) == 168\n assert candidate(nums = [989898989, 878787878, 767676767, 656565656, 545454545, 434343434, 323232323, 212121212, 101010101]) == 324\n assert candidate(nums = [123123123, 234234234, 345345345, 456456456, 567567567]) == 90\n assert candidate(nums = [1234567, 2345671, 3456712, 4567123, 5671234, 6712345, 7123456, 1234567]) == 189\n assert candidate(nums = [987654321, 123456789, 876543219, 918273645]) == 50\n assert candidate(nums = [111222333, 222333444, 333444555, 444555666, 555666777]) == 90\n assert candidate(nums = [1212121, 2323232, 3434343, 4545454, 5656565, 6767676, 7878787, 8989898, 9090909]) == 252\n assert candidate(nums = [999999, 888888, 777777, 666666, 555555, 444444]) == 90\n assert candidate(nums = [5555555, 5555554, 5555553, 5555552, 5555551, 5555550]) == 15\n assert candidate(nums = [101010101, 202020202, 303030303, 404040404, 505050505]) == 50\n assert candidate(nums = [1234, 2345, 3456, 4567, 5678, 6789]) == 60\n assert candidate(nums = [1010, 1111, 1212, 1313, 1414, 1515, 1616, 1717, 1818, 1919]) == 90\n assert candidate(nums = [1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000]) == 36\n assert candidate(nums = [100000001, 200000002, 300000003, 400000004, 500000005, 600000006, 700000007, 800000008, 900000009]) == 72\n assert candidate(nums = [123, 234, 345, 456, 567, 678, 789, 890, 901, 123, 234, 345, 456, 567, 678, 789, 890, 901]) == 432\n assert candidate(nums = [1001, 1010, 1100, 1110, 10011]) == 22\n assert candidate(nums = [987654321, 123456789, 876543219, 912345678]) == 50\n assert candidate(nums = [918273645, 827364591, 736459182, 645918273, 591827364]) == 90\n assert candidate(nums = [2345678, 3456789, 4567890, 5678901, 6789012, 7890123, 8901234]) == 147\n assert candidate(nums = [121212121, 212121212, 323232323, 434343434, 545454545, 656565656, 767676767, 878787878, 989898989]) == 320\n assert candidate(nums = [1010101, 2020202, 3030303, 4040404, 5050505, 6060606, 7070707, 8080808, 9090909]) == 144\n assert candidate(nums = [111111, 222222, 333333, 444444, 555555, 666666, 777777]) == 126\n assert candidate(nums = [1122334455, 2233445566, 3344556677, 4455667788, 5566778899, 6677889911]) == 150\n assert candidate(nums = [987654321, 987654320, 987654319, 987654318, 987654317, 987654316, 987654315, 987654314, 987654313]) == 50\n assert candidate(nums = [123456789, 987654321, 135792468, 864208642, 246802468]) == 83\n assert candidate(nums = [11111111, 22222222, 33333333, 44444444, 55555555, 66666666, 77777777, 88888888, 99999999]) == 288\n assert candidate(nums = [121212121, 212121212, 323232323, 434343434, 545454545]) == 86\n assert candidate(nums = [987654321, 876543210, 765432109, 654321098, 543210987, 432109876, 321098765, 210987654, 109876543]) == 324\n assert candidate(nums = [1234567, 1234568, 1234569, 1234570, 1234571, 1234572, 1234573, 1234574, 1234575]) == 54\n assert candidate(nums = [101010, 110110, 101101, 111000]) == 18\n assert candidate(nums = [80808, 80807, 80806, 80805, 80804, 80803, 80802]) == 21\n assert candidate(nums = [123456, 654321, 111111, 999999]) == 34\n assert candidate(nums = [223344, 443322, 332244, 224433]) == 30\n assert candidate(nums = [9999, 8888, 7777, 6666, 5555, 4444, 3333, 2222, 1111]) == 144\n assert candidate(nums = [101010101, 202020202, 303030303, 404040404, 505050505, 606060606]) == 75\n assert candidate(nums = [999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111, 0]) == 405\n assert candidate(nums = [112233, 445566, 778899, 332211, 665544]) == 56\n assert candidate(nums = [9876543, 8765432, 7654321, 6543210, 5432109, 4321098, 3210987, 2109876, 1098765]) == 252\n assert candidate(nums = [123456789, 123456788, 123456787, 123456786, 123456785, 123456784, 123456783]) == 21\n assert candidate(nums = [555555, 555555, 555555, 555555, 555555, 555555]) == 0\n assert candidate(nums = [987654, 876543, 765432, 654321, 543210]) == 60\n assert candidate(nums = [112233, 113322, 121233, 122133, 123123, 123312, 131223, 132123, 132213, 132312]) == 150\n assert candidate(nums = [1234, 2341, 3412, 4123, 1324, 2413, 3241, 4312, 1423, 2134]) == 148\n assert candidate(nums = [123456789, 987654321, 234567891, 891234567, 345678912, 789123456, 456789123, 654321987, 567891234]) == 310\n assert candidate(nums = [1001, 2002, 3003, 4004, 5005, 6006]) == 30\n assert candidate(nums = [111111111, 222222222, 333333333, 444444444, 555555555]) == 90\n assert candidate(nums = [987654321, 123456789, 987654321, 123456789]) == 32\n assert candidate(nums = [555555555, 444444444, 333333333, 222222222, 111111111, 123456789]) == 130\n assert candidate(nums = [111222, 222333, 333444, 444555]) == 36\n assert candidate(nums = [100100100, 110110110, 120120120, 130130130, 140140140]) == 30\n assert candidate(nums = [123456789, 987654321, 564738291]) == 25\n assert candidate(nums = [1010101, 2020202, 3030303, 4040404, 5050505, 6060606, 7070707, 8080808, 9090909]) == 144\n assert candidate(nums = [123456, 654321, 234561, 165432, 345612, 432165]) == 82\n assert candidate(nums = [555555555, 666666666, 777777777, 888888888, 999999999, 111111111, 222222222, 333333333, 444444444, 123456789, 987654321]) == 476\n assert candidate(nums = [100000000, 200000000, 300000000, 400000000, 500000000, 600000000]) == 15\n assert candidate(nums = [123456789, 987654321, 112233445, 554433221]) == 47\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().sumDigitDifferences", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "long long sumDigitDifferences(vector& nums) {", "container": "Solution", "callable": "sumDigitDifferences", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "long long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3154, "task_id": "find-number-of-ways-to-reach-the-k-th-stair", "difficulty": "Hard", "problem_description": "You are given a non-negative integer k. There exists a staircase with an infinite number of stairs, with the lowest stair numbered 0.\nAlice has an integer jump, with an initial value of 0. She starts on stair 1 and wants to reach stair k using any number of operations. If she is on stair i, in one operation she can:\n\nGo down to stair i - 1. This operation cannot be used consecutively or on stair 0.\nGo up to stair i + 2jump. And then, jump becomes jump + 1.\n\nReturn the total number of ways Alice can reach stair k.\nNote that it is possible that Alice reaches the stair k, and performs some operations to reach the stair k again.\n \nExample 1:\n\nInput: k = 0\nOutput: 2\nExplanation:\nThe 2 possible ways of reaching stair 0 are:\n\nAlice starts at stair 1.\n\t\nUsing an operation of the first type, she goes down 1 stair to reach stair 0.\n\n\nAlice starts at stair 1.\n\t\nUsing an operation of the first type, she goes down 1 stair to reach stair 0.\nUsing an operation of the second type, she goes up 20 stairs to reach stair 1.\nUsing an operation of the first type, she goes down 1 stair to reach stair 0.\n\n\n\n\nExample 2:\n\nInput: k = 1\nOutput: 4\nExplanation:\nThe 4 possible ways of reaching stair 1 are:\n\nAlice starts at stair 1. Alice is at stair 1.\nAlice starts at stair 1.\n\t\nUsing an operation of the first type, she goes down 1 stair to reach stair 0.\nUsing an operation of the second type, she goes up 20 stairs to reach stair 1.\n\n\nAlice starts at stair 1.\n\t\nUsing an operation of the second type, she goes up 20 stairs to reach stair 2.\nUsing an operation of the first type, she goes down 1 stair to reach stair 1.\n\n\nAlice starts at stair 1.\n\t\nUsing an operation of the first type, she goes down 1 stair to reach stair 0.\nUsing an operation of the second type, she goes up 20 stairs to reach stair 1.\nUsing an operation of the first type, she goes down 1 stair to reach stair 0.\nUsing an operation of the second type, she goes up 21 stairs to reach stair 2.\nUsing an operation of the first type, she goes down 1 stair to reach stair 1.\n\n\n\n\n \nConstraints:\n\n0 <= k <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(k = 1000) == 0\n assert candidate(k = 100) == 0\n assert candidate(k = 20) == 0\n assert candidate(k = 1000000000) == 0\n assert candidate(k = 1) == 4\n assert candidate(k = 10) == 0\n assert candidate(k = 10000) == 0\n assert candidate(k = 500) == 0\n assert candidate(k = 1000000) == 0\n assert candidate(k = 10000000) == 0\n assert candidate(k = 3) == 3\n assert candidate(k = 100000000) == 0\n assert candidate(k = 0) == 2\n assert candidate(k = 2) == 4\n assert candidate(k = 100000) == 0\n assert candidate(k = 5) == 4\n assert candidate(k = 4) == 2\n assert candidate(k = 50) == 0\n assert candidate(k = 127) == 8\n assert candidate(k = 8388608) == 1\n assert candidate(k = 63) == 7\n assert candidate(k = 65536) == 1\n assert candidate(k = 16384) == 1\n assert candidate(k = 5000) == 0\n assert candidate(k = 60000000) == 0\n assert candidate(k = 4194304) == 1\n assert candidate(k = 8191) == 14\n assert candidate(k = 30000000) == 0\n assert candidate(k = 750000) == 0\n assert candidate(k = 4096) == 1\n assert candidate(k = 65535) == 17\n assert candidate(k = 536870912) == 1\n assert candidate(k = 2048) == 1\n assert candidate(k = 1000001) == 0\n assert candidate(k = 8192) == 1\n assert candidate(k = 20000000) == 0\n assert candidate(k = 5000000) == 0\n assert candidate(k = 32767) == 16\n assert candidate(k = 1000100) == 0\n assert candidate(k = 524288) == 1\n assert candidate(k = 1000010) == 0\n assert candidate(k = 9) == 0\n assert candidate(k = 32768) == 1\n assert candidate(k = 23) == 0\n assert candidate(k = 500000) == 0\n assert candidate(k = 1073741824) == 1\n assert candidate(k = 131072) == 1\n assert candidate(k = 268435456) == 1\n assert candidate(k = 4095) == 13\n assert candidate(k = 15) == 5\n assert candidate(k = 33554432) == 1\n assert candidate(k = 999999) == 0\n assert candidate(k = 64) == 1\n assert candidate(k = 70000000) == 0\n assert candidate(k = 31) == 6\n assert candidate(k = 1100000) == 0\n assert candidate(k = 50000000) == 0\n assert candidate(k = 16) == 1\n assert candidate(k = 2097152) == 1\n assert candidate(k = 999999999) == 0\n assert candidate(k = 256) == 1\n assert candidate(k = 262144) == 1\n assert candidate(k = 134217728) == 1\n assert candidate(k = 1001000) == 0\n assert candidate(k = 90000000) == 0\n assert candidate(k = 2047) == 12\n assert candidate(k = 30) == 15\n assert candidate(k = 1024) == 1\n assert candidate(k = 67108864) == 1\n assert candidate(k = 7) == 4\n assert candidate(k = 1048576) == 1\n assert candidate(k = 255) == 9\n assert candidate(k = 512) == 1\n assert candidate(k = 80000000) == 0\n assert candidate(k = 1023) == 11\n assert candidate(k = 16777216) == 1\n assert candidate(k = 40000000) == 0\n assert candidate(k = 511) == 10\n assert candidate(k = 1010000) == 0\n"}, "metadata": {"canonical_parameter_names": ["k"], "leetcode_dataset_entry_point": "Solution().waysToReachStair", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int waysToReachStair(int k) {", "container": "Solution", "callable": "waysToReachStair", "parameters": [{"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3158, "task_id": "find-the-xor-of-numbers-which-appear-twice", "difficulty": "Easy", "problem_description": "You are given an array nums, where each number in the array appears either once or twice.\nReturn the bitwise XOR of all the numbers that appear twice in the array, or 0 if no number appears twice.\n \nExample 1:\n\nInput: nums = [1,2,1,3]\nOutput: 1\nExplanation:\nThe only number that appears twice in nums is 1.\n\nExample 2:\n\nInput: nums = [1,2,3]\nOutput: 0\nExplanation:\nNo number appears twice in nums.\n\nExample 3:\n\nInput: nums = [1,2,2,1]\nOutput: 3\nExplanation:\nNumbers 1 and 2 appeared twice. 1 XOR 2 == 3.\n\n \nConstraints:\n\n1 <= nums.length <= 50\n1 <= nums[i] <= 50\nEach number in nums appears either once or twice.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 10, 20, 30, 30, 40, 50]) == 20\n assert candidate(nums = [8, 8, 9, 9, 10, 10, 11]) == 11\n assert candidate(nums = [10, 10, 20, 20, 30]) == 30\n assert candidate(nums = [5, 5, 6, 7, 7, 8, 8, 9]) == 10\n assert candidate(nums = [4, 5, 6, 7, 8, 8, 7]) == 15\n assert candidate(nums = [30, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 30\n assert candidate(nums = [5, 5, 5, 5, 6, 6, 7]) == 6\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4]) == 4\n assert candidate(nums = [1, 2, 2, 1]) == 3\n assert candidate(nums = [1, 2, 1, 3]) == 1\n assert candidate(nums = [4, 5, 6, 4, 5, 7]) == 1\n assert candidate(nums = [42]) == 0\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1]) == 1\n assert candidate(nums = [1]) == 0\n assert candidate(nums = [3, 3, 3, 3, 3, 3]) == 0\n assert candidate(nums = [15, 15, 25, 25, 35]) == 22\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 50]) == 50\n assert candidate(nums = [10, 10, 11, 11, 12]) == 1\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 1\n assert candidate(nums = [10, 10, 20, 30, 20, 30, 40]) == 0\n assert candidate(nums = [4, 5, 6, 7, 8, 8, 9, 9]) == 1\n assert candidate(nums = [33, 33, 44, 44, 55, 55, 66, 66]) == 120\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 1\n assert candidate(nums = [4, 5, 6, 7, 4, 5]) == 1\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 5]) == 0\n assert candidate(nums = [1, 2, 3]) == 0\n assert candidate(nums = [49, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 49\n assert candidate(nums = [7]) == 0\n assert candidate(nums = [4, 5, 6, 7, 5, 4]) == 1\n assert candidate(nums = [10, 10, 20, 30, 30, 40]) == 20\n assert candidate(nums = [2, 2]) == 2\n assert candidate(nums = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 4, 20, 36]) == 4\n assert candidate(nums = [2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 1]) == 23\n assert candidate(nums = [4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24]) == 24\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 1, 2, 3, 4, 5]) == 1\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20]) == 20\n assert candidate(nums = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 60, 70, 80, 90, 100]) == 14\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 5, 6, 7, 8]) == 12\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 1, 3, 5]) == 7\n assert candidate(nums = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50]) == 26\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 33, 36, 39, 42, 45, 48]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16]) == 26\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 50, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48]) == 0\n assert candidate(nums = [5, 5, 10, 10, 15, 15, 20, 20, 25, 25, 30, 30, 35, 35, 40, 40, 45, 45, 50, 50, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 0\n assert candidate(nums = [45, 45, 44, 44, 43, 43, 42, 42, 41, 41, 40, 40, 39, 39, 38, 38, 37, 37, 36, 36, 35, 35, 34, 34, 33, 33, 32, 32, 31, 31, 30, 30, 29, 29, 28, 28, 27, 27, 26, 26, 25, 25, 24, 24, 23, 23, 22, 22, 21, 21, 20, 20, 19, 19, 18, 18, 17, 17, 16, 16, 15, 15, 14, 14, 13, 13, 12, 12, 11, 11, 10, 10]) == 0\n assert candidate(nums = [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 15, 30]) == 17\n assert candidate(nums = [30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 30, 31]) == 1\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39, 40, 40, 41, 41, 42, 42, 43, 43, 44, 44, 45, 45, 46, 46, 47, 47, 48, 48, 49, 49, 50, 50]) == 51\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 50, 7, 14, 21, 28, 35, 42, 49]) == 56\n assert candidate(nums = [14, 28, 14, 42, 56, 70, 84, 56, 70, 84, 98, 98]) == 70\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == 0\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 0\n assert candidate(nums = [25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34]) == 59\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 3, 6, 9]) == 12\n assert candidate(nums = [1, 1, 2, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 10\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 5, 10, 15, 20, 35, 40, 45, 50, 35, 40, 45]) == 50\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 11\n assert candidate(nums = [25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 25, 26, 27, 28, 29, 30, 1, 2, 3, 4, 5]) == 7\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 3, 6, 9, 12, 15]) == 15\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 7, 14, 21, 28, 35, 42, 49, 5, 10, 15, 20, 25, 30, 35, 5, 10, 15, 20, 25, 30]) == 8\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 31\n assert candidate(nums = [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 15, 16, 17, 18, 19]) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, 5, 6, 6, 7, 8, 8, 9, 10, 10, 11, 12, 12, 13, 14, 14, 15, 15, 16, 17, 17, 18, 19, 20, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 30, 31, 32, 33, 34, 35, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 49, 50]) == 5\n assert candidate(nums = [1, 3, 3, 5, 7, 7, 9, 11, 11, 13, 15, 15, 17, 19, 19, 21, 21, 23, 25, 25]) == 31\n assert candidate(nums = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 7, 30, 40]) == 49\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 0\n assert candidate(nums = [25, 26, 27, 28, 29, 30, 25, 26, 27, 28, 29, 30, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 3\n assert candidate(nums = [49, 50, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 3\n assert candidate(nums = [13, 26, 39, 52, 65, 13, 26, 39, 52, 65, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 8, 16, 24, 32, 40, 48]) == 125\n assert candidate(nums = [25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 25, 26, 27, 28, 29, 30]) == 7\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 2, 4, 6, 8, 10]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 11\n assert candidate(nums = [45, 46, 47, 48, 49, 50, 45, 46, 47, 48, 49, 50]) == 31\n assert candidate(nums = [42, 42, 24, 24, 36, 36, 18, 18, 30, 30, 21, 21, 9, 9, 27, 27, 33, 33, 15, 15]) == 51\n assert candidate(nums = [49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49]) == 1\n assert candidate(nums = [45, 45, 30, 30, 25, 25, 20, 15, 10, 5, 1, 2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 16, 17, 18, 19]) == 42\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 55, 60, 65, 70]) == 11\n assert candidate(nums = [1, 1, 2, 3, 4, 4, 5, 5, 6, 7, 8, 8, 9, 9, 10, 11, 12, 12, 13, 14, 15, 15, 16, 17, 18, 19, 20, 20, 21, 22, 23, 23, 24, 25, 25, 26, 27, 28, 28, 29, 30, 30, 31, 32, 32, 33, 34, 35, 35, 36, 37, 38, 39, 40, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 50]) == 3\n assert candidate(nums = [23, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 199]) == 208\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 1, 3]) == 2\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 2, 4, 6]) == 0\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 1, 2, 3, 4, 5]) == 2\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21]) == 1\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 22\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 2, 4, 6, 8, 10]) == 2\n assert candidate(nums = [3, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 93, 96, 99, 3, 6, 9, 12, 15, 18, 21]) == 11\n assert candidate(nums = [5, 5, 10, 15, 15, 20, 25, 25, 30, 35, 35, 40, 45, 45, 50, 50]) == 47\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20]) == 20\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 50]) == 38\n assert candidate(nums = [5, 5, 10, 10, 15, 15, 20, 20, 25, 25, 30, 30, 35, 35, 40, 40, 45, 45, 50, 50, 1, 2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 16, 17, 18, 19, 21, 22, 23, 24, 26, 27, 28, 29, 31, 32, 33, 34, 36, 37, 38, 39, 41, 42, 43, 44, 46, 47, 48, 49]) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5]) == 1\n assert candidate(nums = [45, 46, 47, 48, 49, 50, 45, 46, 47, 48, 49, 50, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 31\n assert candidate(nums = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 27\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 7, 14, 21, 28, 35, 42, 49, 1, 2, 3, 4, 5]) == 56\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 1, 3, 5]) == 7\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 1]) == 11\n assert candidate(nums = [23, 26, 29, 32, 35, 38, 41, 44, 47, 50, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50]) == 45\n assert candidate(nums = [17, 17, 19, 19, 21, 21, 23, 23, 25, 25, 27, 27, 29, 29, 31, 31, 33, 33, 35, 35, 37, 37, 39, 39, 41, 41, 43, 43, 45, 45, 47, 47, 49, 49, 51, 51]) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 1, 3, 5, 7]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 11, 12, 13, 14, 15]) == 1\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 11, 22, 33, 44, 55, 66, 77, 88, 99, 1]) == 19\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]) == 56\n assert candidate(nums = [3, 3, 5, 5, 7, 7, 9, 9, 11, 11, 13, 13, 15, 15, 17, 17, 19, 19, 21, 21, 23, 23, 25, 25, 27, 27, 29, 29, 31, 31, 33, 33, 35, 35, 37, 37, 39, 39, 41, 41, 43, 43, 45, 45, 47, 47, 49, 49]) == 48\n assert candidate(nums = [5, 5, 10, 10, 15, 15, 20, 20, 25, 25, 30, 30, 35, 35, 40, 40, 45, 45, 50, 50]) == 7\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 2, 4, 6, 8, 10]) == 2\n assert candidate(nums = [15, 20, 25, 30, 35, 40, 45, 50, 15, 20, 25, 30, 35, 40, 45, 50]) == 8\n assert candidate(nums = [10, 20, 10, 30, 40, 40, 50, 20]) == 54\n assert candidate(nums = [10, 20, 30, 10, 40, 50, 60, 70, 80, 90, 50, 20, 100]) == 44\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 50, 8, 16, 24, 32, 40, 48]) == 56\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 50, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 0\n assert candidate(nums = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5]) == 1\n assert candidate(nums = [42, 24, 13, 24, 42, 35, 13, 47, 50, 40, 47, 35, 40, 50]) == 41\n assert candidate(nums = [45, 30, 15, 60, 45, 30, 15, 60, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 7\n assert candidate(nums = [25, 26, 26, 27, 28, 28, 29, 30, 30, 31, 32, 32, 33, 34, 34, 35, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]) == 57\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().duplicateNumbersXOR", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int duplicateNumbersXOR(vector& nums) {", "container": "Solution", "callable": "duplicateNumbersXOR", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3159, "task_id": "find-occurrences-of-an-element-in-an-array", "difficulty": "Medium", "problem_description": "You are given an integer array nums, an integer array queries, and an integer x.\nFor each queries[i], you need to find the index of the queries[i]th occurrence of x in the nums array. If there are fewer than queries[i] occurrences of x, the answer should be -1 for that query.\nReturn an integer array answer containing the answers to all queries.\n \nExample 1:\n\nInput: nums = [1,3,1,7], queries = [1,3,2,4], x = 1\nOutput: [0,-1,2,-1]\nExplanation:\n\nFor the 1st query, the first occurrence of 1 is at index 0.\nFor the 2nd query, there are only two occurrences of 1 in nums, so the answer is -1.\nFor the 3rd query, the second occurrence of 1 is at index 2.\nFor the 4th query, there are only two occurrences of 1 in nums, so the answer is -1.\n\n\nExample 2:\n\nInput: nums = [1,2,3], queries = [10], x = 5\nOutput: [-1]\nExplanation:\n\nFor the 1st query, 5 doesn't exist in nums, so the answer is -1.\n\n\n \nConstraints:\n\n1 <= nums.length, queries.length <= 105\n1 <= queries[i] <= 105\n1 <= nums[i], x <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],x = 1) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1]\n assert candidate(nums = [3, 2, 1],queries = [1, 1, 1],x = 3) == [0, 0, 0]\n assert candidate(nums = [1, 2, 3, 4, 5],queries = [1, 1, 1, 1, 1],x = 3) == [2, 2, 2, 2, 2]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 1) == [0, 1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [5, 3, 5, 3, 5],queries = [1, 2, 3, 4, 5, 6],x = 5) == [0, 2, 4, -1, -1, -1]\n assert candidate(nums = [10, 20, 30, 40, 50],queries = [1, 2, 3, 4, 5],x = 10) == [0, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5],queries = [1, 1, 1, 1, 1],x = 6) == [-1, -1, -1, -1, -1]\n assert candidate(nums = [100, 200, 300, 400, 500],queries = [1, 2, 3, 4, 5],x = 300) == [2, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3],queries = [10],x = 5) == [-1]\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],queries = [5, 5, 5, 5, 5],x = 3) == [4, 4, 4, 4, 4]\n assert candidate(nums = [2, 4, 2, 4, 2, 4, 2, 4],queries = [1, 2, 3, 4, 5, 6, 7, 8],x = 2) == [0, 2, 4, 6, -1, -1, -1, -1]\n assert candidate(nums = [4, 4, 4, 4],queries = [1, 2, 3, 4, 5],x = 4) == [0, 1, 2, 3, -1]\n assert candidate(nums = [1, 3, 1, 7],queries = [1, 3, 2, 4],x = 1) == [0, -1, 2, -1]\n assert candidate(nums = [5, 5, 5, 5, 5],queries = [1, 2, 3, 4, 5, 6],x = 5) == [0, 1, 2, 3, 4, -1]\n assert candidate(nums = [10, 20, 30, 40, 50],queries = [1, 2, 3, 4, 5, 6],x = 30) == [2, -1, -1, -1, -1, -1]\n assert candidate(nums = [10, 20, 30, 40, 50],queries = [1],x = 10) == [0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 10) == [9, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [3, 3, 3, 3, 2, 2, 2, 1, 1, 1, 1, 1],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],x = 3) == [0, 1, 2, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [5, 10, 15, 20, 25, 30],x = 1) == [4, 9, 14, 19, 24, 29]\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],x = 9) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],x = 1) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queries = [1],x = 500) == [4]\n assert candidate(nums = [7, 11, 13, 11, 7, 17, 19, 23, 11, 13, 11],queries = [1, 2, 3, 4, 5],x = 11) == [1, 3, 8, 10, -1]\n assert candidate(nums = [7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21],x = 8) == [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],queries = [1, 10, 20, 30, 40],x = 3) == [0, 9, 19, 29, 39]\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],x = 9990) == [10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],x = 9) == [0, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],x = 1) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, -1]\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],x = 1) == [0, 1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],queries = [1, 5, 10, 15, 25, 30],x = 4) == [0, 4, 9, 14, 24, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],x = 21) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [100, 200, 300, 400, 500],queries = [1, 2, 3, 4, 5, 6],x = 500) == [4, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],x = 10) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 5) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21],x = 15) == [14, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],queries = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90],x = 7) == [0, 9, 19, 29, 39, 49, 59, -1, -1, -1]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],x = 5) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1]\n assert candidate(nums = [5, 3, 8, 5, 2, 5, 8, 5, 9, 5],queries = [1, 2, 3, 4, 5, 6],x = 5) == [0, 3, 5, 7, 9, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [1, 11, 21, 31, 41, 51],x = 1) == [0, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],queries = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],x = 20) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 19]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],queries = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],x = 20) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 19]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [1, 5, 10, 15],x = 1) == [0, 4, 9, -1]\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],x = 10000) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [5, 3, 2, 3, 1, 3, 5, 3, 2],queries = [1, 2, 3, 4, 5, 6, 7, 8],x = 3) == [1, 3, 5, 7, -1, -1, -1, -1]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],x = 700) == [6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21],x = 1) == [0, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],x = 4) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [1, 10, 20, 30, 40],x = 1) == [0, 9, 19, -1, -1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [1, 10, 20, 15, 5, 25, 30, 35],x = 1) == [0, 9, 19, 14, 4, 24, 29, -1]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 1000) == [9, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],queries = [1, 5, 10, 15, 20],x = 7) == [0, 4, 9, -1, -1]\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],x = 2) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],queries = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],x = 5) == [0, 9, 19, 29, 39, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],x = 10) == [9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],queries = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 20) == [19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19]\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],queries = [1, 5, 10, 15, 20, 25],x = 3) == [0, 4, 9, 14, 19, -1]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],x = 20) == [9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],x = 5) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [5, 6, 5, 6, 5, 5, 6, 5, 6, 6, 5],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 5) == [0, 2, 4, 5, 7, 10, -1, -1, -1, -1]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],queries = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],x = 10) == [18, 19, 18, 19, 18, 19, 18, 19, 18, 19, 18, 19, 18, 19, 18, 19, 18, 19, 18, 19]\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],x = 80) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],queries = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],x = 9) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [5, 3, 5, 2, 5, 3, 5, 3, 5, 3, 5],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],x = 5) == [0, 2, 4, 6, 8, 10, -1, -1, -1, -1, -1]\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],queries = [1, 5, 10, 15],x = 7) == [0, 4, 9, -1]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 9) == [0, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],queries = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],x = 10) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 9, 9]\n assert candidate(nums = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24],x = 3) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],x = 1) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, 0]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [25, 26, 27, 28, 29, 30],x = 1) == [24, 25, 26, 27, 28, -1]\n assert candidate(nums = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],x = 10) == [0, 5, 10, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],x = 1) == [0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],queries = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],x = 20) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],x = 1) == [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, -1, -1, -1]\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],x = 7) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1]\n assert candidate(nums = [5, 3, 5, 2, 5, 3, 5, 1, 5, 5, 5],queries = [1, 5, 7, 3, 9, 11, 12],x = 5) == [0, 8, 10, 4, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26],x = 15) == [14, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],queries = [1, 10, 20, 30],x = 4) == [0, 9, 19, -1]\n assert candidate(nums = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27],x = 25) == [18, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],queries = [1, 5, 9, 10, 11],x = 5) == [0, 4, 8, 9, -1]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],x = 100) == [0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 1) == [8, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n"}, "metadata": {"canonical_parameter_names": ["nums", "queries", "x"], "leetcode_dataset_entry_point": "Solution().occurrencesOfElement", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector occurrencesOfElement(vector& nums, vector& queries, int x) {", "container": "Solution", "callable": "occurrencesOfElement", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "queries", "type": "vector&"}, {"name": "x", "type": "int"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3160, "task_id": "find-the-number-of-distinct-colors-among-the-balls", "difficulty": "Medium", "problem_description": "You are given an integer limit and a 2D array queries of size n x 2.\nThere are limit + 1 balls with distinct labels in the range [0, limit]. Initially, all balls are uncolored. For every query in queries that is of the form [x, y], you mark ball x with the color y. After each query, you need to find the number of colors among the balls.\nReturn an array result of length n, where result[i] denotes the number of colors after ith query.\nNote that when answering a query, lack of a color will not be considered as a color.\n \nExample 1:\n\nInput: limit = 4, queries = [[1,4],[2,5],[1,3],[3,4]]\nOutput: [1,2,2,3]\nExplanation:\n\n\nAfter query 0, ball 1 has color 4.\nAfter query 1, ball 1 has color 4, and ball 2 has color 5.\nAfter query 2, ball 1 has color 3, and ball 2 has color 5.\nAfter query 3, ball 1 has color 3, ball 2 has color 5, and ball 3 has color 4.\n\n\nExample 2:\n\nInput: limit = 4, queries = [[0,1],[1,2],[2,2],[3,4],[4,5]]\nOutput: [1,2,2,3,4]\nExplanation:\n\n\nAfter query 0, ball 0 has color 1.\nAfter query 1, ball 0 has color 1, and ball 1 has color 2.\nAfter query 2, ball 0 has color 1, and balls 1 and 2 have color 2.\nAfter query 3, ball 0 has color 1, balls 1 and 2 have color 2, and ball 3 has color 4.\nAfter query 4, ball 0 has color 1, balls 1 and 2 have color 2, ball 3 has color 4, and ball 4 has color 5.\n\n\n \nConstraints:\n\n1 <= limit <= 109\n1 <= n == queries.length <= 105\nqueries[i].length == 2\n0 <= queries[i][0] <= limit\n1 <= queries[i][1] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(limit = 3,queries = [[0, 1], [1, 2], [2, 3], [0, 1]]) == [1, 2, 3, 3]\n assert candidate(limit = 1,queries = [[0, 1], [1, 2]]) == [1, 2]\n assert candidate(limit = 4,queries = [[0, 1], [1, 2], [2, 2], [3, 4], [4, 5]]) == [1, 2, 2, 3, 4]\n assert candidate(limit = 10,queries = [[0, 10], [1, 10], [2, 10], [3, 10], [4, 10]]) == [1, 1, 1, 1, 1]\n assert candidate(limit = 5,queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == [1, 2, 3, 4, 5, 6]\n assert candidate(limit = 1,queries = [[0, 1], [0, 2], [0, 3], [0, 4]]) == [1, 1, 1, 1]\n assert candidate(limit = 3,queries = [[0, 1], [1, 1], [2, 1], [3, 1]]) == [1, 1, 1, 1]\n assert candidate(limit = 5,queries = [[0, 2], [1, 2], [2, 3], [3, 4], [4, 5]]) == [1, 1, 2, 3, 4]\n assert candidate(limit = 4,queries = [[1, 4], [2, 5], [1, 3], [3, 4]]) == [1, 2, 2, 3]\n assert candidate(limit = 10,queries = [[0, 10], [1, 20], [2, 30], [3, 40], [4, 50], [5, 60], [6, 70], [7, 80], [8, 90], [9, 100]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(limit = 100,queries = [[0, 1], [50, 2], [100, 3]]) == [1, 2, 3]\n assert candidate(limit = 10,queries = [[0, 1], [2, 2], [4, 3], [6, 4], [8, 5]]) == [1, 2, 3, 4, 5]\n assert candidate(limit = 10,queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(limit = 10,queries = [[0, 10], [1, 9], [2, 8], [3, 7], [4, 6], [5, 5]]) == [1, 2, 3, 4, 5, 6]\n assert candidate(limit = 5,queries = [[0, 10], [1, 20], [2, 10], [3, 30], [4, 40], [5, 50]]) == [1, 2, 2, 3, 4, 5]\n assert candidate(limit = 9,queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [5, 4], [6, 3], [7, 2], [8, 1], [9, 9]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 9]\n assert candidate(limit = 10,queries = [[1, 5], [2, 6], [1, 6], [3, 7], [4, 8], [2, 8], [5, 9], [6, 9], [7, 10], [8, 10], [9, 11]]) == [1, 2, 1, 2, 3, 3, 4, 4, 5, 5, 6]\n assert candidate(limit = 50,queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 2], [7, 3], [8, 4], [9, 5], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6]]) == [1, 2, 3, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6]\n assert candidate(limit = 10,queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1], [1, 2], [2, 3]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10]\n assert candidate(limit = 5,queries = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [1, 1, 1, 1, 1, 2, 3, 4, 5, 5]\n assert candidate(limit = 20,queries = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1], [14, 1], [15, 1], [16, 1], [17, 1], [18, 1], [19, 1]]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(limit = 10,queries = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1]]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(limit = 20,queries = [[5, 2], [5, 3], [10, 4], [15, 5], [15, 6], [10, 7], [5, 8], [5, 9], [10, 10], [15, 11]]) == [1, 1, 2, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(limit = 10,queries = [[5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10]]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(limit = 10,queries = [[0, 1], [1, 2], [2, 1], [3, 2], [4, 3], [5, 4], [6, 5], [7, 6], [8, 7], [9, 8], [10, 9]]) == [1, 2, 2, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(limit = 20,queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [1, 3], [3, 5], [5, 2], [2, 4]]) == [1, 2, 3, 4, 5, 5, 4, 3, 4, 5]\n assert candidate(limit = 10,queries = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(limit = 10,queries = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [10, 10]]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(limit = 10,queries = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10]]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(limit = 5,queries = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1]]) == [1, 1, 1, 1, 1]\n assert candidate(limit = 20,queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(limit = 9,queries = [[9, 10], [8, 10], [7, 10], [6, 10], [5, 10], [4, 10], [3, 10], [2, 10], [1, 10], [0, 10]]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(limit = 100,queries = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 31], [31, 32], [32, 33], [33, 34], [34, 35], [35, 36], [36, 37], [37, 38], [38, 39], [39, 40], [40, 41], [41, 42], [42, 43], [43, 44], [44, 45], [45, 46], [46, 47], [47, 48], [48, 49], [49, 50]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49]\n assert candidate(limit = 10,queries = [[0, 1], [0, 2], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]]) == [1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(limit = 9,queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 8, 8, 8, 8, 8, 8, 8]\n assert candidate(limit = 10,queries = [[0, 1], [0, 2], [1, 2], [1, 3], [2, 3], [2, 4], [3, 4], [3, 5], [4, 5], [4, 6], [5, 6]]) == [1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5]\n assert candidate(limit = 50,queries = [[10, 1], [15, 2], [20, 3], [25, 4], [30, 5], [35, 6], [40, 7], [45, 8], [50, 9]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(limit = 50,queries = [[10, 100], [20, 100], [30, 100], [40, 100], [50, 100], [0, 101], [5, 102], [15, 103], [25, 104], [35, 105], [45, 106]]) == [1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(limit = 100,queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 1], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 10]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(limit = 10,queries = [[0, 10], [1, 20], [2, 10], [3, 30], [4, 10], [5, 20], [6, 30], [7, 40], [8, 50], [9, 60], [10, 70]]) == [1, 2, 2, 3, 3, 3, 3, 4, 5, 6, 7]\n assert candidate(limit = 10,queries = [[0, 10], [1, 2], [2, 3], [3, 10], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == [1, 2, 3, 3, 4, 5, 6, 7, 8, 8]\n assert candidate(limit = 20,queries = [[0, 1], [1, 1], [2, 2], [2, 3], [3, 3], [3, 2], [4, 4], [4, 5], [5, 5], [5, 6], [6, 6], [6, 7], [7, 7], [7, 8], [8, 8], [8, 9]]) == [1, 1, 2, 2, 2, 3, 4, 4, 4, 5, 5, 6, 6, 7, 7, 8]\n assert candidate(limit = 10,queries = [[0, 1], [1, 2], [1, 1], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == [1, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(limit = 1,queries = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10]]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(limit = 10,queries = [[0, 10], [1, 20], [2, 10], [3, 30], [4, 10], [5, 50], [6, 10], [7, 70], [8, 10], [9, 90], [10, 100]]) == [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7]\n assert candidate(limit = 10,queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10]]) == [1, 2, 3, 4, 5, 5, 5, 5, 5, 5]\n assert candidate(limit = 10,queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [1, 3], [3, 5], [5, 2], [2, 4], [0, 10], [1, 10], [2, 10], [3, 10], [4, 10]]) == [1, 2, 3, 4, 5, 5, 4, 3, 4, 5, 5, 4, 3, 3, 2]\n"}, "metadata": {"canonical_parameter_names": ["limit", "queries"], "leetcode_dataset_entry_point": "Solution().queryResults", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector queryResults(int limit, vector>& queries) {", "container": "Solution", "callable": "queryResults", "parameters": [{"name": "limit", "type": "int"}, {"name": "queries", "type": "vector>&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3161, "task_id": "block-placement-queries", "difficulty": "Hard", "problem_description": "There exists an infinite number line, with its origin at 0 and extending towards the positive x-axis.\nYou are given a 2D array queries, which contains two types of queries:\n\nFor a query of type 1, queries[i] = [1, x]. Build an obstacle at distance x from the origin. It is guaranteed that there is no obstacle at distance x when the query is asked.\nFor a query of type 2, queries[i] = [2, x, sz]. Check if it is possible to place a block of size sz anywhere in the range [0, x] on the line, such that the block entirely lies in the range [0, x]. A block cannot be placed if it intersects with any obstacle, but it may touch it. Note that you do not actually place the block. Queries are separate.\n\nReturn a boolean array results, where results[i] is true if you can place the block specified in the ith query of type 2, and false otherwise.\n \nExample 1:\n\nInput: queries = [[1,2],[2,3,3],[2,3,1],[2,2,2]]\nOutput: [false,true,true]\nExplanation:\n\nFor query 0, place an obstacle at x = 2. A block of size at most 2 can be placed before x = 3.\n\nExample 2:\n\nInput: queries = [[1,7],[2,7,6],[1,2],[2,7,5],[2,7,6]]\nOutput: [true,true,false]\nExplanation:\n\n\nPlace an obstacle at x = 7 for query 0. A block of size at most 7 can be placed before x = 7.\nPlace an obstacle at x = 2 for query 2. Now, a block of size at most 5 can be placed before x = 7, and a block of size at most 2 before x = 2.\n\n\n \nConstraints:\n\n1 <= queries.length <= 15 * 104\n2 <= queries[i].length <= 3\n1 <= queries[i][0] <= 2\n1 <= x, sz <= min(5 * 104, 3 * queries.length)\nThe input is generated such that for queries of type 1, no obstacle exists at distance x when the query is asked.\nThe input is generated such that there is at least one query of type 2.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(queries = [[2, 5, 2], [1, 3], [2, 5, 3], [1, 4], [2, 5, 1]]) == [True, True, True]\n assert candidate(queries = [[2, 10, 5], [1, 3], [2, 5, 2], [1, 10], [2, 10, 3]]) == [True, True, True]\n assert candidate(queries = [[1, 7], [2, 7, 6], [1, 2], [2, 7, 5], [2, 7, 6]]) == [True, True, False]\n assert candidate(queries = [[1, 1], [2, 2, 2], [1, 3], [2, 4, 1], [2, 4, 2]]) == [False, True, True]\n assert candidate(queries = [[1, 5], [1, 10], [1, 15], [2, 20, 10], [2, 12, 3]]) == [False, True]\n assert candidate(queries = [[2, 5, 1], [1, 3], [1, 4], [2, 5, 1]]) == [True, True]\n assert candidate(queries = [[1, 1], [1, 3], [1, 5], [1, 7], [2, 10, 5]]) == [False]\n assert candidate(queries = [[2, 5, 3], [1, 2], [2, 5, 2], [1, 4], [2, 5, 3]]) == [True, True, False]\n assert candidate(queries = [[1, 1], [1, 5], [1, 10], [2, 10, 3], [2, 10, 7]]) == [True, False]\n assert candidate(queries = [[1, 1], [1, 2], [1, 3], [1, 4], [2, 4, 2]]) == [False]\n assert candidate(queries = [[1, 1], [1, 3], [1, 5], [2, 6, 2], [2, 6, 4]]) == [True, False]\n assert candidate(queries = [[1, 5], [1, 10], [2, 10, 4], [1, 15], [2, 15, 7]]) == [True, False]\n assert candidate(queries = [[1, 10], [2, 10, 5], [1, 5], [2, 5, 2], [2, 10, 8]]) == [True, True, False]\n assert candidate(queries = [[1, 10], [2, 10, 5], [1, 3], [2, 5, 2]]) == [True, True]\n assert candidate(queries = [[1, 10], [1, 5], [2, 10, 3], [2, 5, 2]]) == [True, True]\n assert candidate(queries = [[1, 2], [2, 3, 3], [2, 3, 1], [2, 2, 2]]) == [False, True, True]\n assert candidate(queries = [[1, 1], [1, 5], [1, 10], [2, 12, 3], [2, 12, 7], [2, 12, 10]]) == [True, False, False]\n assert candidate(queries = [[1, 1], [2, 2, 1], [1, 3], [2, 4, 2], [1, 5], [2, 6, 3], [1, 7], [2, 8, 4], [1, 9], [2, 10, 5]]) == [True, True, False, False, False]\n assert candidate(queries = [[1, 2], [1, 4], [1, 6], [1, 8], [1, 10], [2, 10, 5], [2, 10, 4], [2, 10, 3], [2, 10, 2], [2, 10, 1], [1, 12], [2, 12, 6], [2, 12, 5], [2, 12, 4], [2, 12, 3], [2, 12, 2], [2, 12, 1]]) == [False, False, False, True, True, False, False, False, False, True, True]\n assert candidate(queries = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 5, 5], [2, 5, 4], [2, 5, 3], [2, 5, 2], [2, 5, 1]]) == [False, False, False, False, True]\n assert candidate(queries = [[1, 2], [1, 4], [1, 6], [1, 8], [1, 10], [2, 10, 9], [2, 10, 3], [2, 10, 5]]) == [False, False, False]\n assert candidate(queries = [[1, 1], [1, 3], [1, 5], [1, 7], [1, 9], [2, 10, 9], [2, 10, 8], [2, 10, 7], [2, 10, 6], [2, 10, 5], [2, 10, 4], [2, 10, 3], [2, 10, 2], [2, 10, 1]]) == [False, False, False, False, False, False, False, True, True]\n assert candidate(queries = [[1, 2], [1, 4], [1, 6], [1, 8], [2, 10, 8], [2, 8, 4], [2, 6, 2]]) == [False, False, True]\n assert candidate(queries = [[1, 1], [1, 3], [1, 5], [1, 7], [1, 9], [2, 10, 8], [2, 10, 4], [2, 10, 2]]) == [False, False, True]\n assert candidate(queries = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 5, 2], [2, 5, 3], [2, 5, 4], [2, 5, 5]]) == [False, False, False, False]\n assert candidate(queries = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 5, 1], [2, 5, 2], [2, 5, 3], [2, 5, 4], [2, 5, 5]]) == [True, False, False, False, False]\n assert candidate(queries = [[1, 1], [1, 10], [2, 5, 4], [2, 10, 8], [1, 15], [2, 20, 5], [2, 20, 10], [2, 20, 15], [2, 20, 20]]) == [True, True, True, False, False, False]\n assert candidate(queries = [[1, 2], [1, 4], [1, 6], [1, 8], [1, 10], [1, 12], [1, 14], [1, 16], [1, 18], [1, 20], [2, 21, 10], [2, 21, 20], [2, 21, 30], [2, 21, 40], [2, 21, 50]]) == [False, False, False, False, False]\n assert candidate(queries = [[1, 1], [1, 3], [1, 5], [1, 7], [1, 9], [1, 11], [1, 13], [1, 15], [1, 17], [1, 19], [2, 20, 1], [2, 20, 2], [2, 20, 3], [2, 20, 4], [2, 20, 5], [2, 20, 6], [2, 20, 7], [2, 20, 8], [2, 20, 9], [2, 20, 10]]) == [True, True, False, False, False, False, False, False, False, False]\n assert candidate(queries = [[1, 1], [2, 2, 1], [2, 3, 2], [1, 4], [2, 5, 3], [1, 6], [2, 7, 4], [1, 8], [2, 9, 5]]) == [True, True, True, False, False]\n assert candidate(queries = [[1, 1], [2, 2, 2], [1, 3], [1, 4], [1, 5], [2, 5, 4], [2, 5, 1]]) == [False, False, True]\n assert candidate(queries = [[1, 10], [1, 9], [1, 8], [1, 7], [1, 6], [1, 5], [1, 4], [1, 3], [1, 2], [1, 1], [2, 10, 5], [2, 9, 4], [2, 8, 3], [2, 7, 2], [2, 6, 1]]) == [False, False, False, False, True]\n assert candidate(queries = [[1, 2], [2, 3, 1], [1, 4], [2, 5, 2], [1, 6], [2, 7, 3], [1, 8], [2, 9, 4], [1, 10], [2, 11, 5], [1, 12], [2, 13, 6]]) == [True, True, False, False, False, False]\n assert candidate(queries = [[1, 5], [1, 10], [2, 12, 3], [1, 7], [2, 10, 6], [2, 8, 2]]) == [True, False, True]\n assert candidate(queries = [[1, 1], [1, 2], [2, 2, 1], [2, 2, 2], [1, 3], [2, 3, 1], [2, 3, 2], [2, 3, 3], [1, 4], [2, 4, 1], [2, 4, 2], [2, 4, 3], [2, 4, 4]]) == [True, False, True, False, False, True, False, False, False]\n assert candidate(queries = [[1, 2], [1, 4], [1, 6], [1, 8], [1, 10], [1, 12], [1, 14], [2, 16, 12], [2, 16, 8], [2, 16, 4], [2, 16, 6], [2, 16, 10], [2, 16, 14]]) == [False, False, False, False, False, False]\n assert candidate(queries = [[1, 1], [1, 3], [1, 5], [1, 7], [1, 9], [2, 10, 2], [2, 10, 4], [2, 10, 6], [2, 10, 8], [2, 10, 10]]) == [True, False, False, False, False]\n assert candidate(queries = [[1, 1], [2, 2, 1], [2, 3, 2], [1, 4], [1, 5], [2, 6, 3], [2, 7, 4], [2, 8, 5]]) == [True, True, True, False, False]\n assert candidate(queries = [[1, 1], [2, 2, 1], [1, 3], [2, 4, 2], [1, 5], [2, 6, 3], [1, 7], [2, 8, 4], [1, 9], [2, 10, 5], [1, 11], [2, 12, 6], [1, 13], [2, 14, 7], [1, 14], [2, 15, 8], [1, 16], [2, 17, 9], [1, 17], [2, 18, 10]]) == [True, True, False, False, False, False, False, False, False, False]\n assert candidate(queries = [[1, 1], [2, 3, 1], [2, 3, 2], [1, 4], [1, 5], [2, 6, 3], [2, 6, 5], [1, 7], [2, 8, 4]]) == [True, True, True, False, False]\n assert candidate(queries = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 10, 1], [2, 10, 2], [2, 10, 3], [2, 10, 4], [2, 10, 5], [2, 10, 6], [2, 10, 7], [2, 10, 8], [2, 10, 9], [2, 10, 10]]) == [True, False, False, False, False, False, False, False, False, False]\n assert candidate(queries = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 6, 1], [2, 6, 2], [2, 6, 3], [2, 6, 4], [2, 6, 5], [2, 6, 6]]) == [True, False, False, False, False, False]\n assert candidate(queries = [[1, 1], [2, 2, 2], [1, 3], [2, 4, 1], [2, 4, 2], [1, 5], [2, 6, 1], [2, 6, 2], [2, 6, 3], [2, 6, 4], [2, 6, 5]]) == [False, True, True, True, True, False, False, False]\n assert candidate(queries = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 11, 10], [2, 11, 9], [2, 11, 8], [2, 11, 7], [2, 11, 6], [2, 11, 5], [2, 11, 4], [2, 11, 3], [2, 11, 2], [2, 11, 1]]) == [False, False, False, False, False, False, False, False, False, True]\n assert candidate(queries = [[1, 5], [2, 10, 4], [1, 15], [2, 15, 6], [1, 20], [2, 20, 8], [2, 20, 9]]) == [True, True, True, True]\n assert candidate(queries = [[1, 1], [1, 3], [1, 5], [1, 7], [2, 10, 2], [2, 8, 2], [2, 6, 2], [2, 4, 2], [2, 2, 2]]) == [True, True, True, True, False]\n assert candidate(queries = [[1, 1], [2, 1, 1], [1, 2], [2, 2, 2], [1, 3], [2, 3, 3], [1, 4], [2, 4, 4], [1, 5], [2, 5, 5], [1, 6], [2, 6, 6], [1, 7], [2, 7, 7], [1, 8], [2, 8, 8], [1, 9], [2, 9, 9], [1, 10], [2, 10, 10]]) == [True, False, False, False, False, False, False, False, False, False]\n assert candidate(queries = [[1, 10], [2, 20, 5], [1, 15], [2, 25, 10], [1, 20], [2, 30, 15], [1, 25], [2, 40, 20], [1, 30], [2, 50, 25]]) == [True, True, False, False, False]\n assert candidate(queries = [[1, 5], [1, 10], [1, 15], [2, 20, 10], [2, 20, 5], [2, 20, 15]]) == [False, True, False]\n assert candidate(queries = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 10, 5]]) == [False]\n assert candidate(queries = [[1, 20], [2, 20, 10], [1, 5], [2, 20, 15], [1, 15], [2, 20, 12], [2, 20, 18]]) == [True, True, False, False]\n assert candidate(queries = [[2, 10, 1], [1, 5], [2, 10, 4], [2, 10, 5], [2, 10, 6]]) == [True, True, True, False]\n assert candidate(queries = [[1, 5], [2, 10, 3], [1, 6], [2, 10, 3], [2, 10, 4]]) == [True, True, True]\n assert candidate(queries = [[1, 3], [1, 6], [2, 6, 3], [2, 6, 4]]) == [True, False]\n assert candidate(queries = [[1, 3], [1, 6], [2, 10, 4], [1, 1], [2, 10, 9]]) == [True, False]\n assert candidate(queries = [[2, 10, 1], [1, 5], [2, 10, 5], [2, 10, 6]]) == [True, True, False]\n assert candidate(queries = [[1, 5], [1, 10], [2, 12, 7], [1, 8], [2, 15, 9]]) == [False, False]\n assert candidate(queries = [[1, 3], [1, 6], [2, 8, 4], [1, 5], [2, 10, 3]]) == [False, True]\n assert candidate(queries = [[1, 5], [2, 5, 4], [1, 15], [2, 15, 10], [2, 10, 3]]) == [True, True, True]\n assert candidate(queries = [[1, 3], [1, 6], [1, 9], [2, 12, 7], [2, 12, 5]]) == [False, False]\n assert candidate(queries = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 5, 3]]) == [False]\n assert candidate(queries = [[1, 1], [1, 2], [1, 3], [2, 3, 2], [2, 4, 2]]) == [False, False]\n assert candidate(queries = [[1, 10], [2, 10, 5], [1, 5], [2, 10, 3], [2, 5, 4]]) == [True, True, True]\n assert candidate(queries = [[1, 5], [1, 10], [2, 15, 4], [2, 15, 6], [1, 8], [2, 15, 7]]) == [True, False, False]\n assert candidate(queries = [[2, 10, 10], [1, 5], [2, 10, 4], [1, 3], [2, 10, 3]]) == [True, True, True]\n assert candidate(queries = [[2, 10, 3], [1, 5], [2, 10, 5], [1, 8], [2, 10, 2]]) == [True, True, True]\n assert candidate(queries = [[2, 5, 4], [1, 3], [2, 4, 1], [1, 4], [2, 5, 2]]) == [True, True, True]\n assert candidate(queries = [[1, 5], [1, 10], [1, 15], [2, 10, 3], [2, 20, 8]]) == [True, False]\n assert candidate(queries = [[2, 10, 5], [1, 5], [2, 5, 2], [1, 10], [2, 10, 5]]) == [True, True, True]\n assert candidate(queries = [[2, 5, 2], [1, 3], [1, 7], [2, 9, 4]]) == [True, True]\n assert candidate(queries = [[1, 1], [1, 2], [1, 3], [2, 3, 2], [2, 3, 3]]) == [False, False]\n assert candidate(queries = [[1, 10], [2, 15, 10], [1, 5], [2, 8, 3]]) == [True, True]\n assert candidate(queries = [[1, 5], [1, 10], [1, 15], [2, 15, 5], [2, 15, 10], [2, 15, 20]]) == [True, False, False]\n assert candidate(queries = [[1, 10], [2, 10, 5], [1, 5], [2, 10, 3], [2, 10, 6]]) == [True, True, False]\n assert candidate(queries = [[1, 1], [1, 2], [1, 3], [2, 4, 3], [2, 3, 1], [2, 5, 4]]) == [False, True, False]\n assert candidate(queries = [[1, 10], [2, 10, 9], [2, 10, 10], [2, 10, 11]]) == [True, True, False]\n assert candidate(queries = [[2, 5, 1], [1, 3], [2, 5, 2], [1, 4], [2, 5, 2]]) == [True, True, True]\n assert candidate(queries = [[2, 5, 2], [1, 2], [1, 3], [2, 5, 2], [2, 4, 2]]) == [True, True, True]\n assert candidate(queries = [[1, 10], [2, 15, 5], [2, 15, 10], [1, 5], [2, 15, 4]]) == [True, True, True]\n assert candidate(queries = [[1, 5], [2, 5, 4], [1, 3], [2, 3, 2], [2, 5, 3]]) == [True, True, True]\n assert candidate(queries = [[1, 10], [2, 10, 5], [1, 5], [2, 10, 4]]) == [True, True]\n assert candidate(queries = [[1, 1], [1, 3], [1, 5], [2, 4, 2], [2, 6, 3]]) == [True, False]\n assert candidate(queries = [[1, 10], [2, 10, 5], [1, 5], [2, 10, 5], [2, 5, 1]]) == [True, True, True]\n assert candidate(queries = [[2, 10, 1], [1, 5], [2, 10, 2], [1, 7], [2, 10, 3]]) == [True, True, True]\n assert candidate(queries = [[1, 10], [2, 10, 5], [1, 8], [2, 10, 7], [1, 6], [2, 10, 8]]) == [True, True, False]\n assert candidate(queries = [[1, 10], [2, 10, 5], [2, 10, 10], [1, 5], [2, 10, 5], [2, 10, 1], [2, 10, 9]]) == [True, True, True, True, False]\n assert candidate(queries = [[1, 5], [1, 3], [2, 6, 2], [2, 6, 4]]) == [True, False]\n assert candidate(queries = [[1, 5], [1, 10], [2, 8, 3], [1, 15], [2, 20, 5]]) == [True, True]\n assert candidate(queries = [[1, 10], [1, 5], [2, 10, 4], [2, 10, 5], [1, 3], [2, 10, 2]]) == [True, True, True]\n assert candidate(queries = [[2, 5, 2], [1, 3], [2, 4, 2], [1, 7], [2, 8, 6]]) == [True, True, False]\n assert candidate(queries = [[1, 5], [1, 10], [1, 15], [2, 20, 10], [2, 20, 15], [2, 20, 20]]) == [False, False, False]\n assert candidate(queries = [[2, 10, 5], [1, 5], [1, 10], [2, 10, 5]]) == [True, True]\n assert candidate(queries = [[1, 3], [1, 5], [2, 5, 2], [1, 7], [2, 10, 4]]) == [True, False]\n assert candidate(queries = [[1, 10], [2, 10, 5], [1, 3], [2, 10, 2], [2, 5, 3]]) == [True, True, True]\n assert candidate(queries = [[2, 5, 3], [1, 2], [1, 4], [2, 5, 2], [1, 3], [2, 5, 1]]) == [True, True, True]\n assert candidate(queries = [[1, 1], [1, 3], [1, 5], [1, 7], [2, 8, 2], [2, 8, 3], [2, 8, 4]]) == [True, False, False]\n assert candidate(queries = [[1, 3], [1, 5], [1, 7], [2, 8, 2]]) == [True]\n assert candidate(queries = [[1, 5], [1, 10], [2, 10, 4], [2, 10, 5]]) == [True, True]\n assert candidate(queries = [[1, 1], [2, 10, 1], [1, 5], [2, 10, 4], [1, 10], [2, 10, 3]]) == [True, True, True]\n assert candidate(queries = [[1, 5], [1, 10], [2, 15, 4], [2, 15, 6], [2, 15, 5]]) == [True, False, True]\n assert candidate(queries = [[1, 10], [1, 5], [2, 8, 2], [1, 3], [2, 6, 2]]) == [True, True]\n assert candidate(queries = [[2, 10, 5], [1, 3], [2, 10, 2], [1, 7], [2, 10, 3]]) == [True, True, True]\n assert candidate(queries = [[1, 1], [2, 2, 1], [2, 3, 2], [1, 2], [2, 3, 1]]) == [True, True, True]\n assert candidate(queries = [[1, 1], [1, 2], [1, 3], [1, 4], [2, 4, 3], [2, 4, 2], [2, 4, 1]]) == [False, False, True]\n assert candidate(queries = [[1, 10], [2, 10, 5], [2, 10, 10], [1, 5], [2, 5, 2]]) == [True, True, True]\n assert candidate(queries = [[1, 1], [1, 2], [1, 3], [2, 3, 1], [2, 3, 2], [2, 3, 3]]) == [True, False, False]\n assert candidate(queries = [[2, 15, 1], [1, 5], [2, 10, 5], [1, 10], [2, 15, 5]]) == [True, True, True]\n assert candidate(queries = [[2, 10, 5], [1, 3], [1, 7], [2, 10, 3], [1, 5], [2, 10, 2]]) == [True, True, True]\n assert candidate(queries = [[1, 5], [1, 8], [2, 8, 4], [1, 6], [2, 8, 3]]) == [True, True]\n assert candidate(queries = [[1, 1], [1, 2], [1, 3], [1, 4], [2, 5, 3], [2, 5, 1]]) == [False, True]\n assert candidate(queries = [[2, 5, 3], [1, 3], [2, 5, 2]]) == [True, True]\n assert candidate(queries = [[1, 5], [1, 10], [2, 7, 3], [1, 15], [2, 15, 6]]) == [True, False]\n assert candidate(queries = [[1, 1], [1, 2], [1, 3], [2, 3, 3], [2, 5, 2], [1, 4], [2, 4, 2]]) == [False, True, False]\n assert candidate(queries = [[1, 5], [1, 3], [2, 4, 2], [2, 6, 3]]) == [True, True]\n assert candidate(queries = [[1, 2], [1, 5], [1, 8], [2, 10, 3], [2, 10, 2], [2, 10, 1]]) == [True, True, True]\n assert candidate(queries = [[1, 2], [1, 4], [1, 6], [1, 8], [2, 10, 3]]) == [False]\n assert candidate(queries = [[1, 4], [2, 6, 3], [1, 2], [2, 8, 6], [1, 6], [2, 10, 5]]) == [True, False, False]\n assert candidate(queries = [[1, 5], [1, 10], [2, 9, 3], [1, 15], [2, 14, 5]]) == [True, True]\n assert candidate(queries = [[2, 10, 5], [1, 3], [1, 7], [2, 10, 5], [2, 10, 2]]) == [True, False, True]\n assert candidate(queries = [[2, 10, 5], [1, 3], [1, 7], [2, 10, 6], [1, 5], [2, 10, 4]]) == [True, False, False]\n assert candidate(queries = [[1, 10], [1, 5], [2, 12, 4], [2, 8, 3]]) == [True, True]\n assert candidate(queries = [[1, 1], [1, 2], [1, 3], [2, 3, 1], [2, 3, 2]]) == [True, False]\n assert candidate(queries = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 5, 4], [2, 10, 5]]) == [False, True]\n assert candidate(queries = [[1, 3], [1, 5], [1, 7], [2, 8, 2], [2, 8, 4], [2, 8, 6]]) == [True, False, False]\n assert candidate(queries = [[2, 10, 5], [1, 5], [2, 10, 4], [1, 8], [2, 10, 3]]) == [True, True, True]\n assert candidate(queries = [[1, 10], [1, 5], [2, 15, 5], [2, 10, 3], [1, 12], [2, 15, 4]]) == [True, True, True]\n assert candidate(queries = [[2, 5, 4], [1, 3], [2, 3, 2], [1, 5], [2, 5, 3]]) == [True, True, True]\n assert candidate(queries = [[1, 5], [1, 10], [2, 15, 6], [2, 15, 10], [2, 15, 11]]) == [False, False, False]\n assert candidate(queries = [[2, 1, 1], [1, 1], [2, 1, 1]]) == [True, True]\n assert candidate(queries = [[1, 5], [1, 10], [2, 8, 3], [2, 12, 5]]) == [True, True]\n assert candidate(queries = [[2, 10, 5], [1, 3], [2, 10, 3], [1, 7], [2, 10, 4]]) == [True, True, True]\n"}, "metadata": {"canonical_parameter_names": ["queries"], "leetcode_dataset_entry_point": "Solution().getResults", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector getResults(vector>& queries) {", "container": "Solution", "callable": "getResults", "parameters": [{"name": "queries", "type": "vector>&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3162, "task_id": "find-the-number-of-good-pairs-i", "difficulty": "Easy", "problem_description": "You are given 2 integer arrays nums1 and nums2 of lengths n and m respectively. You are also given a positive integer k.\nA pair (i, j) is called good if nums1[i] is divisible by nums2[j] * k (0 <= i <= n - 1, 0 <= j <= m - 1).\nReturn the total number of good pairs.\n \nExample 1:\n\nInput: nums1 = [1,3,4], nums2 = [1,3,4], k = 1\nOutput: 5\nExplanation:\nThe 5 good pairs are (0, 0), (1, 0), (1, 1), (2, 0), and (2, 2).\nExample 2:\n\nInput: nums1 = [1,2,4,12], nums2 = [2,4], k = 3\nOutput: 2\nExplanation:\nThe 2 good pairs are (3, 0) and (3, 1).\n\n \nConstraints:\n\n1 <= n, m <= 50\n1 <= nums1[i], nums2[j] <= 50\n1 <= k <= 50\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [7, 14, 21],nums2 = [1, 7],k = 3) == 2\n assert candidate(nums1 = [1, 3, 4],nums2 = [1, 3, 4],k = 1) == 5\n assert candidate(nums1 = [7, 14, 21],nums2 = [1, 7, 14],k = 1) == 7\n assert candidate(nums1 = [7, 14, 21],nums2 = [1, 7, 14],k = 3) == 2\n assert candidate(nums1 = [7, 14, 21],nums2 = [7, 14],k = 1) == 4\n assert candidate(nums1 = [20, 40, 60],nums2 = [5, 10],k = 4) == 4\n assert candidate(nums1 = [5, 10, 15],nums2 = [1, 2, 3],k = 5) == 5\n assert candidate(nums1 = [10, 20, 30],nums2 = [2, 5, 10],k = 1) == 9\n assert candidate(nums1 = [5, 10, 15],nums2 = [1, 5],k = 2) == 2\n assert candidate(nums1 = [10, 20, 30],nums2 = [5, 10],k = 2) == 4\n assert candidate(nums1 = [1, 2, 4, 12],nums2 = [2, 4],k = 3) == 2\n assert candidate(nums1 = [12, 24, 36, 48, 60, 72, 84, 96, 108],nums2 = [4, 8, 12],k = 4) == 5\n assert candidate(nums1 = [15, 30, 45, 60, 75, 90],nums2 = [1, 5, 15],k = 3) == 14\n assert candidate(nums1 = [8, 16, 24, 32],nums2 = [2, 4, 8],k = 2) == 10\n assert candidate(nums1 = [121, 242, 363, 484, 605],nums2 = [11, 121],k = 11) == 5\n assert candidate(nums1 = [12, 24, 36, 48, 60],nums2 = [1, 2, 3, 4, 5, 6],k = 4) == 16\n assert candidate(nums1 = [8, 16, 24, 32, 40],nums2 = [2, 4, 8],k = 4) == 8\n assert candidate(nums1 = [121, 242, 363, 484, 605],nums2 = [11, 22, 33],k = 11) == 8\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [2, 4, 5, 10],k = 5) == 9\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [5, 10, 20, 25, 50],k = 5) == 17\n assert candidate(nums1 = [25, 50, 75, 100, 125],nums2 = [5, 25],k = 5) == 6\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [2, 4, 5, 10],k = 2) == 10\n assert candidate(nums1 = [20, 40, 60, 80, 100],nums2 = [2, 4, 5, 10],k = 5) == 12\n assert candidate(nums1 = [8, 16, 24, 32, 40, 48, 56, 64, 72],nums2 = [1, 2, 4, 8],k = 2) == 31\n assert candidate(nums1 = [35, 70, 105, 140, 175, 210, 245],nums2 = [5, 7, 35],k = 7) == 9\n assert candidate(nums1 = [15, 30, 45, 60, 75, 90],nums2 = [1, 3, 5, 15],k = 2) == 12\n assert candidate(nums1 = [169, 338, 507, 676, 845],nums2 = [13, 26, 39],k = 13) == 8\n assert candidate(nums1 = [22, 44, 66, 88, 110],nums2 = [1, 2, 11],k = 11) == 10\n assert candidate(nums1 = [28, 56, 84, 112, 140],nums2 = [4, 7, 14],k = 4) == 8\n assert candidate(nums1 = [45, 90, 135, 180, 225],nums2 = [5, 9, 15, 45],k = 5) == 8\n assert candidate(nums1 = [18, 36, 54, 72, 90, 108, 126, 144, 162, 180],nums2 = [1, 2, 3, 4, 6, 9],k = 9) == 32\n assert candidate(nums1 = [225, 450, 675, 900, 1125],nums2 = [15, 30, 75],k = 15) == 8\n assert candidate(nums1 = [14, 28, 42, 56, 70, 84, 98, 112, 126, 140, 154, 168, 182, 196],nums2 = [2, 7, 14],k = 7) == 18\n assert candidate(nums1 = [8, 16, 24, 32, 40, 48, 56],nums2 = [2, 4, 8],k = 2) == 17\n assert candidate(nums1 = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130],nums2 = [1, 13, 26],k = 1) == 25\n assert candidate(nums1 = [18, 36, 54, 72, 90],nums2 = [1, 2, 3, 6, 9],k = 9) == 12\n assert candidate(nums1 = [35, 70, 105, 140, 175, 210, 245, 280, 315, 350],nums2 = [5, 7, 35],k = 5) == 14\n assert candidate(nums1 = [21, 42, 63, 84, 105],nums2 = [3, 7, 21],k = 7) == 5\n assert candidate(nums1 = [49, 98, 147, 196, 245],nums2 = [7, 14, 21],k = 7) == 8\n assert candidate(nums1 = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40],nums2 = [2, 4, 8],k = 4) == 8\n assert candidate(nums1 = [40, 80, 120, 160, 200, 240, 280, 320],nums2 = [4, 8, 20],k = 4) == 10\n assert candidate(nums1 = [11, 22, 33, 44, 55, 66, 77, 88, 99],nums2 = [1, 11],k = 11) == 9\n assert candidate(nums1 = [6, 12, 18, 24, 30],nums2 = [1, 2, 3, 4, 5],k = 2) == 14\n assert candidate(nums1 = [35, 70, 105, 140, 175, 210],nums2 = [5, 7, 35],k = 5) == 8\n assert candidate(nums1 = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60],nums2 = [2, 6, 12],k = 2) == 12\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [2, 5, 10],k = 2) == 9\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [5, 10, 25],k = 10) == 11\n assert candidate(nums1 = [36, 72, 108, 144, 180],nums2 = [2, 3, 6],k = 6) == 15\n assert candidate(nums1 = [42, 84, 126, 168, 210],nums2 = [6, 12, 21],k = 7) == 7\n assert candidate(nums1 = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169, 182, 195],nums2 = [1, 13],k = 13) == 16\n assert candidate(nums1 = [11, 22, 33, 44, 55, 66, 77, 88, 99],nums2 = [11, 22, 33],k = 1) == 16\n assert candidate(nums1 = [30, 60, 90, 120, 150, 180, 210],nums2 = [2, 5, 10],k = 6) == 13\n assert candidate(nums1 = [6, 12, 18, 24, 30, 36],nums2 = [1, 2, 3, 4, 6],k = 2) == 19\n assert candidate(nums1 = [25, 50, 75, 100, 125],nums2 = [5, 10, 25],k = 5) == 8\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60],nums2 = [5, 10, 15],k = 5) == 2\n assert candidate(nums1 = [33, 66, 99, 132, 165],nums2 = [11, 22, 33],k = 3) == 8\n assert candidate(nums1 = [3, 9, 27, 81],nums2 = [1, 3, 9],k = 3) == 9\n assert candidate(nums1 = [64, 128, 192, 256, 320],nums2 = [8, 16, 32],k = 4) == 12\n assert candidate(nums1 = [14, 28, 42, 56, 70],nums2 = [7, 14, 28],k = 2) == 8\n assert candidate(nums1 = [18, 36, 54, 72, 90, 108, 126, 144, 162, 180, 198, 216, 234, 252, 270],nums2 = [3, 6, 9, 18],k = 9) == 12\n assert candidate(nums1 = [15, 30, 45, 60, 75],nums2 = [3, 5, 15],k = 5) == 7\n assert candidate(nums1 = [45, 90, 135, 180, 225],nums2 = [5, 15, 45],k = 3) == 11\n assert candidate(nums1 = [18, 36, 54, 72, 90],nums2 = [2, 3, 6, 9, 18],k = 3) == 17\n assert candidate(nums1 = [60, 120, 180, 240],nums2 = [2, 5, 10],k = 4) == 8\n assert candidate(nums1 = [15, 30, 45, 60, 75, 90],nums2 = [3, 5, 15],k = 5) == 8\n assert candidate(nums1 = [49, 98, 147, 196, 245],nums2 = [7, 49],k = 7) == 5\n assert candidate(nums1 = [11, 22, 33, 44, 55],nums2 = [1, 11, 22],k = 5) == 2\n assert candidate(nums1 = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96],nums2 = [2, 4, 8],k = 8) == 10\n assert candidate(nums1 = [63, 126, 189, 252, 315],nums2 = [9, 21, 63],k = 9) == 1\n assert candidate(nums1 = [16, 32, 48, 64, 80, 96, 112, 128, 144, 160],nums2 = [2, 4, 8, 16],k = 8) == 18\n assert candidate(nums1 = [21, 42, 63, 84, 105, 126, 147, 168, 189, 210],nums2 = [3, 7, 21],k = 7) == 12\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [1, 5, 10],k = 10) == 13\n assert candidate(nums1 = [99, 198, 297, 396],nums2 = [9, 18, 27, 36],k = 9) == 0\n assert candidate(nums1 = [16, 32, 48, 64, 80],nums2 = [4, 8, 16],k = 4) == 8\n assert candidate(nums1 = [18, 36, 54, 72, 90],nums2 = [6, 9, 18],k = 3) == 7\n assert candidate(nums1 = [121, 143, 165, 187],nums2 = [11, 13, 15],k = 11) == 3\n assert candidate(nums1 = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],nums2 = [3, 6, 9],k = 3) == 18\n assert candidate(nums1 = [12, 24, 36, 48, 60],nums2 = [3, 6, 12],k = 4) == 8\n assert candidate(nums1 = [12, 18, 24, 36, 48],nums2 = [1, 3, 4, 6, 12],k = 2) == 18\n assert candidate(nums1 = [100, 150, 200, 250],nums2 = [5, 10, 20],k = 5) == 10\n assert candidate(nums1 = [20, 40, 60, 80, 100],nums2 = [4, 8, 20],k = 5) == 8\n assert candidate(nums1 = [15, 30, 45, 60, 75],nums2 = [3, 5, 15],k = 3) == 7\n assert candidate(nums1 = [7, 14, 21, 28, 35, 42, 49, 56],nums2 = [1, 7, 14],k = 1) == 20\n assert candidate(nums1 = [25, 50, 75, 100, 125],nums2 = [1, 5, 25],k = 5) == 11\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [2, 5, 10],k = 5) == 7\n assert candidate(nums1 = [25, 50, 75, 100, 125, 150],nums2 = [5, 10, 25],k = 5) == 10\n assert candidate(nums1 = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110],nums2 = [1, 11],k = 11) == 10\n assert candidate(nums1 = [33, 66, 99, 132, 165],nums2 = [11, 33],k = 3) == 6\n assert candidate(nums1 = [81, 108, 144, 180],nums2 = [9, 18, 27],k = 3) == 4\n assert candidate(nums1 = [24, 48, 72, 96, 120],nums2 = [8, 12, 24],k = 4) == 4\n assert candidate(nums1 = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500],nums2 = [5, 10, 25, 50],k = 10) == 18\n assert candidate(nums1 = [30, 60, 90, 120],nums2 = [2, 5, 10],k = 6) == 8\n assert candidate(nums1 = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180],nums2 = [3, 5, 15],k = 5) == 16\n assert candidate(nums1 = [45, 90, 135, 180],nums2 = [3, 9, 15],k = 5) == 8\n assert candidate(nums1 = [12, 24, 36, 48, 60],nums2 = [2, 4, 6, 8, 10],k = 4) == 5\n assert candidate(nums1 = [24, 36, 48],nums2 = [2, 3, 6, 12],k = 4) == 8\n assert candidate(nums1 = [21, 42, 63, 84, 105, 126],nums2 = [7, 14, 21],k = 3) == 11\n assert candidate(nums1 = [12, 18, 24, 30, 36, 42],nums2 = [2, 3, 4],k = 6) == 6\n assert candidate(nums1 = [9, 18, 27, 36, 45],nums2 = [3, 6, 9],k = 3) == 8\n assert candidate(nums1 = [9, 18, 27, 36, 45, 54, 63, 72, 81],nums2 = [1, 3, 9],k = 3) == 21\n assert candidate(nums1 = [8, 16, 24, 32, 40],nums2 = [2, 4, 8],k = 2) == 12\n assert candidate(nums1 = [28, 56, 84, 112],nums2 = [7, 14, 21],k = 7) == 0\n assert candidate(nums1 = [25, 50, 75, 100, 125, 150],nums2 = [5, 10, 25],k = 5) == 10\n assert candidate(nums1 = [15, 25, 35, 45, 55],nums2 = [5, 10, 15],k = 5) == 1\n assert candidate(nums1 = [7, 14, 21, 28, 35, 42, 49],nums2 = [1, 7, 14],k = 7) == 8\n assert candidate(nums1 = [9, 18, 27, 36, 45],nums2 = [1, 3, 9],k = 3) == 11\n"}, "metadata": {"canonical_parameter_names": ["nums1", "nums2", "k"], "leetcode_dataset_entry_point": "Solution().numberOfPairs", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int numberOfPairs(vector& nums1, vector& nums2, int k) {", "container": "Solution", "callable": "numberOfPairs", "parameters": [{"name": "nums1", "type": "vector&"}, {"name": "nums2", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3163, "task_id": "string-compression-iii", "difficulty": "Medium", "problem_description": "Given a string word, compress it using the following algorithm:\n\nBegin with an empty string comp. While word is not empty, use the following operation:\n\n\t\nRemove a maximum length prefix of word made of a single character c repeating at most 9 times.\nAppend the length of the prefix followed by c to comp.\n\n\n\nReturn the string comp.\n \nExample 1:\n\nInput: word = \"abcde\"\nOutput: \"1a1b1c1d1e\"\nExplanation:\nInitially, comp = \"\". Apply the operation 5 times, choosing \"a\", \"b\", \"c\", \"d\", and \"e\" as the prefix in each operation.\nFor each prefix, append \"1\" followed by the character to comp.\n\nExample 2:\n\nInput: word = \"aaaaaaaaaaaaaabb\"\nOutput: \"9a5a2b\"\nExplanation:\nInitially, comp = \"\". Apply the operation 3 times, choosing \"aaaaaaaaa\", \"aaaaa\", and \"bb\" as the prefix in each operation.\n\nFor prefix \"aaaaaaaaa\", append \"9\" followed by \"a\" to comp.\nFor prefix \"aaaaa\", append \"5\" followed by \"a\" to comp.\nFor prefix \"bb\", append \"2\" followed by \"b\" to comp.\n\n\n \nConstraints:\n\n1 <= word.length <= 2 * 105\nword consists only of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word = \"pppppppppppppppppppppppppppppppppppppp\") == \"9p9p9p9p2p\"\n assert candidate(word = \"abcde\") == \"1a1b1c1d1e\"\n assert candidate(word = \"aabbcc\") == \"2a2b2c\"\n assert candidate(word = \"aaaaaaaaaaaaaabb\") == \"9a5a2b\"\n assert candidate(word = \"ababababab\") == \"1a1b1a1b1a1b1a1b1a1b\"\n assert candidate(word = \"aaaaaaaaaabbbbbbbbbccccccccddddddddd\") == \"9a1a9b8c9d\"\n assert candidate(word = \"aabcccccaaa\") == \"2a1b5c3a\"\n assert candidate(word = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == \"2a2b2c2d2e2f2g2h2i2j2k2l2m2n2o2p2q2r2s2t2u2v2w2x2y2z\"\n assert candidate(word = \"aabbccddeeffgghhiijj\") == \"2a2b2c2d2e2f2g2h2i2j\"\n assert candidate(word = \"zzzzzzzzzz\") == \"9z1z\"\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"9z9z9z9z9z5z\"\n assert candidate(word = \"a\") == \"1a\"\n assert candidate(word = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzz\") == \"2a2b2c2d2e2f2g2h2i2j2k2l2m2n2o2p2q2r2s2t2u2v2w2x2y9z1z\"\n assert candidate(word = \"mmmmmmmmmmnnnnnnnnnnoooooooooollllllllkkkkkkkkkjjjjjjjjjiiiiiiiii\") == \"9m1m9n1n9o1o8l9k9j9i\"\n assert candidate(word = \"abcdefghijklmnopqrstuvwxzyz\") == \"1a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1z1y1z\"\n assert candidate(word = \"abababababababababab\") == \"1a1b1a1b1a1b1a1b1a1b1a1b1a1b1a1b1a1b1a1b\"\n assert candidate(word = \"zzzzyyyyxxxxwwwwvvvvuuuuttttssssrrrrqqqqppppllllkkkkjjjjiiggggffffeeeeddddccccbbbbaaa\") == \"4z4y4x4w4v4u4t4s4r4q4p4l4k4j2i4g4f4e4d4c4b3a\"\n assert candidate(word = \"a9b9c9d9e9f9g9h9i9j9k9l9m9n9o9p9q9r9s9t9u9v9w9x9y9z9\") == \"1a191b191c191d191e191f191g191h191i191j191k191l191m191n191o191p191q191r191s191t191u191v191w191x191y191z19\"\n assert candidate(word = \"aaaaaaaaaabbbbbbbbbccccccccddddddddeeeeeeeeeeffffffffffgggggggggghhhhhhhhhhiiiiiiiiiijjjjjjjjjjkkkkkkkkkkllllllllllmmmmmmmmmmnnnnnnnnnnooooooooooppppppppppqqqqqqqqqqrrrrrrrrrrssssssssssttttttttttuuuuuuuuuuvvvvvvvvvvwwwwwwwwwwxxxxxxxxxxxyyyyyyyyyyzzzzzzzzzz\") == \"9a1a9b8c8d9e1e9f1f9g1g9h1h9i1i9j1j9k1k9l1l9m1m9n1n9o1o9p1p9q1q9r1r9s1s9t1t9u1u9v1v9w1w9x2x9y1y9z1z\"\n assert candidate(word = \"aaaaaabbccccddeeeeeeffffgggghhhhiiiiiijjjjkkkkklllllmmmmmnnnnooooo\") == \"6a2b4c2d6e4f4g4h6i4j5k5l5m4n5o\"\n assert candidate(word = \"abababababababababababababababababababab\") == \"1a1b1a1b1a1b1a1b1a1b1a1b1a1b1a1b1a1b1a1b1a1b1a1b1a1b1a1b1a1b1a1b1a1b1a1b1a1b1a1b\"\n assert candidate(word = \"aaabbbcccddd\") == \"3a3b3c3d\"\n assert candidate(word = \"aaaaaaaaaabbbbbbbbbbccccccccccdddddddddeeeeeeeeeeffffffffffgggggggggghhhhhhhhhh\") == \"9a1a9b1b9c1c9d9e1e9f1f9g1g9h1h\"\n assert candidate(word = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == \"9a9a9a9a9a9a9a9a\"\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == \"1a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z\"\n"}, "metadata": {"canonical_parameter_names": ["word"], "leetcode_dataset_entry_point": "Solution().compressedString", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string compressedString(string word) {", "container": "Solution", "callable": "compressedString", "parameters": [{"name": "word", "type": "string"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3164, "task_id": "find-the-number-of-good-pairs-ii", "difficulty": "Medium", "problem_description": "You are given 2 integer arrays nums1 and nums2 of lengths n and m respectively. You are also given a positive integer k.\nA pair (i, j) is called good if nums1[i] is divisible by nums2[j] * k (0 <= i <= n - 1, 0 <= j <= m - 1).\nReturn the total number of good pairs.\n \nExample 1:\n\nInput: nums1 = [1,3,4], nums2 = [1,3,4], k = 1\nOutput: 5\nExplanation:\nThe 5 good pairs are (0, 0), (1, 0), (1, 1), (2, 0), and (2, 2).\nExample 2:\n\nInput: nums1 = [1,2,4,12], nums2 = [2,4], k = 3\nOutput: 2\nExplanation:\nThe 2 good pairs are (3, 0) and (3, 1).\n\n \nConstraints:\n\n1 <= n, m <= 105\n1 <= nums1[i], nums2[j] <= 106\n1 <= k <= 103\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [7, 14, 21],nums2 = [1, 7, 14],k = 7) == 3\n assert candidate(nums1 = [1, 3, 4],nums2 = [1, 3, 4],k = 1) == 5\n assert candidate(nums1 = [100, 200, 300],nums2 = [10, 20, 30],k = 10) == 5\n assert candidate(nums1 = [5, 10, 15],nums2 = [1, 5, 10],k = 1) == 7\n assert candidate(nums1 = [7, 14, 28],nums2 = [1, 2, 4],k = 7) == 6\n assert candidate(nums1 = [1, 2, 4, 12],nums2 = [2, 4],k = 3) == 2\n assert candidate(nums1 = [100, 200, 300],nums2 = [5, 10, 15],k = 5) == 7\n assert candidate(nums1 = [5, 10, 15, 20],nums2 = [1, 2, 5],k = 2) == 5\n assert candidate(nums1 = [999999, 999998, 999997, 999996, 999995],nums2 = [1, 2, 3, 4, 5],k = 100) == 0\n assert candidate(nums1 = [7, 14, 21, 28, 35],nums2 = [1, 2, 3, 4, 5, 6, 7],k = 7) == 10\n assert candidate(nums1 = [7, 14, 21, 28, 35],nums2 = [1, 7, 14, 21, 28, 35],k = 1) == 15\n assert candidate(nums1 = [6, 12, 18, 24, 30],nums2 = [2, 3, 6],k = 2) == 9\n assert candidate(nums1 = [999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 100) == 0\n assert candidate(nums1 = [1000, 2000, 3000, 4000, 5000],nums2 = [5, 10, 15, 20, 25, 30],k = 10) == 22\n assert candidate(nums1 = [12, 24, 36, 48, 60],nums2 = [1, 2, 3, 4, 5, 6],k = 2) == 23\n assert candidate(nums1 = [100000, 200000, 300000, 400000],nums2 = [100, 200, 300, 400],k = 10) == 13\n assert candidate(nums1 = [120, 180, 240, 300],nums2 = [5, 10, 15, 20, 25, 30],k = 6) == 13\n assert candidate(nums1 = [72, 144, 216, 288, 360],nums2 = [8, 12, 24, 36],k = 3) == 16\n assert candidate(nums1 = [810, 1620, 2430, 3240, 4050, 4860, 5490, 6120, 6840, 7560],nums2 = [5, 10, 15, 18, 20, 25, 30, 45, 60, 90],k = 5) == 16\n assert candidate(nums1 = [500000, 750000, 1000000, 1250000, 1500000],nums2 = [100, 250, 500, 1250, 2500],k = 20) == 25\n assert candidate(nums1 = [987654, 876543, 765432, 654321, 543210],nums2 = [98765, 87654, 76543, 65432, 54321],k = 10) == 1\n assert candidate(nums1 = [210, 330, 450, 570],nums2 = [3, 6, 9, 12],k = 5) == 9\n assert candidate(nums1 = [101, 202, 303, 404, 505],nums2 = [1, 101, 202, 303, 404],k = 1) == 14\n assert candidate(nums1 = [333, 666, 999, 1332, 1665],nums2 = [3, 6, 9, 12, 15],k = 3) == 10\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1],k = 1) == 50\n assert candidate(nums1 = [999999, 999998, 999997],nums2 = [999, 998, 997],k = 1) == 1\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1],k = 1) == 25\n assert candidate(nums1 = [987654321, 987654322, 987654323, 987654324],nums2 = [987, 988, 989, 990],k = 987) == 0\n assert candidate(nums1 = [999999, 999998, 999997, 999996, 999995],nums2 = [999, 998, 997, 996, 995],k = 1000) == 0\n assert candidate(nums1 = [104729, 209458, 314187, 418916, 523645, 628374, 733103, 837832, 942561],nums2 = [104729, 209458, 314187],k = 1) == 16\n assert candidate(nums1 = [120, 150, 180, 210],nums2 = [3, 5, 6, 7],k = 4) == 5\n assert candidate(nums1 = [1000000, 2000000, 3000000, 4000000, 5000000],nums2 = [1000, 2000, 3000, 4000, 5000],k = 500) == 14\n assert candidate(nums1 = [333, 666, 999, 1332, 1665],nums2 = [3, 9, 27, 81],k = 3) == 6\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 100\n assert candidate(nums1 = [999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990],nums2 = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990],k = 10) == 0\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 55\n assert candidate(nums1 = [1000000, 999999, 999998],nums2 = [1, 2, 3, 4, 5],k = 1000) == 4\n assert candidate(nums1 = [1000000, 2000000, 3000000],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1000) == 20\n assert candidate(nums1 = [500, 1000, 1500, 2000, 2500],nums2 = [5, 10, 25],k = 4) == 12\n assert candidate(nums1 = [1000000, 1000000, 1000000, 1000000],nums2 = [1, 2, 4, 5],k = 1000) == 16\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [10, 20, 30, 40, 50],k = 5) == 14\n assert candidate(nums1 = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],nums2 = [1, 7, 14, 21, 28, 35, 42, 49, 56, 63, 70],k = 7) == 11\n assert candidate(nums1 = [500, 1000, 1500, 2000, 2500],nums2 = [25, 50, 75],k = 2) == 11\n assert candidate(nums1 = [987654, 321456, 789123, 123456, 456789],nums2 = [123, 321, 654, 456, 789],k = 23) == 0\n assert candidate(nums1 = [111111, 222222, 333333, 444444, 555555],nums2 = [11, 22, 33, 44, 55],k = 11) == 0\n assert candidate(nums1 = [555555, 666666, 777777, 888888, 999999],nums2 = [5, 6, 7, 8, 9, 55, 66, 77, 88, 99],k = 111) == 18\n assert candidate(nums1 = [300000, 300000, 300000, 300000, 300000],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 15000) == 25\n assert candidate(nums1 = [101, 202, 303, 404, 505, 606, 707, 808, 909],nums2 = [1, 10, 100, 1000],k = 1) == 9\n assert candidate(nums1 = [999999, 888888, 777777, 666666, 555555],nums2 = [111111, 222222, 333333, 444444, 555555],k = 111) == 0\n assert candidate(nums1 = [1024, 2048, 4096, 8192],nums2 = [32, 64, 128],k = 16) == 11\n assert candidate(nums1 = [123456, 234567, 345678, 456789],nums2 = [123, 234, 345, 456],k = 7) == 0\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 100\n assert candidate(nums1 = [999999, 888888, 777777, 666666],nums2 = [333333, 222222, 111111],k = 3) == 4\n assert candidate(nums1 = [1000, 2000, 3000, 4000, 5000],nums2 = [10, 20, 30, 40, 50],k = 10) == 18\n assert candidate(nums1 = [1000000, 500000, 250000, 125000, 62500],nums2 = [125, 250, 500],k = 2) == 14\n assert candidate(nums1 = [210, 420, 630, 840, 1050],nums2 = [1, 2, 3, 5, 6, 7, 10, 14, 15, 21, 30, 35, 42, 70, 105, 210],k = 2) == 56\n assert candidate(nums1 = [100000, 200000, 300000, 400000, 500000],nums2 = [50000, 100000, 150000, 200000, 250000],k = 1000) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1],k = 1) == 25\n assert candidate(nums1 = [999999],nums2 = [1, 3, 9, 27, 81],k = 10000) == 0\n assert candidate(nums1 = [123456, 234567, 345678, 456789, 567890],nums2 = [123, 456, 789],k = 12) == 0\n assert candidate(nums1 = [12345, 67890, 11111, 22222, 33333],nums2 = [3, 9, 27, 81, 243],k = 3) == 0\n assert candidate(nums1 = [1000, 2000, 3000, 4000, 5000],nums2 = [1, 2, 5, 10, 20],k = 25) == 25\n assert candidate(nums1 = [101, 202, 303, 404, 505],nums2 = [1, 2, 3, 4, 5, 6],k = 101) == 10\n assert candidate(nums1 = [1000000, 1000000, 1000000],nums2 = [1, 10, 100, 1000],k = 100) == 12\n assert candidate(nums1 = [500000, 600000, 700000, 800000],nums2 = [50000, 60000, 70000, 80000],k = 10) == 4\n assert candidate(nums1 = [987654, 456789, 123456, 654321],nums2 = [6, 12, 18, 24, 30, 36, 42],k = 7) == 0\n assert candidate(nums1 = [987654, 987654, 987654, 987654, 987654],nums2 = [123456, 246912, 370368, 493824, 617280],k = 61728) == 0\n assert candidate(nums1 = [97, 194, 291, 388, 485],nums2 = [1, 97, 194],k = 1) == 12\n assert candidate(nums1 = [77, 143, 209, 275],nums2 = [7, 11, 13, 17],k = 1) == 6\n assert candidate(nums1 = [1000000, 1000000, 1000000, 1000000, 1000000],nums2 = [1, 1, 1, 1, 1],k = 1000000) == 25\n assert candidate(nums1 = [555555, 444444, 333333, 222222, 111111],nums2 = [111111, 222222, 333333, 444444, 555555],k = 11111) == 0\n assert candidate(nums1 = [21, 42, 63, 84, 105],nums2 = [3, 7, 21],k = 1) == 15\n assert candidate(nums1 = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],nums2 = [1, 2, 4, 5, 10, 20, 25, 50, 100],k = 1) == 90\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 2, 3, 4, 5],k = 1) == 22\n assert candidate(nums1 = [7, 14, 21, 28, 35, 42, 49],nums2 = [1, 2, 3, 4, 5, 6, 7],k = 7) == 16\n assert candidate(nums1 = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953],nums2 = [5, 10, 15, 20, 25],k = 50) == 21\n assert candidate(nums1 = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 100000) == 40\n assert candidate(nums1 = [123456, 234567, 345678, 456789],nums2 = [123, 234, 345, 456],k = 3) == 0\n assert candidate(nums1 = [123456, 234567, 345678, 456789],nums2 = [123, 234, 345],k = 6) == 0\n assert candidate(nums1 = [12, 24, 36, 48, 60],nums2 = [1, 2, 3, 4, 5, 6],k = 2) == 23\n assert candidate(nums1 = [123456, 654321, 111111, 222222],nums2 = [123, 321, 111, 222, 444],k = 3) == 0\n assert candidate(nums1 = [1024, 2048, 4096, 8192, 16384],nums2 = [16, 32, 64, 128, 256],k = 32) == 19\n assert candidate(nums1 = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 100) == 67\n assert candidate(nums1 = [100000, 200000, 300000, 400000],nums2 = [1, 2, 3, 4, 5],k = 100) == 17\n assert candidate(nums1 = [1000000, 900000, 800000, 700000],nums2 = [100, 200, 300, 400],k = 25) == 13\n assert candidate(nums1 = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 40\n assert candidate(nums1 = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],nums2 = [1, 2, 3, 4, 5, 6, 9, 10, 12, 15, 18, 30],k = 4) == 6\n assert candidate(nums1 = [123456, 234567, 345678, 456789, 567890],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 123) == 0\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30],nums2 = [1, 5, 10, 15, 20, 25, 30],k = 5) == 7\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 3, 5, 7, 9],k = 1) == 17\n assert candidate(nums1 = [111111, 222222, 333333, 444444, 555555],nums2 = [111, 222, 333, 444, 555],k = 111) == 0\n assert candidate(nums1 = [100000, 200000, 300000, 400000, 500000, 600000],nums2 = [100, 200, 300, 400, 500, 600],k = 1000) == 14\n assert candidate(nums1 = [777777, 888888, 999999],nums2 = [7, 8, 9, 77, 88, 99, 777, 888, 999],k = 11) == 10\n"}, "metadata": {"canonical_parameter_names": ["nums1", "nums2", "k"], "leetcode_dataset_entry_point": "Solution().numberOfPairs", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "long long numberOfPairs(vector& nums1, vector& nums2, int k) {", "container": "Solution", "callable": "numberOfPairs", "parameters": [{"name": "nums1", "type": "vector&"}, {"name": "nums2", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "long long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3165, "task_id": "maximum-sum-of-subsequence-with-non-adjacent-elements", "difficulty": "Hard", "problem_description": "You are given an array nums consisting of integers. You are also given a 2D array queries, where queries[i] = [posi, xi].\nFor query i, we first set nums[posi] equal to xi, then we calculate the answer to query i which is the maximum sum of a subsequence of nums where no two adjacent elements are selected.\nReturn the sum of the answers to all queries.\nSince the final answer may be very large, return it modulo 109 + 7.\nA subsequence is an array that can be derived from another array by deleting some or no elements without changing the order of the remaining elements.\n \nExample 1:\n\nInput: nums = [3,5,9], queries = [[1,-2],[0,-3]]\nOutput: 21\nExplanation:\nAfter the 1st query, nums = [3,-2,9] and the maximum sum of a subsequence with non-adjacent elements is 3 + 9 = 12.\nAfter the 2nd query, nums = [-3,-2,9] and the maximum sum of a subsequence with non-adjacent elements is 9.\n\nExample 2:\n\nInput: nums = [0,-1], queries = [[0,-5]]\nOutput: 0\nExplanation:\nAfter the 1st query, nums = [-5,-1] and the maximum sum of a subsequence with non-adjacent elements is 0 (choosing an empty subsequence).\n\n \nConstraints:\n\n1 <= nums.length <= 5 * 104\n-105 <= nums[i] <= 105\n1 <= queries.length <= 5 * 104\nqueries[i] == [posi, xi]\n0 <= posi <= nums.length - 1\n-105 <= xi <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [100, 200, 300, 400, 500],queries = [[0, -100], [2, -200], [4, -300]]) == 2100\n assert candidate(nums = [1, 2, 3, 4, 5],queries = [[0, 10], [4, -10], [2, 0]]) == 46\n assert candidate(nums = [-1, -2, -3, -4, -5],queries = [[1, 2], [3, 4], [4, 5]]) == 15\n assert candidate(nums = [3, 5, 9],queries = [[1, -2], [0, -3]]) == 21\n assert candidate(nums = [0, -1],queries = [[0, -5]]) == 0\n assert candidate(nums = [100000, -100000, 100000, -100000, 100000],queries = [[0, -100000], [2, -100000], [4, -100000]]) == 300000\n assert candidate(nums = [1, 2, 3, 4, 5],queries = [[0, 5], [2, 1], [4, -1]]) == 33\n assert candidate(nums = [100000, -100000, 50000, -50000],queries = [[0, 50000], [1, -50000], [2, 100000], [3, -100000]]) == 500000\n assert candidate(nums = [1, 2, 3, 4, 5],queries = [[0, 5], [2, -1], [4, 10]]) == 38\n assert candidate(nums = [-10, -20, -30, -40],queries = [[1, 10], [3, 20]]) == 40\n assert candidate(nums = [-5, -4, -3, -2, -1],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == 22\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1],queries = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0]]) == 20\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[0, -100000], [1, -99999], [2, -99998], [3, -99997], [4, -99996], [5, -99995], [6, -99994], [7, -99993], [8, -99992], [9, -99991]]) == 1900\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],queries = [[0, -100000], [1, -100000], [2, -100000], [3, -100000], [4, -100000]]) == 1900000\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],queries = [[0, 30], [1, 28], [2, 26], [3, 24], [4, 22], [5, 20], [6, 18], [7, 16], [8, 14], [9, 12], [10, 10], [11, 8], [12, 6], [13, 4], [14, 2]]) == 2536\n assert candidate(nums = [1, 3, 2, 1, 100, 1, 1, 1, 1, 1],queries = [[4, 200], [4, 300], [4, 400], [4, 500], [4, 600]]) == 2025\n assert candidate(nums = [-100000, -90000, -80000, -70000, -60000, -50000, -40000, -30000, -20000, -10000],queries = [[0, -50000], [2, -30000], [4, -10000]]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[1, 0], [3, 0], [5, 0], [7, 0], [9, 0]]) == 1350\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 153\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, -1], [1, -2], [2, -3], [3, -4], [4, -5], [5, -6], [6, -7], [7, -8], [8, -9], [9, -10]]) == 190\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queries = [[0, 0], [2, 0], [4, 0], [6, 0], [8, 0]]) == 15000\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],queries = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0]]) == 80\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996],queries = [[0, 99995], [4, 99994], [2, 99993], [1, 99992], [3, 99991]]) == 1499922\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 125\n assert candidate(nums = [1, 2, 3, 4, 5],queries = [[0, 10], [0, 20], [0, 30], [0, 40], [0, 50]]) == 190\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10],queries = [[0, 10], [1, -10], [2, 10], [3, -10], [4, 10], [5, -10], [6, 10], [7, -10], [8, 10], [9, -10]]) == 440\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50],queries = [[0, 100], [1, -100], [2, 200], [3, -200], [4, 300], [5, -300], [6, 400], [7, -400], [8, 500], [9, -500]]) == 7800\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, -1], [2, -1], [4, -1], [6, -1], [8, -1]]) == 150\n assert candidate(nums = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1],queries = [[0, 100000], [1, 100000], [2, 100000], [3, 100000], [4, 100000], [5, 100000], [6, 100000], [7, 100000], [8, 100000], [9, 100000]]) == 3000020\n assert candidate(nums = [-99999, 99999, -99998, 99998, -99997, 99997, -99996, 99996, -99995, 99995],queries = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0]]) == 2499905\n assert candidate(nums = [-100000, -100000, -100000, -100000, -100000],queries = [[0, 100000], [1, 100000], [2, 100000], [3, 100000], [4, 100000]]) == 900000\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 125\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 10], [1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10]]) == 460\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]]) == 430\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],queries = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 165\n assert candidate(nums = [100000, -100000, 90000, -90000, 80000, -80000, 70000, -70000, 60000, -60000],queries = [[0, 100000], [1, -100000], [2, 90000], [3, -90000], [4, 80000], [5, -80000], [6, 70000], [7, -70000], [8, 60000], [9, -60000]]) == 4000000\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 125\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[0, -100], [1, 100], [2, -200], [3, 200], [4, -300], [5, 300], [6, -400], [7, 400], [8, -500], [9, 500]]) == 7400\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]) == 150\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[0, 5], [1, 15], [2, 25], [3, 35], [4, 45], [5, 55], [6, 65], [7, 75], [8, 85], [9, 95]]) == 2875\n assert candidate(nums = [100000, -100000, 50000, -50000, 25000, -25000],queries = [[0, 100000], [1, 0], [2, -50000], [3, 0], [4, 25000], [5, 0]]) == 850000\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queries = [[0, 1000], [1, 900], [2, 800], [3, 700], [4, 600], [5, 500], [6, 400], [7, 300], [8, 200], [9, 100]]) == 39200\n assert candidate(nums = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 10], [1, -10], [2, 20], [3, -20], [4, 30], [5, -30]]) == 364\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, -1], [9, -10], [5, -6], [2, -3]]) == 101\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000],queries = [[0, -100000], [1, -100000], [2, -100000], [3, -100000], [4, -100000]]) == 600000\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],queries = [[0, 1], [2, 2], [4, 3], [6, 4], [8, 5], [1, 5], [3, 4], [5, 3], [7, 2], [9, 1]]) == 124\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 10], [1, 20], [2, 30], [3, 40], [4, 50], [5, 60], [6, 70], [7, 80], [8, 90], [9, 100]]) == 1410\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991],queries = [[0, 0], [2, 0], [4, 0], [6, 0], [8, 0]]) == 2499875\n assert candidate(nums = [1, 2, 3, 4, 5],queries = [[0, 5], [1, 4], [2, 3], [3, 2], [4, 1], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == 92\n assert candidate(nums = [50000, -50000, 50000, -50000, 50000],queries = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]]) == 300000\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[0, 2], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2], [8, 2], [9, 2]]) == 80\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],queries = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0]]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5],queries = [[0, -1], [1, -2], [2, -3], [3, -4], [4, -5], [0, 5], [1, 4], [2, 3], [3, 2], [4, 1]]) == 61\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queries = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0]]) == 19000\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1],queries = [[0, 1000], [1, 1000], [2, 1000], [3, 1000], [4, 1000]]) == 9016\n assert candidate(nums = [5, 8, 2, 7, 10, 1, 5, 3, 4, 6],queries = [[0, -5], [1, -8], [2, -2], [3, -7], [4, -10], [5, -1], [6, -5], [7, -3], [8, -4], [9, -6]]) == 137\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queries = [[0, -100], [1, -200], [2, -300], [3, -400], [4, -500], [5, -600], [6, -700], [7, -800], [8, -900], [9, -1000]]) == 19000\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],queries = [[1, 1], [3, 1], [5, 1], [7, 1], [9, 1]]) == 15\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == 2370\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 10], [2, 20], [4, 30], [6, 40], [8, 50], [9, 60]]) == 590\n assert candidate(nums = [10000, -20000, 30000, -40000, 50000, -60000, 70000, -80000, 90000, -100000],queries = [[0, 10000], [1, -10000], [2, 10000], [3, -10000], [4, 10000], [5, -10000], [6, 10000], [7, -10000], [8, 10000], [9, -10000]]) == 1700000\n assert candidate(nums = [100000, -100000, 100000, -100000, 100000, -100000, 100000, -100000],queries = [[0, -1], [1, 1], [2, -1], [3, 1], [4, -1], [5, 1], [6, -1], [7, 1]]) == 1200013\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, -1], [2, -3], [4, -5], [6, -7], [8, -9]]) == 150\n assert candidate(nums = [50000, -50000, 50000, -50000, 50000, -50000, 50000, -50000, 50000, -50000],queries = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0]]) == 1000000\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50],queries = [[0, 50000], [1, 50000], [2, 50000], [3, 50000], [4, 50000], [5, 50000], [6, 50000], [7, 50000], [8, 50000], [9, 50000]]) == 1500800\n assert candidate(nums = [100000, -100000, 50000, -50000, 25000, -25000, 75000, -75000, 125000, -125000],queries = [[0, -100000], [1, 100000], [2, -50000], [3, 50000], [4, -25000], [5, 25000], [6, -75000], [7, 75000], [8, -125000], [9, 125000]]) == 3200000\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],queries = [[0, 15], [1, 10], [2, 5], [3, 0], [4, -5], [5, -10], [6, -15], [7, -20], [8, -25], [9, -30]]) == 1125\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 100], [2, 200], [4, 300], [6, 400], [8, 500]]) == 3580\n assert candidate(nums = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],queries = [[0, -100000], [1, -90000], [2, -80000], [3, -70000], [4, -60000], [5, -50000], [6, -40000], [7, -30000], [8, -20000], [9, -10000]]) == 950000\n assert candidate(nums = [123456],queries = [[0, -123456]]) == 0\n assert candidate(nums = [1, 2, 3, -1, -2, -3, 4, 5, 6, -4, -5, -6],queries = [[0, 10], [3, 20], [6, 30], [9, 40], [11, 50]]) == 379\n assert candidate(nums = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000],queries = [[0, -1000], [1, 200], [2, -300], [3, 400], [4, -500], [5, 600], [6, -700], [7, 800], [8, -900], [9, 1000]]) == 23000\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],queries = [[0, 20], [1, 18], [2, 16], [3, 14], [4, 12], [5, 10], [6, 8], [7, 6], [8, 4], [9, 2]]) == 762\n assert candidate(nums = [1, -10, 2, -20, 3, -30, 4, -40, 5, -50],queries = [[0, 10], [2, 20], [4, 30], [6, 40], [8, 50]]) == 390\n assert candidate(nums = [-100000, -99999, -99998, -99997, -99996],queries = [[0, -99995], [4, -99994], [2, -99993], [1, -99992], [3, -99991]]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],queries = [[0, -1], [1, 0], [2, -1], [3, 0], [4, -1], [5, 0], [6, -1], [7, 0], [8, -1], [9, 0], [10, -1], [11, 0], [12, -1], [13, 0], [14, -1]]) == 616\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10],queries = [[0, 10], [1, -10], [2, 20], [3, -20], [4, 30], [5, -30], [6, 40], [7, -40], [8, 50], [9, -50]]) == 840\n assert candidate(nums = [-100, 200, -300, 400, -500, 600, -700, 800, -900, 1000],queries = [[1, -1000], [3, 1000], [5, -1000], [7, 1000], [9, -1000]]) == 14000\n assert candidate(nums = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1],queries = [[0, 10], [1, 20], [2, 30], [3, 40], [4, 50], [5, 60], [6, 70], [7, 80], [8, 90], [9, 100]]) == 1331\n assert candidate(nums = [0, -1, 1, -2, 2, -3, 3, -4, 4, -5, 5],queries = [[0, -100], [1, 100], [2, -200], [3, 200], [4, -300], [5, 300], [6, -400], [7, 400], [8, -500], [9, 500], [10, -600]]) == 7095\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],queries = [[0, -5], [1, -10], [2, -15], [3, -20], [4, -25], [5, -30], [6, -35], [7, -40], [8, -45], [9, -50]]) == 950\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],queries = [[0, 1], [1, 0], [2, 1], [3, 0], [4, 1], [5, 0], [6, 1], [7, 0], [8, 1], [9, 0]]) == 50\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],queries = [[0, 10], [1, 20], [2, 30], [3, 40], [4, 50]]) == 300\n assert candidate(nums = [0, 1, 0, -1, 0, 1, 0, -1, 0, 1],queries = [[0, 1], [2, 1], [4, 1], [6, 1], [8, 1]]) == 21\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, -10], [2, 0], [4, 20], [6, -20], [8, 30]]) == 192\n assert candidate(nums = [5, -1, 4, 2, 3],queries = [[1, 100], [2, -5], [0, 0], [3, 300]]) == 709\n assert candidate(nums = [5, -5, 5, -5, 5, -5, 5, -5, 5, -5],queries = [[0, 10], [1, -10], [2, 10], [3, -10], [4, 10], [5, -10], [6, 10], [7, -10], [8, 10], [9, -10]]) == 400\n"}, "metadata": {"canonical_parameter_names": ["nums", "queries"], "leetcode_dataset_entry_point": "Solution().maximumSumSubsequence", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maximumSumSubsequence(vector& nums, vector>& queries) {", "container": "Solution", "callable": "maximumSumSubsequence", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "queries", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3168, "task_id": "minimum-number-of-chairs-in-a-waiting-room", "difficulty": "Easy", "problem_description": "You are given a string s. Simulate events at each second i:\n\nIf s[i] == 'E', a person enters the waiting room and takes one of the chairs in it.\nIf s[i] == 'L', a person leaves the waiting room, freeing up a chair.\n\nReturn the minimum number of chairs needed so that a chair is available for every person who enters the waiting room given that it is initially empty.\n \nExample 1:\n\nInput: s = \"EEEEEEE\"\nOutput: 7\nExplanation:\nAfter each second, a person enters the waiting room and no person leaves it. Therefore, a minimum of 7 chairs is needed.\n\nExample 2:\n\nInput: s = \"ELELEEL\"\nOutput: 2\nExplanation:\nLet's consider that there are 2 chairs in the waiting room. The table below shows the state of the waiting room at each second.\n\n\n\n\nSecond\nEvent\nPeople in the Waiting Room\nAvailable Chairs\n\n\n0\nEnter\n1\n1\n\n\n1\nLeave\n0\n2\n\n\n2\nEnter\n1\n1\n\n\n3\nLeave\n0\n2\n\n\n4\nEnter\n1\n1\n\n\n5\nEnter\n2\n0\n\n\n6\nLeave\n1\n1\n\n\n\nExample 3:\n\nInput: s = \"ELEELEELLL\"\nOutput: 3\nExplanation:\nLet's consider that there are 3 chairs in the waiting room. The table below shows the state of the waiting room at each second.\n\n\n\n\nSecond\nEvent\nPeople in the Waiting Room\nAvailable Chairs\n\n\n0\nEnter\n1\n2\n\n\n1\nLeave\n0\n3\n\n\n2\nEnter\n1\n2\n\n\n3\nEnter\n2\n1\n\n\n4\nLeave\n1\n2\n\n\n5\nEnter\n2\n1\n\n\n6\nEnter\n3\n0\n\n\n7\nLeave\n2\n1\n\n\n8\nLeave\n1\n2\n\n\n9\nLeave\n0\n3\n\n\n\n \nConstraints:\n\n1 <= s.length <= 50\ns consists only of the letters 'E' and 'L'.\ns represents a valid sequence of entries and exits.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"ELEELEELLL\") == 3\n assert candidate(s = \"EEEEEEE\") == 7\n assert candidate(s = \"EELLEELLL\") == 2\n assert candidate(s = \"E\") == 1\n assert candidate(s = \"EELLEL\") == 2\n assert candidate(s = \"ELE\") == 1\n assert candidate(s = \"LE\") == 0\n assert candidate(s = \"ELEEL\") == 2\n assert candidate(s = \"ELELEEL\") == 2\n assert candidate(s = \"ELLEEL\") == 1\n assert candidate(s = \"EEEEELLLL\") == 5\n assert candidate(s = \"EEEELEEL\") == 5\n assert candidate(s = \"ELLEELLEELLE\") == 1\n assert candidate(s = \"LELELEL\") == 0\n assert candidate(s = \"LELELELEL\") == 0\n assert candidate(s = \"ELELELELEL\") == 1\n assert candidate(s = \"EL\") == 1\n assert candidate(s = \"EEELLLL\") == 3\n assert candidate(s = \"ELEELLEL\") == 2\n assert candidate(s = \"ELLELE\") == 1\n assert candidate(s = \"ELLEELLEEL\") == 1\n assert candidate(s = \"LEELLEEL\") == 1\n assert candidate(s = \"EEEELEEEE\") == 7\n assert candidate(s = \"L\") == 0\n assert candidate(s = \"LLL\") == 0\n assert candidate(s = \"EELEEL\") == 3\n assert candidate(s = \"ELLELELEL\") == 1\n assert candidate(s = \"LEELLEELEELLELEEL\") == 2\n assert candidate(s = \"EEEEEEEEEELLLLLLLLLLLL\") == 10\n assert candidate(s = \"ELLEELLEELLEELLEELLEELLEELLEELLEELLEELLEELLEELLEELLEELLEEL\") == 1\n assert candidate(s = \"EEEEEEEEEEEEEEEEEEELLLLLLLLLLLLLLLLLLLL\") == 19\n assert candidate(s = \"EEEEEEEEEEEEEEEEEEEE\") == 20\n assert candidate(s = \"EELLEELLEE\") == 2\n assert candidate(s = \"ELEELLEELLEELLLL\") == 2\n assert candidate(s = \"ELLEELLEEELLEELLE\") == 2\n assert candidate(s = \"EEEEEEELEELLLLEEEE\") == 8\n assert candidate(s = \"ELEELLEELLEELLEELLEELLE\") == 2\n assert candidate(s = \"LEELEELLEELEELLEELEELLEELEELLEELEEL\") == 6\n assert candidate(s = \"EEEEELLEELLEELLEELLEEE\") == 6\n assert candidate(s = \"LELELELELELELELELELELELELELELELELELELELELELELELELELELELELELELELELELELELELELELELELELELELELELELELELE\") == 0\n assert candidate(s = \"ELELELELELELEL\") == 1\n assert candidate(s = \"LEEELLLLLEEEEEE\") == 3\n assert candidate(s = \"EEEEEELLLLLL\") == 6\n assert candidate(s = \"EEEELEEEEELEEEEELEEEEELEEEEELEEEEELEEEEELEEE\") == 30\n assert candidate(s = \"EEEEELLLLEELLL\") == 5\n assert candidate(s = \"LLELELELELELELEE\") == 0\n assert candidate(s = \"EEEEEEEEEELELELELELELE\") == 10\n assert candidate(s = \"ELELLELLELLELLELLE\") == 1\n assert candidate(s = \"EEEEELEELLLLLE\") == 6\n assert candidate(s = \"ELELELLELELLEL\") == 1\n assert candidate(s = \"ELEELLEELLEELLEELLEELLEELLEELLEELLEELL\") == 2\n assert candidate(s = \"EEEELELEELLEEEE\") == 7\n assert candidate(s = \"ELEELLEELLEELLEL\") == 2\n assert candidate(s = \"EEELLLLLLEELEELLEEL\") == 3\n assert candidate(s = \"EEEEEEEEEEEEEEEEEEEEEELE\") == 22\n assert candidate(s = \"LEEEEELELELEEL\") == 5\n assert candidate(s = \"ELLEEELLEELLEELLEELLEELLE\") == 2\n assert candidate(s = \"EEEELELELELELELEL\") == 4\n assert candidate(s = \"EEEEEEEEELLLL\") == 9\n assert candidate(s = \"ELLEELLEELLEELLE\") == 1\n assert candidate(s = \"ELEELLEELLEELLEELLEELLEELLEELLEELLE\") == 2\n assert candidate(s = \"EELEELEELEELEE\") == 6\n assert candidate(s = \"EEEEELLLLEEEEEELLLLLEEE\") == 7\n assert candidate(s = \"LEELLEELLEELLEELL\") == 1\n assert candidate(s = \"EEEEEEEELELLELLE\") == 8\n assert candidate(s = \"LELELELELELELELELE\") == 0\n assert candidate(s = \"LEELLEELLEELLEEL\") == 1\n assert candidate(s = \"LLEELLELLEELLE\") == 0\n assert candidate(s = \"ELELELELELELE\") == 1\n assert candidate(s = \"ELLEELLEELLEELLEELLEELLEELLEELLEELLEELLEELLEELLEELLEELLEELLEELLE\") == 1\n assert candidate(s = \"EEEEEEEEEEELELELELELELELELELELELELELELELEEEE\") == 14\n assert candidate(s = \"EEEEELLEELLEELLEELLE\") == 5\n assert candidate(s = \"EEEEEEEEEEEEEEEEEEEEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL\") == 27\n assert candidate(s = \"EELLEELLEELE\") == 2\n assert candidate(s = \"LEELLEELLEELLEELLEEL\") == 1\n assert candidate(s = \"ELLEEELLEEELLEEELLEEELLEEELLEE\") == 6\n assert candidate(s = \"ELELELELELEL\") == 1\n assert candidate(s = \"EEEEELLEELLELLLL\") == 5\n assert candidate(s = \"EELEELLEELLEEELLEELLE\") == 4\n assert candidate(s = \"EEEEEELLLLLLLL\") == 6\n assert candidate(s = \"ELLLLLLEEEEEEL\") == 1\n assert candidate(s = \"EEEEELLLLEELLLLL\") == 5\n assert candidate(s = \"LEEEEEEEEEEEEEEEEEEEEEEE\") == 22\n assert candidate(s = \"ELLEELLEEELLEEELLEEELLEEEL\") == 5\n assert candidate(s = \"EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE\") == 40\n assert candidate(s = \"EEEEEEEEEEELLL\") == 11\n assert candidate(s = \"EELEEEELLLLLLLEELLLL\") == 5\n assert candidate(s = \"ELEELEELLELEEELLELEL\") == 4\n assert candidate(s = \"EEEEELLLLLEELLLLLEEEE\") == 5\n assert candidate(s = \"EEEELLLLLLLLEEE\") == 4\n assert candidate(s = \"EELEEELEEELEEELEEELEEELEEELE\") == 14\n assert candidate(s = \"EEEEELLEELLLEELL\") == 5\n assert candidate(s = \"EEEEELLLLLEEEE\") == 5\n assert candidate(s = \"EEEEEEEEEEEEEEEELLLLLLLLLLLLLLL\") == 16\n assert candidate(s = \"LELLELELLELELLELELLELLEL\") == 0\n assert candidate(s = \"ELLEELLEELLEELLEELLEEEEE\") == 4\n assert candidate(s = \"ELLEELLEELLEELLEELLEELLEELLEELLEELLEELLEELLE\") == 1\n assert candidate(s = \"ELELELELELELELELEL\") == 1\n assert candidate(s = \"ELLEELLEELLEELLL\") == 1\n assert candidate(s = \"EEEEELLLLEEEEE\") == 6\n assert candidate(s = \"EEEELELLLL\") == 4\n assert candidate(s = \"LEEELEEELEEELEEELEEELEEELEEELEEELEEELEEEEE\") == 22\n assert candidate(s = \"EEEEEEEEEEEEEEEEEEEEE\") == 21\n assert candidate(s = \"LELELELELELELELELELELELELELELELELELELELELELE\") == 0\n assert candidate(s = \"EEEEELLEEEEEEELLLLEEEE\") == 10\n assert candidate(s = \"LLEELLELLEELLEELLEELLEELLE\") == 0\n assert candidate(s = \"EEELLEELLEELLEELLEELLEEL\") == 3\n assert candidate(s = \"LELELELELELELELELELELEL\") == 0\n assert candidate(s = \"LEELLEELLEELLELL\") == 1\n assert candidate(s = \"ELLEELLEELLEELLLLL\") == 1\n assert candidate(s = \"EEEEEEEEEELEEEEEEEEELEEEEEEEEEEELEEEEEEEEE\") == 36\n assert candidate(s = \"LELELELELELELELELELELELELELELELELELELELELELELE\") == 0\n assert candidate(s = \"ELLEELLEELLEELLEELLEELLEELLEELLE\") == 1\n assert candidate(s = \"ELLEELLEELLEELLEELLEELLEELLEELLEELLEEL\") == 1\n assert candidate(s = \"ELLELELLELLEELLE\") == 1\n assert candidate(s = \"ELELLELLELLELLEL\") == 1\n assert candidate(s = \"EEEEEEEEELLLLLLLLL\") == 9\n assert candidate(s = \"EEEEEEEEELLLLLLLLLLLL\") == 9\n assert candidate(s = \"LELELELELELELELELELELELELELELELELELELELELELELELEL\") == 0\n assert candidate(s = \"ELLEELLELLEE\") == 1\n assert candidate(s = \"ELLEELLEELLEELLEELLEELL\") == 1\n assert candidate(s = \"EEELLEELLEELLE\") == 3\n assert candidate(s = \"LELELELELELELELELELE\") == 0\n assert candidate(s = \"ELEELLEELLEELLEELLEELLEELLEELLEELLEELLEELLEEL\") == 2\n assert candidate(s = \"ELEELLEELLEELLEELLEELLEELLEELLEELLEELLEELLEELL\") == 2\n assert candidate(s = \"EELLEELEELLEELEELLEELEELLEELEELLEE\") == 6\n assert candidate(s = \"LEELLEELLEELLEELLEELLEELLEELLEEL\") == 1\n assert candidate(s = \"EEEEEEELLLLLLLELLL\") == 7\n assert candidate(s = \"ELLEELLEELLEELLEELLE\") == 1\n assert candidate(s = \"LLLLLLLLLLEEEEEEEEEE\") == 0\n assert candidate(s = \"EEEEEEELLLLLLLEEEE\") == 7\n assert candidate(s = \"LEELLEELLEELLEELLEELLEEL\") == 1\n assert candidate(s = \"EEEEELLEELLEELLEELLEELLEELLEELLEELLEEL\") == 5\n assert candidate(s = \"ELLEELLEELLEEL\") == 1\n assert candidate(s = \"ELLELEELLELEELLELEELLELEEL\") == 1\n assert candidate(s = \"LEELLEEELLEL\") == 2\n assert candidate(s = \"EEEEELLLLLLLEEELLLLLEEELLLLLLLEEEEE\") == 5\n assert candidate(s = \"ELEELLEEL\") == 2\n assert candidate(s = \"LEEEEEELLEEEEEELLEEEEEELLE\") == 13\n assert candidate(s = \"EELLEELLLEELL\") == 2\n assert candidate(s = \"EEEEEEEEEEEEEEEEEEEEEEEEEELELELELELELELELELELELELELELELELELELELELELELELELELELE\") == 26\n assert candidate(s = \"EELLEELLLLEEEL\") == 2\n assert candidate(s = \"LELELELELELELELELELELELE\") == 0\n assert candidate(s = \"ELEELEELEELEELEELEE\") == 7\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().minimumChairs", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumChairs(string s) {", "container": "Solution", "callable": "minimumChairs", "parameters": [{"name": "s", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3169, "task_id": "count-days-without-meetings", "difficulty": "Medium", "problem_description": "You are given a positive integer days representing the total number of days an employee is available for work (starting from day 1). You are also given a 2D array meetings of size n where, meetings[i] = [start_i, end_i] represents the starting and ending days of meeting i (inclusive).\nReturn the count of days when the employee is available for work but no meetings are scheduled.\nNote: The meetings may overlap.\n \nExample 1:\n\nInput: days = 10, meetings = [[5,7],[1,3],[9,10]]\nOutput: 2\nExplanation:\nThere is no meeting scheduled on the 4th and 8th days.\n\nExample 2:\n\nInput: days = 5, meetings = [[2,4],[1,3]]\nOutput: 1\nExplanation:\nThere is no meeting scheduled on the 5th day.\n\nExample 3:\n\nInput: days = 6, meetings = [[1,6]]\nOutput: 0\nExplanation:\nMeetings are scheduled for all working days.\n\n \nConstraints:\n\n1 <= days <= 109\n1 <= meetings.length <= 105\nmeetings[i].length == 2\n1 <= meetings[i][0] <= meetings[i][1] <= days\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(days = 15,meetings = [[5, 6], [6, 7], [7, 8]]) == 11\n assert candidate(days = 10,meetings = [[5, 7], [1, 3], [9, 10]]) == 2\n assert candidate(days = 15,meetings = [[1, 2], [3, 5], [6, 8], [10, 12], [14, 15]]) == 2\n assert candidate(days = 20,meetings = [[5, 10], [15, 20]]) == 8\n assert candidate(days = 5,meetings = [[2, 4], [1, 3]]) == 1\n assert candidate(days = 7,meetings = [[1, 2], [3, 4], [5, 6], [7, 7]]) == 0\n assert candidate(days = 30,meetings = [[1, 5], [6, 10], [11, 15], [16, 20], [21, 25], [26, 30]]) == 0\n assert candidate(days = 10,meetings = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == 5\n assert candidate(days = 20,meetings = [[1, 10], [15, 20]]) == 4\n assert candidate(days = 20,meetings = [[1, 5], [10, 15], [5, 10]]) == 5\n assert candidate(days = 6,meetings = [[1, 6]]) == 0\n assert candidate(days = 15,meetings = [[1, 2], [3, 5], [6, 7], [8, 10], [11, 13], [14, 15]]) == 0\n assert candidate(days = 100,meetings = [[1, 10], [20, 30], [40, 50], [60, 70], [80, 90]]) == 46\n assert candidate(days = 7,meetings = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]]) == 0\n assert candidate(days = 100,meetings = [[10, 20], [30, 40], [50, 60]]) == 67\n assert candidate(days = 25,meetings = [[5, 15], [10, 20]]) == 9\n assert candidate(days = 15,meetings = [[2, 5], [6, 9], [12, 13]]) == 5\n assert candidate(days = 7,meetings = [[1, 2], [3, 4], [5, 6]]) == 1\n assert candidate(days = 1,meetings = [[1, 1]]) == 0\n assert candidate(days = 30,meetings = [[5, 10], [15, 20], [25, 30]]) == 12\n assert candidate(days = 20,meetings = [[1, 2], [3, 5], [8, 10], [15, 20]]) == 6\n assert candidate(days = 100,meetings = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 31], [31, 32], [32, 33], [33, 34], [34, 35], [35, 36], [36, 37], [37, 38], [38, 39], [39, 40], [40, 41], [41, 42], [42, 43], [43, 44], [44, 45], [45, 46], [46, 47], [47, 48], [48, 49], [49, 50]]) == 50\n assert candidate(days = 50,meetings = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 31], [31, 32], [32, 33], [33, 34], [34, 35], [35, 36], [36, 37], [37, 38], [38, 39], [39, 40], [40, 41], [41, 42], [42, 43], [43, 44], [44, 45], [45, 46], [46, 47], [47, 48], [48, 49], [49, 50]]) == 0\n assert candidate(days = 1000,meetings = [[1, 500], [501, 1000], [250, 750]]) == 0\n assert candidate(days = 100,meetings = [[5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [50, 55], [55, 60], [60, 65], [65, 70], [70, 75], [75, 80], [80, 85], [85, 90], [90, 95], [95, 100]]) == 4\n assert candidate(days = 1000,meetings = [[100, 200], [300, 400], [500, 600], [700, 800], [900, 1000]]) == 495\n assert candidate(days = 1000000,meetings = [[1, 1000000]]) == 0\n assert candidate(days = 100,meetings = [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100]]) == 0\n assert candidate(days = 100,meetings = [[1, 3], [2, 5], [3, 7], [4, 9], [5, 11], [6, 13], [7, 15], [8, 17], [9, 19], [10, 21], [11, 23], [12, 25], [13, 27], [14, 29], [15, 31], [16, 33], [17, 35], [18, 37], [19, 39], [20, 41], [21, 43], [22, 45], [23, 47], [24, 49], [25, 51], [26, 53], [27, 55], [28, 57], [29, 59], [30, 61], [31, 63], [32, 65], [33, 67], [34, 69], [35, 71], [36, 73], [37, 75], [38, 77], [39, 79], [40, 81], [41, 83], [42, 85], [43, 87], [44, 89], [45, 91], [46, 93], [47, 95], [48, 97], [49, 99]]) == 1\n assert candidate(days = 200,meetings = [[1, 50], [51, 100], [101, 150], [151, 200], [50, 100], [100, 150], [150, 200], [1, 100], [100, 200], [1, 200], [10, 90], [20, 80], [30, 70], [40, 60], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90]]) == 0\n assert candidate(days = 100,meetings = [[1, 99], [2, 98], [3, 97], [4, 96]]) == 1\n assert candidate(days = 1000,meetings = [[1, 200], [201, 400], [401, 600], [601, 800], [801, 1000]]) == 0\n assert candidate(days = 100,meetings = [[1, 100]]) == 0\n assert candidate(days = 1000000,meetings = [[1, 1000000], [100000, 200000], [200000, 300000], [300000, 400000], [400000, 500000], [500000, 600000], [600000, 700000], [700000, 800000], [800000, 900000], [900000, 1000000]]) == 0\n assert candidate(days = 50,meetings = [[5, 10], [8, 12], [15, 20], [18, 22], [25, 30], [28, 32], [35, 40], [38, 42], [45, 50]]) == 12\n assert candidate(days = 1000,meetings = [[5, 10], [15, 20], [25, 30], [35, 40], [45, 50], [55, 60], [65, 70], [75, 80], [85, 90], [95, 100], [105, 110], [115, 120], [125, 130], [135, 140], [145, 150], [155, 160], [165, 170], [175, 180], [185, 190], [195, 200], [205, 210], [215, 220], [225, 230], [235, 240], [245, 250], [255, 260], [265, 270], [275, 280], [285, 290], [295, 300], [305, 310], [315, 320], [325, 330], [335, 340], [345, 350], [355, 360], [365, 370], [375, 380], [385, 390], [395, 400], [405, 410], [415, 420], [425, 430], [435, 440], [445, 450], [455, 460], [465, 470], [475, 480], [485, 490], [495, 500], [505, 510], [515, 520], [525, 530], [535, 540], [545, 550], [555, 560], [565, 570], [575, 580], [585, 590], [595, 600], [605, 610], [615, 620], [625, 630], [635, 640], [645, 650], [655, 660], [665, 670], [675, 680], [685, 690], [695, 700], [705, 710], [715, 720], [725, 730], [735, 740], [745, 750], [755, 760], [765, 770], [775, 780], [785, 790], [795, 800], [805, 810], [815, 820], [825, 830], [835, 840], [845, 850], [855, 860], [865, 870], [875, 880], [885, 890], [895, 900], [905, 910], [915, 920], [925, 930], [935, 940], [945, 950], [955, 960], [965, 970], [975, 980], [985, 990], [995, 1000]]) == 400\n assert candidate(days = 200,meetings = [[1, 2], [4, 5], [7, 8], [10, 11], [13, 14], [16, 17], [19, 20], [22, 23], [25, 26], [28, 29], [31, 32], [34, 35], [37, 38], [40, 41], [43, 44], [46, 47], [49, 50], [52, 53], [55, 56], [58, 59], [61, 62], [64, 65], [67, 68], [70, 71], [73, 74], [76, 77], [79, 80], [82, 83], [85, 86], [88, 89], [91, 92], [94, 95], [97, 98], [99, 100], [101, 102], [103, 104], [105, 106], [107, 108], [109, 110], [111, 112], [113, 114], [115, 116], [117, 118], [119, 120], [121, 122], [123, 124], [125, 126], [127, 128], [129, 130], [131, 132], [133, 134], [135, 136], [137, 138], [139, 140], [141, 142], [143, 144], [145, 146], [147, 148], [149, 150], [151, 152], [153, 154], [155, 156], [157, 158], [159, 160], [161, 162], [163, 164], [165, 166], [167, 168], [169, 170], [171, 172], [173, 174], [175, 176], [177, 178], [179, 180], [181, 182], [183, 184], [185, 186], [187, 188], [189, 190], [191, 192], [193, 194], [195, 196], [197, 198], [199, 200]]) == 32\n assert candidate(days = 1000000,meetings = [[1, 500000], [500001, 1000000]]) == 0\n assert candidate(days = 1000,meetings = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == 980\n assert candidate(days = 500,meetings = [[1, 10], [100, 200], [300, 400], [490, 500]]) == 277\n assert candidate(days = 100,meetings = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 31], [31, 32], [32, 33], [33, 34], [34, 35], [35, 36], [36, 37], [37, 38], [38, 39], [39, 40], [40, 41], [41, 42], [42, 43], [43, 44], [44, 45], [45, 46], [46, 47], [47, 48], [48, 49], [49, 50], [50, 51], [51, 52], [52, 53], [53, 54], [54, 55], [55, 56], [56, 57], [57, 58], [58, 59], [59, 60], [60, 61], [61, 62], [62, 63], [63, 64], [64, 65], [65, 66], [66, 67], [67, 68], [68, 69], [69, 70], [70, 71], [71, 72], [72, 73], [73, 74], [74, 75], [75, 76], [76, 77], [77, 78], [78, 79], [79, 80], [80, 81], [81, 82], [82, 83], [83, 84], [84, 85], [85, 86], [86, 87], [87, 88], [88, 89], [89, 90], [90, 91], [91, 92], [92, 93], [93, 94], [94, 95], [95, 96], [96, 97], [97, 98], [98, 99], [99, 100]]) == 0\n assert candidate(days = 500,meetings = [[1, 250], [200, 300], [400, 500]]) == 99\n assert candidate(days = 1000000000,meetings = [[1, 500000000], [500000001, 1000000000]]) == 0\n assert candidate(days = 100,meetings = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20], [21, 21], [22, 22], [23, 23], [24, 24], [25, 25], [26, 26], [27, 27], [28, 28], [29, 29], [30, 30], [31, 31], [32, 32], [33, 33], [34, 34], [35, 35], [36, 36], [37, 37], [38, 38], [39, 39], [40, 40], [41, 41], [42, 42], [43, 43], [44, 44], [45, 45], [46, 46], [47, 47], [48, 48], [49, 49], [50, 50], [51, 51], [52, 52], [53, 53], [54, 54], [55, 55], [56, 56], [57, 57], [58, 58], [59, 59], [60, 60], [61, 61], [62, 62], [63, 63], [64, 64], [65, 65], [66, 66], [67, 67], [68, 68], [69, 69], [70, 70], [71, 71], [72, 72], [73, 73], [74, 74], [75, 75], [76, 76], [77, 77], [78, 78], [79, 79], [80, 80], [81, 81], [82, 82], [83, 83], [84, 84], [85, 85], [86, 86], [87, 87], [88, 88], [89, 89], [90, 90], [91, 91], [92, 92], [93, 93], [94, 94], [95, 95], [96, 96], [97, 97], [98, 98], [99, 99], [100, 100]]) == 0\n assert candidate(days = 50,meetings = [[1, 2], [3, 5], [6, 8], [9, 11], [12, 14], [15, 17], [18, 20], [21, 23], [24, 26], [27, 29], [30, 32], [33, 35], [36, 38], [39, 41], [42, 44], [45, 47], [48, 49]]) == 1\n assert candidate(days = 1000000,meetings = [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 13], [13, 15], [15, 17], [17, 19], [19, 21]]) == 999979\n assert candidate(days = 10,meetings = [[1, 10], [2, 3], [4, 5], [6, 7], [8, 9], [1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == 0\n assert candidate(days = 1000,meetings = [[1, 1000], [100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700], [700, 800], [800, 900], [900, 1000]]) == 0\n assert candidate(days = 20,meetings = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15], [12, 16], [13, 17], [14, 18], [15, 19], [16, 20]]) == 0\n assert candidate(days = 50,meetings = [[1, 10], [5, 15], [10, 20], [15, 25], [20, 30]]) == 20\n assert candidate(days = 10,meetings = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]) == 0\n assert candidate(days = 500,meetings = [[1, 100], [50, 150], [100, 200], [150, 250], [200, 300], [250, 350], [300, 400], [350, 450], [400, 500]]) == 0\n assert candidate(days = 1000000,meetings = [[1, 1000000]]) == 0\n assert candidate(days = 1000,meetings = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14]]) == 986\n assert candidate(days = 365,meetings = [[1, 10], [20, 25], [30, 35], [40, 45], [50, 55], [60, 65], [70, 75], [80, 85], [90, 95], [100, 105], [110, 115], [120, 125], [130, 135], [140, 145], [150, 155], [160, 165], [170, 175], [180, 185], [190, 195], [200, 205], [210, 215], [220, 225], [230, 235], [240, 245], [250, 255], [260, 265], [270, 275], [280, 285], [290, 295], [300, 305], [310, 315], [320, 325], [330, 335], [340, 345], [350, 355], [360, 365]]) == 145\n assert candidate(days = 10,meetings = [[1, 3], [3, 5], [5, 7], [7, 9], [9, 10]]) == 0\n assert candidate(days = 1000000000,meetings = [[1, 1000000000]]) == 0\n assert candidate(days = 50,meetings = [[1, 10], [11, 20], [21, 30], [31, 40], [41, 50], [5, 15], [10, 25], [20, 35], [30, 45], [40, 50]]) == 0\n assert candidate(days = 1000,meetings = [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 13], [13, 15], [15, 17], [17, 19], [19, 21]]) == 979\n assert candidate(days = 365,meetings = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20], [21, 21], [22, 22], [23, 23], [24, 24], [25, 25], [26, 26], [27, 27], [28, 28], [29, 29], [30, 30], [31, 31], [32, 32], [33, 33], [34, 34], [35, 35], [36, 36], [37, 37], [38, 38], [39, 39], [40, 40], [41, 41], [42, 42], [43, 43], [44, 44], [45, 45], [46, 46], [47, 47], [48, 48], [49, 49], [50, 50], [51, 51], [52, 52], [53, 53], [54, 54], [55, 55], [56, 56], [57, 57], [58, 58], [59, 59], [60, 60], [61, 61], [62, 62], [63, 63], [64, 64], [65, 65], [66, 66], [67, 67], [68, 68], [69, 69], [70, 70], [71, 71], [72, 72], [73, 73], [74, 74], [75, 75], [76, 76], [77, 77], [78, 78], [79, 79], [80, 80], [81, 81], [82, 82], [83, 83], [84, 84], [85, 85], [86, 86], [87, 87], [88, 88], [89, 89], [90, 90], [91, 91], [92, 92], [93, 93], [94, 94], [95, 95], [96, 96], [97, 97], [98, 98], [99, 99], [100, 100], [101, 101], [102, 102], [103, 103], [104, 104], [105, 105], [106, 106], [107, 107], [108, 108], [109, 109], [110, 110], [111, 111], [112, 112], [113, 113], [114, 114], [115, 115], [116, 116], [117, 117], [118, 118], [119, 119], [120, 120], [121, 121], [122, 122], [123, 123], [124, 124], [125, 125], [126, 126], [127, 127], [128, 128], [129, 129], [130, 130], [131, 131], [132, 132], [133, 133], [134, 134], [135, 135], [136, 136], [137, 137], [138, 138], [139, 139], [140, 140], [141, 141], [142, 142], [143, 143], [144, 144], [145, 145], [146, 146], [147, 147], [148, 148], [149, 149], [150, 150], [151, 151], [152, 152], [153, 153], [154, 154], [155, 155], [156, 156], [157, 157], [158, 158], [159, 159], [160, 160], [161, 161], [162, 162], [163, 163], [164, 164], [165, 165], [166, 166], [167, 167], [168, 168], [169, 169], [170, 170], [171, 171], [172, 172], [173, 173], [174, 174], [175, 175], [176, 176], [177, 177], [178, 178], [179, 179], [180, 180], [181, 181], [182, 182], [183, 183], [184, 184], [185, 185], [186, 186], [187, 187], [188, 188], [189, 189], [190, 190], [191, 191], [192, 192], [193, 193], [194, 194], [195, 195], [196, 196], [197, 197], [198, 198], [199, 199], [200, 200], [201, 201], [202, 202], [203, 203], [204, 204], [205, 205], [206, 206], [207, 207], [208, 208], [209, 209], [210, 210], [211, 211], [212, 212], [213, 213], [214, 214], [215, 215], [216, 216], [217, 217], [218, 218], [219, 219], [220, 220], [221, 221], [222, 222], [223, 223], [224, 224], [225, 225], [226, 226], [227, 227], [228, 228], [229, 229], [230, 230], [231, 231], [232, 232], [233, 233], [234, 234], [235, 235], [236, 236], [237, 237], [238, 238], [239, 239], [240, 240], [241, 241], [242, 242], [243, 243], [244, 244], [245, 245], [246, 246], [247, 247], [248, 248], [249, 249], [250, 250], [251, 251], [252, 252], [253, 253], [254, 254], [255, 255], [256, 256], [257, 257], [258, 258], [259, 259], [260, 260], [261, 261], [262, 262], [263, 263], [264, 264], [265, 265], [266, 266], [267, 267], [268, 268], [269, 269], [270, 270], [271, 271], [272, 272], [273, 273], [274, 274], [275, 275], [276, 276], [277, 277], [278, 278], [279, 279], [280, 280], [281, 281], [282, 282], [283, 283], [284, 284], [285, 285], [286, 286], [287, 287], [288, 288], [289, 289], [290, 290], [291, 291], [292, 292], [293, 293], [294, 294], [295, 295], [296, 296], [297, 297], [298, 298], [299, 299], [300, 300], [301, 301], [302, 302], [303, 303], [304, 304], [305, 305], [306, 306], [307, 307], [308, 308], [309, 309], [310, 310], [311, 311], [312, 312], [313, 313], [314, 314], [315, 315], [316, 316], [317, 317], [318, 318], [319, 319], [320, 320], [321, 321], [322, 322], [323, 323], [324, 324], [325, 325], [326, 326], [327, 327], [328, 328], [329, 329], [330, 330], [331, 331], [332, 332], [333, 333], [334, 334], [335, 335], [336, 336], [337, 337], [338, 338], [339, 339], [340, 340], [341, 341], [342, 342], [343, 343], [344, 344], [345, 345], [346, 346], [347, 347], [348, 348], [349, 349], [350, 350], [351, 351], [352, 352], [353, 353], [354, 354], [355, 355], [356, 356], [357, 357], [358, 358], [359, 359], [360, 360], [361, 361], [362, 362], [363, 363], [364, 364], [365, 365]]) == 0\n assert candidate(days = 100,meetings = [[1, 10], [5, 15], [10, 20], [15, 25], [20, 30], [25, 35], [30, 40], [35, 45], [40, 50], [45, 55], [50, 60], [55, 65], [60, 70], [65, 75], [70, 80], [75, 85], [80, 90], [85, 95], [90, 100]]) == 0\n assert candidate(days = 100,meetings = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15], [12, 16], [13, 17], [14, 18], [15, 19], [16, 20], [17, 21], [18, 22], [19, 23], [20, 24], [21, 25], [22, 26], [23, 27], [24, 28], [25, 29], [26, 30], [27, 31], [28, 32], [29, 33], [30, 34], [31, 35], [32, 36], [33, 37], [34, 38], [35, 39], [36, 40], [37, 41], [38, 42], [39, 43], [40, 44], [41, 45], [42, 46], [43, 47], [44, 48], [45, 49], [46, 50], [47, 51], [48, 52], [49, 53], [50, 54], [51, 55], [52, 56], [53, 57], [54, 58], [55, 59], [56, 60], [57, 61], [58, 62], [59, 63], [60, 64], [61, 65], [62, 66], [63, 67], [64, 68], [65, 69], [66, 70], [67, 71], [68, 72], [69, 73], [70, 74], [71, 75], [72, 76], [73, 77], [74, 78], [75, 79], [76, 80], [77, 81], [78, 82], [79, 83], [80, 84], [81, 85], [82, 86], [83, 87], [84, 88], [85, 89], [86, 90], [87, 91], [88, 92], [89, 93], [90, 94], [91, 95], [92, 96], [93, 97], [94, 98], [95, 99], [96, 100]]) == 0\n assert candidate(days = 100,meetings = [[20, 30], [25, 35], [30, 40], [35, 45], [40, 50]]) == 69\n assert candidate(days = 100,meetings = [[1, 50], [51, 100]]) == 0\n assert candidate(days = 500,meetings = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 490\n assert candidate(days = 500,meetings = [[1, 500]]) == 0\n assert candidate(days = 2,meetings = [[1, 1]]) == 1\n assert candidate(days = 100,meetings = [[1, 50], [51, 100], [25, 75], [76, 100], [1, 25]]) == 0\n assert candidate(days = 1000000,meetings = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20], [21, 21], [22, 22], [23, 23], [24, 24], [25, 25], [26, 26], [27, 27], [28, 28], [29, 29], [30, 30], [31, 31], [32, 32], [33, 33], [34, 34], [35, 35], [36, 36], [37, 37], [38, 38], [39, 39], [40, 40], [41, 41], [42, 42], [43, 43], [44, 44], [45, 45], [46, 46], [47, 47], [48, 48], [49, 49], [50, 50]]) == 999950\n assert candidate(days = 10,meetings = [[1, 1], [1, 2], [2, 2], [2, 3], [3, 3], [3, 4], [4, 4], [4, 5], [5, 5], [5, 6], [6, 6], [6, 7], [7, 7], [7, 8], [8, 8], [8, 9], [9, 9], [9, 10], [10, 10]]) == 0\n assert candidate(days = 10,meetings = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 0\n assert candidate(days = 100,meetings = [[1, 50], [51, 100], [25, 75], [76, 100], [1, 25], [76, 100]]) == 0\n assert candidate(days = 200,meetings = [[1, 50], [25, 75], [50, 100], [75, 125], [100, 150], [125, 175], [150, 200]]) == 0\n assert candidate(days = 100,meetings = [[1, 50], [2, 49], [3, 48], [4, 47], [5, 46], [6, 45], [7, 44], [8, 43], [9, 42], [10, 41], [11, 40], [12, 39], [13, 38], [14, 37], [15, 36], [16, 35], [17, 34], [18, 33], [19, 32], [20, 31], [21, 30], [22, 29], [23, 28], [24, 27], [25, 26], [26, 25], [27, 24], [28, 23], [29, 22], [30, 21], [31, 20], [32, 19], [33, 18], [34, 17], [35, 16], [36, 15], [37, 14], [38, 13], [39, 12], [40, 11], [41, 10], [42, 9], [43, 8], [44, 7], [45, 6], [46, 5], [47, 4], [48, 3], [49, 2], [50, 1]]) == 50\n assert candidate(days = 100,meetings = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 90\n assert candidate(days = 999999999,meetings = [[1, 999999999]]) == 0\n assert candidate(days = 200,meetings = [[1, 50], [51, 100], [101, 150], [151, 200]]) == 0\n assert candidate(days = 100,meetings = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 90\n assert candidate(days = 500,meetings = [[1, 10], [11, 20], [21, 30], [31, 40], [41, 50], [51, 60], [61, 70], [71, 80], [81, 90], [91, 100], [101, 110], [111, 120], [121, 130], [131, 140], [141, 150], [151, 160], [161, 170], [171, 180], [181, 190], [191, 200], [201, 210], [211, 220], [221, 230], [231, 240], [241, 250], [251, 260], [261, 270], [271, 280], [281, 290], [291, 300], [301, 310], [311, 320], [321, 330], [331, 340], [341, 350], [351, 360], [361, 370], [371, 380], [381, 390], [391, 400], [401, 410], [411, 420], [421, 430], [431, 440], [441, 450], [451, 460], [461, 470], [471, 480], [481, 490], [491, 500]]) == 0\n assert candidate(days = 50,meetings = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15], [12, 16], [13, 17], [14, 18], [15, 19], [16, 20]]) == 30\n assert candidate(days = 1000000,meetings = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == 999980\n assert candidate(days = 100,meetings = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91], [11, 90], [12, 89], [13, 88], [14, 87], [15, 86], [16, 85], [17, 84], [18, 83], [19, 82], [20, 81], [21, 80], [22, 79], [23, 78], [24, 77], [25, 76], [26, 75], [27, 74], [28, 73], [29, 72], [30, 71], [31, 70], [32, 69], [33, 68], [34, 67], [35, 66], [36, 65], [37, 64], [38, 63], [39, 62], [40, 61], [41, 60], [42, 59], [43, 58], [44, 57], [45, 56], [46, 55], [47, 54], [48, 53], [49, 52], [50, 51]]) == 0\n assert candidate(days = 365,meetings = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20], [21, 21], [22, 22], [23, 23], [24, 24], [25, 25], [26, 26], [27, 27], [28, 28], [29, 29], [30, 30], [31, 31], [32, 32], [33, 33], [34, 34], [35, 35], [36, 36], [37, 37], [38, 38], [39, 39], [40, 40], [41, 41], [42, 42], [43, 43], [44, 44], [45, 45], [46, 46], [47, 47], [48, 48], [49, 49], [50, 50]]) == 315\n assert candidate(days = 1000000,meetings = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20], [21, 22], [23, 24], [25, 26], [27, 28], [29, 30], [31, 32], [33, 34], [35, 36], [37, 38], [39, 40], [41, 42], [43, 44], [45, 46], [47, 48], [49, 50], [51, 52], [53, 54], [55, 56], [57, 58], [59, 60], [61, 62], [63, 64], [65, 66], [67, 68], [69, 70], [71, 72], [73, 74], [75, 76], [77, 78], [79, 80], [81, 82], [83, 84], [85, 86], [87, 88], [89, 90], [91, 92], [93, 94], [95, 96], [97, 98], [99, 100]]) == 999900\n assert candidate(days = 10,meetings = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10]]) == 0\n assert candidate(days = 1000,meetings = [[1, 100], [200, 300], [400, 500], [600, 700], [800, 900]]) == 496\n assert candidate(days = 2,meetings = [[1, 2]]) == 0\n assert candidate(days = 50,meetings = [[5, 10], [10, 15], [15, 20], [20, 25], [25, 30]]) == 24\n assert candidate(days = 100,meetings = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20], [21, 22], [23, 24], [25, 26], [27, 28], [29, 30], [31, 32], [33, 34], [35, 36], [37, 38], [39, 40], [41, 42], [43, 44], [45, 46], [47, 48], [49, 50], [51, 52], [53, 54], [55, 56], [57, 58], [59, 60], [61, 62], [63, 64], [65, 66], [67, 68], [69, 70], [71, 72], [73, 74], [75, 76], [77, 78], [79, 80], [81, 82], [83, 84], [85, 86], [87, 88], [89, 90], [91, 92], [93, 94], [95, 96], [97, 98], [99, 100]]) == 0\n assert candidate(days = 100,meetings = [[5, 5], [10, 10], [15, 15], [20, 20], [25, 25], [30, 30], [35, 35], [40, 40], [45, 45], [50, 50]]) == 90\n"}, "metadata": {"canonical_parameter_names": ["days", "meetings"], "leetcode_dataset_entry_point": "Solution().countDays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int countDays(int days, vector>& meetings) {", "container": "Solution", "callable": "countDays", "parameters": [{"name": "days", "type": "int"}, {"name": "meetings", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3170, "task_id": "lexicographically-minimum-string-after-removing-stars", "difficulty": "Medium", "problem_description": "You are given a string s. It may contain any number of '*' characters. Your task is to remove all '*' characters.\nWhile there is a '*', do the following operation:\n\nDelete the leftmost '*' and the smallest non-'*' character to its left. If there are several smallest characters, you can delete any of them.\n\nReturn the lexicographically smallest resulting string after removing all '*' characters.\n \nExample 1:\n\nInput: s = \"aaba*\"\nOutput: \"aab\"\nExplanation:\nWe should delete one of the 'a' characters with '*'. If we choose s[3], s becomes the lexicographically smallest.\n\nExample 2:\n\nInput: s = \"abc\"\nOutput: \"abc\"\nExplanation:\nThere is no '*' in the string.\n\n \nConstraints:\n\n1 <= s.length <= 105\ns consists only of lowercase English letters and '*'.\nThe input is generated such that it is possible to delete all '*' characters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"*a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z\") == \"z\"\n assert candidate(s = \"*a*b*c\") == \"c\"\n assert candidate(s = \"aaba*\") == \"aab\"\n assert candidate(s = \"z*z*z*z\") == \"z\"\n assert candidate(s = \"a*b*c*a*b*c\") == \"c\"\n assert candidate(s = \"zzzzzzzzz***zzzzz\") == \"zzzzzzzzzzz\"\n assert candidate(s = \"abc***\") == \"\"\n assert candidate(s = \"a*a*a*a*a*a*a*a*a*a\") == \"a\"\n assert candidate(s = \"aaabbbccc***\") == \"bbbccc\"\n assert candidate(s = \"ab*c*d*e\") == \"de\"\n assert candidate(s = \"ab*ac*\") == \"bc\"\n assert candidate(s = \"aaa*bbb*ccc\") == \"abbbccc\"\n assert candidate(s = \"abcde*****fghij\") == \"fghij\"\n assert candidate(s = \"a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z\") == \"z\"\n assert candidate(s = \"a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z*a\") == \"a\"\n assert candidate(s = \"leetcode*e*et*c*o*\") == \"leetoeto\"\n assert candidate(s = \"abcabcabc***abc\") == \"bcbcbcabc\"\n assert candidate(s = \"a*a*a*a*a\") == \"a\"\n assert candidate(s = \"abc\") == \"abc\"\n assert candidate(s = \"z*z*z\") == \"z\"\n assert candidate(s = \"aa*bb*c\") == \"bbc\"\n assert candidate(s = \"abcdef*ghij*k*l*m*\") == \"fghijklm\"\n assert candidate(s = \"*a*a*a*a*a*a*a*a*a*a\") == \"a\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba*\") == \"zyxwvutsrqponmlkjihgfedcb\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz*\") == \"bcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"abc*def*ghi*\") == \"defghi\"\n assert candidate(s = \"*a*b*c*\") == \"\"\n assert candidate(s = \"ab*cd*ef*gh*ij*kl*mn*op*qr*st*uv*wx*yz*a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z\") == \"tuvwxyztuvwxyz\"\n assert candidate(s = \"aaabbbccc*bbb*aaa*\") == \"abbbcccbbbaa\"\n assert candidate(s = \"abc*d*efg*h*ijk*lmn*opq*rst*u*v*w*x*y*z*\") == \"opqrstuvwxyz\"\n assert candidate(s = \"aabbaa*bb*a*aa*\") == \"aabbbba\"\n assert candidate(s = \"aaabbbccc***bbb***aaa\") == \"bbbcccaaa\"\n assert candidate(s = \"abracadabra*bra*bra*cad*a\") == \"abracadabrbrbrcda\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz*zyxwvutsrqponmlkjihgfedcba*\") == \"bcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcb\"\n assert candidate(s = \"a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z*a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z\") == \"z\"\n assert candidate(s = \"a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z*\") == \"\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz*\") == \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(s = \"banana*na*na\") == \"banannna\"\n assert candidate(s = \"abcabcabcabcabcabcabc*abc*abc*abc*\") == \"abcabcabcabcabcabcbcbcbcbc\"\n assert candidate(s = \"*a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z*\") == \"\"\n assert candidate(s = \"mno*pqr*stu*vwx*yz*abc*def*ghi*jkl\") == \"rstuvwxyzdefghijkl\"\n assert candidate(s = \"abcabcabcabc*abc*abc*abc*abc*abc*abc*abc*abc*\") == \"abcabcabcbcbcbcbcbcbcbcbcbc\"\n assert candidate(s = \"abcdefghijk*lmnopqrst*uvwxyz*\") == \"defghijklmnopqrstuvwxyz\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz***\") == \"bccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\"\n assert candidate(s = \"a*a*b*b*c*c*d*d*e*e*f*f*g*g*h*h*i*i*j*j*k*k*l*l*m*m*n*n*o*o*p*p*q*q*r*r*s*s*t*t*u*u*v*v*w*w*x*x*y*y*z*z\") == \"z\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz*\") == \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(s = \"abc*def*ghi*jkl*mno*pqr*stu*vwx*yz*a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z\") == \"rstuvwxyzrstuvwxyz\"\n assert candidate(s = \"zzzzz*yyyyy*xxxxx*wwwww*vvvvv*uuuuu*ttttt*sssss*rrrrr*qqqqq*ppppp*ooooo*nnnnn*mmmmm*lllll*kkkkk*jjjjj*iiiii*h*\") == \"zzzzyyyyxxxxwwwwvvvvuuuuttttssssrrrrqqqqppppoooonnnnmmmmllllkkkkjjjjiiii\"\n assert candidate(s = \"zzzzzzzzzzz*a*zzzzzzzzzz*b*zzzzzzzzzz*c*zzzzzzzzzz*d*zzzzzzzzzz*e*zzzzzzzzzz*f*zzzzzzzzzz*g*zzzzzzzzzz*h*zzzzzzzzzz*i*zzzzzzzzzz*j*zzzzzzzzzz*k*zzzzzzzzzz*l*zzzzzzzzzz*m*zzzzzzzzzz*n*zzzzzzzzzz*o*zzzzzzzzzz*p*zzzzzzzzzz*q*zzzzzzzzzz*r*zzzzzzzzzz*s*zzzzzzzzzz*t*zzzzzzzzzz*u*zzzzzzzzzz*v*zzzzzzzzzz*w*zzzzzzzzzz*x*zzzzzzzzzz*y*zzzzzzzzzz*z*\") == \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(s = \"a*z*y*x*z*y*x*\") == \"\"\n assert candidate(s = \"a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z*a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z*a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z\") == \"z\"\n assert candidate(s = \"aaabbbccc*aa*bb*cc*\") == \"abbbcccbbcc\"\n assert candidate(s = \"z*yz*yz*yz*y*z\") == \"zzzz\"\n assert candidate(s = \"xyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyx***zyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyx***zyxzyxzyxzyxzyxzyxzyxzyxzyxzyx***\") == \"xyxzyxzyxzyxzyxzyxzyxzyxzyxzyzyzyzyxzyxzyxzyxzyxzyxzyxzyxzyxzyzyzyzyxzyxzyxzyxzyxzyxzyxzyzyzy\"\n assert candidate(s = \"abc***def***ghi***jkl***mno***pqr***stu***vwx***yz*\") == \"z\"\n assert candidate(s = \"zyxwvu*utsrqponmlkjihgfedcba*\") == \"zyxwvutsrqponmlkjihgfedcb\"\n assert candidate(s = \"abcd*efgh*i*jklm*no*pqrst*uvw*x*y*z\") == \"jklmnopqrstuvwxyz\"\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaab*aaaaaaaaaaaaaaaaaaaaaa\") == \"aaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(s = \"z*z*z*z*z*z*z*z*z*z\") == \"z\"\n assert candidate(s = \"z*z*z*z*z*z*z*z*z*z*z*z*z*z*z*z\") == \"z\"\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz*\") == \"aaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz\"\n assert candidate(s = \"zzzzzzzzzzz*zzzzzzzzzz*zzzzzzzzzz*\") == \"zzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(s = \"*abcdefghijklmnopqrstuvwxyz*\") == \"bcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"mississippi*m*m*m*s*s*s*i*i*i*p*p*p\") == \"ssssppssspp\"\n assert candidate(s = \"aabbccddeee***f***\") == \"ddeeef\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz*\") == \"abbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\"\n assert candidate(s = \"b*a*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z*\") == \"\"\n assert candidate(s = \"le*etco*de***\") == \"lto\"\n assert candidate(s = \"zyxzyxzyx***\") == \"zyzyzy\"\n assert candidate(s = \"zyx*zyx*zyx*\") == \"zyzyzy\"\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().clearStars", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string clearStars(string s) {", "container": "Solution", "callable": "clearStars", "parameters": [{"name": "s", "type": "string"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3171, "task_id": "find-subarray-with-bitwise-or-closest-to-k", "difficulty": "Hard", "problem_description": "You are given an array nums and an integer k. You need to find a subarray of nums such that the absolute difference between k and the bitwise OR of the subarray elements is as small as possible. In other words, select a subarray nums[l..r] such that |k - (nums[l] OR nums[l + 1] ... OR nums[r])| is minimum.\nReturn the minimum possible value of the absolute difference.\nA subarray is a contiguous non-empty sequence of elements within an array.\n \nExample 1:\n\nInput: nums = [1,2,4,5], k = 3\nOutput: 0\nExplanation:\nThe subarray nums[0..1] has OR value 3, which gives the minimum absolute difference |3 - 3| = 0.\n\nExample 2:\n\nInput: nums = [1,3,1,3], k = 2\nOutput: 1\nExplanation:\nThe subarray nums[1..1] has OR value 3, which gives the minimum absolute difference |3 - 2| = 1.\n\nExample 3:\n\nInput: nums = [1], k = 10\nOutput: 9\nExplanation:\nThere is a single subarray with OR value 1, which gives the minimum absolute difference |10 - 1| = 9.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 109\n1 <= k <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1000000000],k = 500000000) == 500000000\n assert candidate(nums = [10, 20, 30, 40],k = 25) == 5\n assert candidate(nums = [1],k = 10) == 9\n assert candidate(nums = [5, 6, 7, 8, 9],k = 7) == 0\n assert candidate(nums = [5, 5, 5, 5, 5],k = 10) == 5\n assert candidate(nums = [1000000000, 1000000000, 1000000000],k = 1000000000) == 0\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 0\n assert candidate(nums = [3, 5, 7, 9],k = 8) == 1\n assert candidate(nums = [10, 20, 30, 40, 50],k = 25) == 5\n assert candidate(nums = [1, 1, 1, 1, 1],k = 2) == 1\n assert candidate(nums = [7, 8, 9],k = 5) == 2\n assert candidate(nums = [1, 1, 1, 1],k = 1) == 0\n assert candidate(nums = [5, 3, 6, 7, 9],k = 4) == 1\n assert candidate(nums = [1, 1, 2, 2, 3, 3],k = 0) == 1\n assert candidate(nums = [2, 4, 6, 8, 10],k = 7) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 15) == 0\n assert candidate(nums = [1000000000],k = 1000000000) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 65) == 3\n assert candidate(nums = [1, 3, 1, 3],k = 2) == 1\n assert candidate(nums = [1, 1, 1, 1, 1],k = 1) == 0\n assert candidate(nums = [3, 3, 3, 3, 3],k = 3) == 0\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],k = 255) == 0\n assert candidate(nums = [2, 4, 8, 16, 32],k = 31) == 1\n assert candidate(nums = [5, 7, 9, 11, 13],k = 8) == 1\n assert candidate(nums = [1, 2, 4, 5],k = 3) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 1\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575, 2097151, 4194303, 8388607, 16777215, 33554431],k = 10000000) == 1611393\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],k = 500) == 11\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],k = 100) == 27\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5],k = 3) == 2\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000],k = 1000000000) == 0\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],k = 1000) == 8\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],k = 1) == 1\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135, 144, 153, 162, 171, 180],k = 110) == 1\n assert candidate(nums = [31, 15, 7, 3, 1, 128, 64, 32, 16, 8, 4, 2, 1],k = 127) == 0\n assert candidate(nums = [256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728],k = 268435456) == 256\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],k = 511) == 0\n assert candidate(nums = [1048575, 1048575, 1048575, 1048575, 1048575],k = 1048574) == 1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],k = 1023) == 0\n assert candidate(nums = [3, 5, 7, 10, 15, 20],k = 12) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 5\n assert candidate(nums = [123456789, 987654321, 135792468, 246813579, 1112131415],k = 333333333) == 85994358\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 25) == 1\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 3) == 1\n assert candidate(nums = [1, 5, 10, 20, 40, 80, 160, 320, 640, 1280],k = 1000) == 8\n assert candidate(nums = [1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048],k = 100000) == 1696\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 14) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 55) == 3\n assert candidate(nums = [999999999, 999999998, 999999997, 999999996, 999999995],k = 999999994) == 1\n assert candidate(nums = [3, 7, 11, 15, 19, 23, 27, 31, 35, 39],k = 20) == 1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216],k = 10000000) == 1611392\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 55) == 3\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023],k = 500) == 11\n assert candidate(nums = [255, 127, 63, 31, 15, 7, 3, 1],k = 64) == 1\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996],k = 1000000000) == 0\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],k = 40) == 4\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 16) == 1\n assert candidate(nums = [3, 7, 11, 15, 19, 23, 27, 31, 35],k = 20) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 45) == 5\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 25) == 3\n assert candidate(nums = [255, 127, 63, 31, 15, 7, 3, 1],k = 100) == 27\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],k = 1024) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 4\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],k = 30) == 1\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 10) == 3\n assert candidate(nums = [8, 4, 2, 1, 16, 8, 4, 2, 1],k = 10) == 2\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],k = 500) == 4\n assert candidate(nums = [999999999, 999999998, 999999997, 999999996, 999999995],k = 999999994) == 1\n assert candidate(nums = [31, 15, 7, 3, 1, 0, 1, 3, 7, 15, 31],k = 16) == 1\n assert candidate(nums = [255, 127, 63, 31, 15, 7, 3, 1, 256, 512, 1024, 2048, 4096],k = 1000) == 23\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],k = 1000) == 8\n assert candidate(nums = [3, 7, 2, 5, 10, 14],k = 6) == 1\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 1) == 6\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000],k = 1000000001) == 1\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023],k = 512) == 1\n assert candidate(nums = [3, 7, 11, 15, 19, 23, 27, 31, 35, 39],k = 25) == 2\n assert candidate(nums = [8, 16, 32, 64, 128, 256],k = 200) == 8\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 0) == 1\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 750) == 14\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80],k = 50) == 2\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],k = 20) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 0\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],k = 1023) == 1\n assert candidate(nums = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21],k = 10) == 1\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61],k = 42) == 1\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 77) == 2\n assert candidate(nums = [3, 6, 1, 8, 9, 10, 5],k = 7) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 8) == 0\n assert candidate(nums = [1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],k = 1048576) == 1024\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1],k = 0) == 1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256],k = 127) == 0\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],k = 33) == 2\n assert candidate(nums = [9, 3, 15, 8, 5, 2, 7, 11, 6, 4],k = 13) == 0\n assert candidate(nums = [3, 7, 2, 5, 6, 1, 4, 8, 9],k = 12) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 550) == 42\n assert candidate(nums = [31, 15, 7, 3, 1],k = 4) == 1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576],k = 1073741824) == 1071644673\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],k = 500) == 4\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],k = 500) == 4\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],k = 42) == 3\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130],k = 85) == 6\n assert candidate(nums = [2147483647, 2147483647, 2147483647, 2147483647, 2147483647],k = 1) == 2147483646\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125],k = 1000000000) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 10) == 0\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21],k = 10) == 1\n assert candidate(nums = [2147483647, 2147483646, 2147483645, 2147483644, 2147483643],k = 2147483640) == 3\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],k = 1024) == 0\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096],k = 2048) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 25) == 5\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 28) == 1\n assert candidate(nums = [13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31],k = 20) == 0\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768],k = 16384) == 0\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 9) == 0\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128],k = 100) == 4\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1023) == 1022\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 10) == 1\n assert candidate(nums = [13, 21, 34, 55, 89, 144, 233, 377, 610, 987],k = 159) == 15\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 5\n assert candidate(nums = [1, 2, 3, 5, 6, 7, 11, 13, 14, 15, 17, 19, 21, 22, 23, 26, 27, 29, 30, 31],k = 28) == 1\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000],k = 1000000000) == 0\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000],k = 1000000000) == 0\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().minimumDifference", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumDifference(vector& nums, int k) {", "container": "Solution", "callable": "minimumDifference", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3174, "task_id": "clear-digits", "difficulty": "Easy", "problem_description": "You are given a string s.\nYour task is to remove all digits by doing this operation repeatedly:\n\nDelete the first digit and the closest non-digit character to its left.\n\nReturn the resulting string after removing all digits.\nNote that the operation cannot be performed on a digit that does not have any non-digit character to its left.\n \nExample 1:\n\nInput: s = \"abc\"\nOutput: \"abc\"\nExplanation:\nThere is no digit in the string.\n\nExample 2:\n\nInput: s = \"cb34\"\nOutput: \"\"\nExplanation:\nFirst, we apply the operation on s[2], and s becomes \"c4\".\nThen we apply the operation on s[1], and s becomes \"\".\n\n \nConstraints:\n\n1 <= s.length <= 100\ns consists only of lowercase English letters and digits.\nThe input is generated such that it is possible to delete all digits.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcdef\") == \"abcdef\"\n assert candidate(s = \"a1b2c3d4e5\") == \"\"\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9j0\") == \"\"\n assert candidate(s = \"a1b2c3d4e5f6\") == \"\"\n assert candidate(s = \"a1b2c3\") == \"\"\n assert candidate(s = \"abcd1234\") == \"\"\n assert candidate(s = \"abcd1\") == \"abc\"\n assert candidate(s = \"cb34\") == \"\"\n assert candidate(s = \"a1b1c1\") == \"\"\n assert candidate(s = \"a1b2c3d4\") == \"\"\n assert candidate(s = \"a1b\") == \"b\"\n assert candidate(s = \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\") == \"\"\n assert candidate(s = \"abc\") == \"abc\"\n assert candidate(s = \"abc1d2e3\") == \"ab\"\n assert candidate(s = \"abcd\") == \"abcd\"\n assert candidate(s = \"abc123\") == \"\"\n assert candidate(s = \"z9y8x7w6v5u4t3s2r1q0p1o2n3m4l5k6j7i8h9g0f1e2d3c4b5a6\") == \"\"\n assert candidate(s = \"abc123d4ef5\") == \"e\"\n assert candidate(s = \"z1y2x3w4v5u6t7s8r9q0p1o2n3m4l5k6j7i8h9g0f1e2d3c4b5a6\") == \"\"\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0\") == \"\"\n assert candidate(s = \"xyz765mno432lmn109pqr876\") == \"\"\n assert candidate(s = \"hello2world1\") == \"hellworl\"\n assert candidate(s = \"zz9yy8xx7ww6vv5uu4tt3ss2rr1qqppooonnmmllkkjjiihhggffeedcba1\") == \"zyxwvutsrqqppooonnmmllkkjjiihhggffeedcb\"\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6a7b8c9d0e1f2g3h4i5j6k7l8m9n0o1p2q3r4s5t6u7v8w9x0y1z2a3b4c5d6e7f8g9h0i1j2k3l4m5n6o7p8q9r0s1t2u3v4w5x6y7z8\") == \"\"\n assert candidate(s = \"mnbv1234cvbnm5678mnbvc90\") == \"cmnb\"\n assert candidate(s = \"abcdefghij1klmnopqr2stuv3wxyz4abcd5efg6hij7klmno8pqr9stu0vwx1yz2\") == \"abcdefghiklmnopqstuwxyabcefhiklmnpqstvwy\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz1234567890\") == \"abcdefghijklmnop\"\n assert candidate(s = \"q1w2e3r4t5y6u7i8o9p0\") == \"\"\n assert candidate(s = \"abcdefghij1234567890klmnopqrstuvwxyz\") == \"klmnopqrstuvwxyz\"\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6\") == \"\"\n assert candidate(s = \"abcdefgh12345678ijkl90mnopqrstu12345678vwxyz0\") == \"ijmvwxy\"\n assert candidate(s = \"abcd1234abcd5678abcd90abcd\") == \"ababcd\"\n assert candidate(s = \"z9y8x7w6v5u4t3s2r1\") == \"\"\n assert candidate(s = \"x1y2z3a4b5c6d7e8f9g0\") == \"\"\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6\") == \"\"\n assert candidate(s = \"a1a2a3a4a5a6a7a8a9a0b1b2b3b4b5b6b7b8b9b0c1c2c3c4c5c6c7c8c9c0\") == \"\"\n assert candidate(s = \"abcdefgh1ijklm2nopqr3stuv4wxyz5\") == \"abcdefgijklnopqstuwxy\"\n assert candidate(s = \"m1n2o3p4q5r6s7t8u9v0w1x2y3z4\") == \"\"\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6a7b8c9d0\") == \"\"\n assert candidate(s = \"abcdefghij0987654321klmnopqrstuvwxyz\") == \"klmnopqrstuvwxyz\"\n assert candidate(s = \"abcdef123ghijkl456mnopq789rstuv0\") == \"abcghimnrstu\"\n assert candidate(s = \"x1y2z3x1y2z3\") == \"\"\n assert candidate(s = \"xyz123abc456def789ghi0\") == \"gh\"\n assert candidate(s = \"abcdefghi1jklmnopq2rstuvwxy3z\") == \"abcdefghjklmnoprstuvwxz\"\n assert candidate(s = \"aaa1bbb2ccc3ddd4eee5fff6ggg7hhh8iii9jjj\") == \"aabbccddeeffgghhiijjj\"\n assert candidate(s = \"abcdef1ghijkl2mnopqr3stuv4wxyz5\") == \"abcdeghijkmnopqstuwxy\"\n assert candidate(s = \"mno4pqr5stu6vwx7yz8\") == \"mnpqstvwy\"\n assert candidate(s = \"p1q2r3s4t5u6v7w8x9y0z1a2b3c4d5e6f7g8h9i0\") == \"\"\n assert candidate(s = \"abc123def456ghi789jkl0mno1pqr2stu3vwx4yz5\") == \"jkmnpqstvwy\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz0123456789\") == \"abcdefghijklmnop\"\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4\") == \"\"\n assert candidate(s = \"x9y8z7w6v5u4t3s2r1q0p\") == \"p\"\n assert candidate(s = \"x9y8z7\") == \"\"\n assert candidate(s = \"abcdefghi1jklmnopq2rstuv3wxyz4\") == \"abcdefghjklmnoprstuwxy\"\n assert candidate(s = \"m9n8o7p6q5r4s3t2u1\") == \"\"\n assert candidate(s = \"abc123def456ghi789jkl012mno345pqr678stu90\") == \"s\"\n assert candidate(s = \"z9y8x7w6v5u4t3s2r1q\") == \"q\"\n assert candidate(s = \"abcdefghij1klmnopqr2stuv3wxyz4\") == \"abcdefghiklmnopqstuwxy\"\n assert candidate(s = \"abcdef123ghijkl456mno789pqr12stu34vwxy5z\") == \"abcghipsvwxz\"\n assert candidate(s = \"abcdefghij1234567890\") == \"\"\n assert candidate(s = \"xyz123\") == \"\"\n assert candidate(s = \"abcd1234efgh5678ijkl90\") == \"ij\"\n assert candidate(s = \"abc1def2ghi3jkl4mno5pqr6stu7vwx8yz9\") == \"abdeghjkmnpqstvwy\"\n assert candidate(s = \"x9y8z7x6y5z4x3y2z1\") == \"\"\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6a7b8c9d0e1f2g3h4i5j6k7l8m9n0o1p2q3r4s5t6u7v8w9x0y1z2\") == \"\"\n assert candidate(s = \"z9y8x7w6v5u4t3s2r1q0ponmlkjihgfedcba\") == \"ponmlkjihgfedcba\"\n assert candidate(s = \"xyz7uvw8mno9\") == \"xyuvmn\"\n assert candidate(s = \"abcdefghij1klmnopq2rstuv3wxyz4\") == \"abcdefghiklmnoprstuwxy\"\n assert candidate(s = \"p1q2r3s4t5u6v7w8x9y0z\") == \"z\"\n assert candidate(s = \"z1y2x3w4v5u6t7s8r9q0\") == \"\"\n assert candidate(s = \"abcdefghij1klmnopq2rstuvwx3yz\") == \"abcdefghiklmnoprstuvwyz\"\n assert candidate(s = \"abcdef1ghijkl2mnopqr3stuv4wxyz5abcdef6ghijkl7mnopqr8stuv9wxyz0\") == \"abcdeghijkmnopqstuwxyabcdeghijkmnopqstuwxy\"\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().clearDigits", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string clearDigits(string s) {", "container": "Solution", "callable": "clearDigits", "parameters": [{"name": "s", "type": "string"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3175, "task_id": "find-the-first-player-to-win-k-games-in-a-row", "difficulty": "Medium", "problem_description": "A competition consists of n players numbered from 0 to n - 1.\nYou are given an integer array skills of size n and a positive integer k, where skills[i] is the skill level of player i. All integers in skills are unique.\nAll players are standing in a queue in order from player 0 to player n - 1.\nThe competition process is as follows:\n\nThe first two players in the queue play a game, and the player with the higher skill level wins.\nAfter the game, the winner stays at the beginning of the queue, and the loser goes to the end of it.\n\nThe winner of the competition is the first player who wins k games in a row.\nReturn the initial index of the winning player.\n \nExample 1:\n\nInput: skills = [4,2,6,3,9], k = 2\nOutput: 2\nExplanation:\nInitially, the queue of players is [0,1,2,3,4]. The following process happens:\n\nPlayers 0 and 1 play a game, since the skill of player 0 is higher than that of player 1, player 0 wins. The resulting queue is [0,2,3,4,1].\nPlayers 0 and 2 play a game, since the skill of player 2 is higher than that of player 0, player 2 wins. The resulting queue is [2,3,4,1,0].\nPlayers 2 and 3 play a game, since the skill of player 2 is higher than that of player 3, player 2 wins. The resulting queue is [2,4,1,0,3].\n\nPlayer 2 won k = 2 games in a row, so the winner is player 2.\n\nExample 2:\n\nInput: skills = [2,5,4], k = 3\nOutput: 1\nExplanation:\nInitially, the queue of players is [0,1,2]. The following process happens:\n\nPlayers 0 and 1 play a game, since the skill of player 1 is higher than that of player 0, player 1 wins. The resulting queue is [1,2,0].\nPlayers 1 and 2 play a game, since the skill of player 1 is higher than that of player 2, player 1 wins. The resulting queue is [1,0,2].\nPlayers 1 and 0 play a game, since the skill of player 1 is higher than that of player 0, player 1 wins. The resulting queue is [1,2,0].\n\nPlayer 1 won k = 3 games in a row, so the winner is player 1.\n\n \nConstraints:\n\nn == skills.length\n2 <= n <= 105\n1 <= k <= 109\n1 <= skills[i] <= 106\nAll integers in skills are unique.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(skills = [5, 1, 9, 2, 8, 3, 7, 4, 6],k = 3) == 2\n assert candidate(skills = [1000000, 999999, 999998, 999997],k = 4) == 0\n assert candidate(skills = [2, 5, 4],k = 3) == 1\n assert candidate(skills = [1, 3, 2, 5, 4],k = 1) == 1\n assert candidate(skills = [10, 20, 30, 40, 50],k = 5) == 4\n assert candidate(skills = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 0\n assert candidate(skills = [1000000, 1, 2, 3, 4],k = 4) == 0\n assert candidate(skills = [5, 10, 15, 20, 25, 30],k = 2) == 5\n assert candidate(skills = [50, 40, 30, 20, 10],k = 4) == 0\n assert candidate(skills = [4, 2, 6, 3, 9],k = 2) == 2\n assert candidate(skills = [5, 4, 3, 2, 1],k = 5) == 0\n assert candidate(skills = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 9\n assert candidate(skills = [1, 3, 5, 7, 9],k = 1) == 1\n assert candidate(skills = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 9) == 9\n assert candidate(skills = [3, 1, 2, 5, 4, 6, 7],k = 3) == 6\n assert candidate(skills = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 8) == 0\n assert candidate(skills = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10],k = 3) == 4\n assert candidate(skills = [2, 1, 5, 4, 3, 6],k = 2) == 2\n assert candidate(skills = [2, 4, 6, 8, 10, 1, 3, 5, 7, 9],k = 2) == 4\n assert candidate(skills = [9, 1, 8, 2, 7, 3, 6, 4, 5, 10],k = 3) == 0\n assert candidate(skills = [500, 400, 300, 200, 100, 600, 700, 800, 900, 1000],k = 4) == 0\n assert candidate(skills = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 19) == 0\n assert candidate(skills = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9],k = 10) == 8\n assert candidate(skills = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 10) == 14\n assert candidate(skills = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 5) == 9\n assert candidate(skills = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 100000) == 9\n assert candidate(skills = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 5) == 5\n assert candidate(skills = [1000, 100, 10, 1],k = 100) == 0\n assert candidate(skills = [5, 1, 9, 2, 8, 3, 7, 4, 6, 10],k = 5) == 2\n assert candidate(skills = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 0\n assert candidate(skills = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105],k = 7) == 9\n assert candidate(skills = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 0\n assert candidate(skills = [5, 3, 1, 4, 2],k = 3) == 0\n assert candidate(skills = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 5) == 0\n assert candidate(skills = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019],k = 10) == 19\n assert candidate(skills = [1, 10, 3, 4, 7, 5, 6, 9, 8, 2],k = 4) == 1\n assert candidate(skills = [8, 4, 6, 2, 7, 3, 9, 1, 5, 10],k = 9) == 9\n assert candidate(skills = [1, 10, 3, 8, 5, 6, 7, 2, 4, 9],k = 7) == 1\n assert candidate(skills = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9],k = 4) == 8\n assert candidate(skills = [50, 51, 48, 49, 46, 47, 44, 45, 42, 43, 40, 41, 38, 39, 36, 37, 34, 35, 32, 33],k = 10) == 1\n assert candidate(skills = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 9\n assert candidate(skills = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 10) == 9\n assert candidate(skills = [3, 1, 2, 5, 4, 7, 6, 9, 8, 10],k = 3) == 9\n assert candidate(skills = [100000, 99999, 99998, 99997, 99996],k = 100000) == 0\n assert candidate(skills = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 1) == 0\n assert candidate(skills = [1000000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1000000) == 0\n assert candidate(skills = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 0\n assert candidate(skills = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10],k = 5) == 9\n assert candidate(skills = [23, 45, 12, 56, 89, 43, 21, 67, 8, 90],k = 5) == 4\n assert candidate(skills = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109],k = 2) == 9\n assert candidate(skills = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 3) == 5\n assert candidate(skills = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1],k = 5) == 0\n assert candidate(skills = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991],k = 10) == 0\n assert candidate(skills = [10, 2, 15, 3, 20, 5, 25, 7, 30, 9],k = 5) == 8\n assert candidate(skills = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],k = 5) == 0\n assert candidate(skills = [1, 1000000],k = 1000000) == 1\n assert candidate(skills = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991],k = 100) == 0\n assert candidate(skills = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 9) == 0\n assert candidate(skills = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 11, 12, 13, 14, 15],k = 5) == 0\n assert candidate(skills = [500000, 500001, 500002, 500003, 500004, 500005, 500006, 500007, 500008, 500009],k = 5) == 9\n assert candidate(skills = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 10) == 9\n assert candidate(skills = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10],k = 5) == 4\n assert candidate(skills = [8, 7, 6, 5, 4, 3, 2, 1],k = 7) == 0\n assert candidate(skills = [7, 6, 5, 4, 3, 2, 1],k = 6) == 0\n assert candidate(skills = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 10) == 14\n assert candidate(skills = [2, 3, 1, 5, 4],k = 4) == 3\n assert candidate(skills = [20, 30, 10, 40, 50, 60, 70, 80, 90, 100],k = 3) == 9\n assert candidate(skills = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11],k = 8) == 0\n assert candidate(skills = [999999, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 9) == 0\n assert candidate(skills = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90],k = 10) == 0\n assert candidate(skills = [9, 1, 2, 8, 3, 7, 4, 6, 5, 10],k = 4) == 0\n assert candidate(skills = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 50, 40, 30, 20, 10],k = 5) == 9\n assert candidate(skills = [1, 3, 2, 4, 6, 5, 7, 9, 8, 10],k = 7) == 9\n assert candidate(skills = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 12) == 13\n assert candidate(skills = [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32],k = 8) == 14\n assert candidate(skills = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10],k = 5) == 9\n assert candidate(skills = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 15) == 19\n assert candidate(skills = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6],k = 8) == 5\n assert candidate(skills = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 10) == 19\n assert candidate(skills = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991],k = 999990) == 0\n assert candidate(skills = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 5) == 14\n assert candidate(skills = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95],k = 6) == 1\n assert candidate(skills = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 5) == 9\n assert candidate(skills = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 19\n assert candidate(skills = [500, 250, 750, 125, 875, 375, 625, 687, 937, 187, 437, 787, 287, 1125, 1062],k = 7) == 13\n assert candidate(skills = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 0\n assert candidate(skills = [10, 1, 9, 2, 8, 3, 7, 4, 6, 5],k = 5) == 0\n assert candidate(skills = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2],k = 1) == 0\n assert candidate(skills = [1000000, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 1) == 0\n assert candidate(skills = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 1) == 1\n assert candidate(skills = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6],k = 6) == 5\n assert candidate(skills = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 20) == 19\n assert candidate(skills = [1, 1, 1, 1, 1, 1, 1, 1, 1, 100],k = 1) == 0\n assert candidate(skills = [3, 1, 2, 5, 4, 8, 7, 10, 9, 6],k = 3) == 7\n assert candidate(skills = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10],k = 10) == 9\n assert candidate(skills = [5, 3, 8, 1, 9, 2, 7, 4, 6, 10],k = 7) == 9\n assert candidate(skills = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91],k = 90) == 1\n assert candidate(skills = [1000, 100, 10, 1, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],k = 8) == 9\n assert candidate(skills = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991],k = 6) == 0\n assert candidate(skills = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 1) == 1\n assert candidate(skills = [10, 20, 30, 40, 50, 60, 70, 80, 90, 1],k = 9) == 8\n assert candidate(skills = [32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4],k = 7) == 0\n assert candidate(skills = [9, 3, 1, 7, 5, 2, 8, 6, 4, 10],k = 5) == 0\n assert candidate(skills = [3, 1, 2, 5, 4, 6],k = 3) == 5\n assert candidate(skills = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],k = 4) == 1\n assert candidate(skills = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14],k = 6) == 13\n assert candidate(skills = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 25) == 29\n assert candidate(skills = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],k = 9) == 0\n assert candidate(skills = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],k = 1) == 0\n assert candidate(skills = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 19) == 19\n assert candidate(skills = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 5) == 9\n assert candidate(skills = [4, 1, 3, 2, 5, 7, 6, 8, 10, 9],k = 4) == 8\n assert candidate(skills = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],k = 9) == 9\n assert candidate(skills = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96],k = 8) == 1\n assert candidate(skills = [25, 50, 75, 100, 125, 150, 175, 200, 225, 250],k = 8) == 9\n assert candidate(skills = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 1) == 0\n assert candidate(skills = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96],k = 5) == 1\n assert candidate(skills = [7, 3, 9, 2, 8, 4, 6, 1, 5],k = 3) == 2\n assert candidate(skills = [200, 150, 300, 100, 250, 400, 50, 350, 500],k = 5) == 8\n assert candidate(skills = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 10) == 9\n assert candidate(skills = [100, 101, 99, 102, 98, 103, 97, 104, 96, 105],k = 5) == 9\n assert candidate(skills = [10, 2, 8, 4, 6, 1, 3, 5, 7, 9],k = 3) == 0\n assert candidate(skills = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 100) == 9\n assert candidate(skills = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 2) == 0\n assert candidate(skills = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20, 22, 23, 25, 26, 28, 29],k = 15) == 9\n assert candidate(skills = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109],k = 10) == 9\n assert candidate(skills = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 15) == 14\n assert candidate(skills = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],k = 3) == 1\n"}, "metadata": {"canonical_parameter_names": ["skills", "k"], "leetcode_dataset_entry_point": "Solution().findWinningPlayer", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int findWinningPlayer(vector& skills, int k) {", "container": "Solution", "callable": "findWinningPlayer", "parameters": [{"name": "skills", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3176, "task_id": "find-the-maximum-length-of-a-good-subsequence-i", "difficulty": "Medium", "problem_description": "You are given an integer array nums and a non-negative integer k. A sequence of integers seq is called good if there are at most k indices i in the range [0, seq.length - 2] such that seq[i] != seq[i + 1].\nReturn the maximum possible length of a good subsequence of nums.\n \nExample 1:\n\nInput: nums = [1,2,1,1,3], k = 2\nOutput: 4\nExplanation:\nThe maximum length subsequence is [1,2,1,1,3].\n\nExample 2:\n\nInput: nums = [1,2,3,4,5,1], k = 0\nOutput: 2\nExplanation:\nThe maximum length subsequence is [1,2,3,4,5,1].\n\n \nConstraints:\n\n1 <= nums.length <= 500\n1 <= nums[i] <= 109\n0 <= k <= min(nums.length, 25)\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 1, 1, 1, 1],k = 3) == 5\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 4) == 10\n assert candidate(nums = [1, 2, 3, 2, 1],k = 1) == 3\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 0) == 1\n assert candidate(nums = [1, 2, 1, 1, 3],k = 2) == 4\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],k = 2) == 9\n assert candidate(nums = [1, 2],k = 1) == 2\n assert candidate(nums = [1, 2, 1, 3, 1, 2, 1],k = 2) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 9) == 10\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 3) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == 4\n assert candidate(nums = [1, 2, 2, 2, 1, 2],k = 1) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5],k = 1) == 3\n assert candidate(nums = [1, 3, 2, 3, 1, 4, 1, 2, 3, 4],k = 2) == 5\n assert candidate(nums = [5, 4, 3, 2, 1],k = 1) == 2\n assert candidate(nums = [10, 20, 30, 40, 50],k = 5) == 5\n assert candidate(nums = [5, 5, 5, 5, 5],k = 1) == 5\n assert candidate(nums = [1],k = 0) == 1\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3],k = 4) == 6\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 0) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 1],k = 0) == 2\n assert candidate(nums = [1, 3, 2, 3, 1, 2, 3, 1, 2, 3],k = 3) == 6\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 6\n assert candidate(nums = [1, 1, 1, 1, 1],k = 1) == 5\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4],k = 3) == 8\n assert candidate(nums = [10, 20, 30, 40, 50],k = 3) == 4\n assert candidate(nums = [1, 2, 2, 2, 1, 2, 1],k = 2) == 6\n assert candidate(nums = [5, 5, 5, 5, 5],k = 0) == 5\n assert candidate(nums = [1, 1, 1, 1, 1],k = 0) == 5\n assert candidate(nums = [10, 20, 30, 20, 10, 5, 5, 5, 5],k = 3) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 0) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5],k = 5) == 6\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 2) == 3\n assert candidate(nums = [1, 2, 2, 1, 2, 2, 1, 2, 2, 1],k = 3) == 8\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13],k = 0) == 1\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 0) == 10\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5],k = 10) == 20\n assert candidate(nums = [1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3],k = 5) == 13\n assert candidate(nums = [1, 2, 1, 3, 2, 3, 1, 4, 1, 2, 3, 4, 1, 2, 3, 1, 4, 1, 2, 3, 4],k = 5) == 12\n assert candidate(nums = [5, 1, 3, 5, 7, 5, 3, 1, 5],k = 4) == 6\n assert candidate(nums = [1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1],k = 2) == 9\n assert candidate(nums = [1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 15) == 24\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],k = 3) == 14\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 10) == 28\n assert candidate(nums = [100, 200, 100, 300, 100, 400, 100, 500, 100, 600, 100, 700, 100, 800, 100, 900, 100, 1000, 100, 1100, 100, 1200, 100, 1300, 100],k = 15) == 20\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],k = 12) == 16\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 15) == 16\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5],k = 2) == 15\n assert candidate(nums = [100, 200, 100, 300, 200, 400, 300, 500, 400, 600, 500, 700, 600, 800, 700],k = 7) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],k = 5) == 8\n assert candidate(nums = [100, 200, 300, 200, 100, 300, 200, 100, 300, 200, 100],k = 6) == 8\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13],k = 7) == 16\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],k = 5) == 9\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 0) == 10\n assert candidate(nums = [100, 200, 300, 400, 500, 100, 200, 300, 400, 500, 100, 200, 300, 400, 500],k = 5) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 20) == 24\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 0) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 20\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 4) == 6\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7],k = 7) == 21\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 20) == 21\n assert candidate(nums = [1, 2, 1, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1],k = 3) == 7\n assert candidate(nums = [1000000000, 999999999, 1000000000, 999999999, 1000000000, 999999999],k = 2) == 4\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 0) == 88\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 7\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 20) == 32\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1],k = 4) == 7\n assert candidate(nums = [100, 200, 100, 300, 100, 200, 300, 400, 500, 100, 200],k = 4) == 7\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 5) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2],k = 3) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 9) == 11\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3],k = 3) == 15\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 1, 2, 2, 3, 3],k = 5) == 12\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10],k = 10) == 40\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 7\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 0) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],k = 10) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 12\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5],k = 5) == 9\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 0) == 20\n assert candidate(nums = [10, 20, 30, 20, 10, 20, 30, 20, 10],k = 2) == 6\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 13\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1],k = 7) == 14\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 0) == 1\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7],k = 2) == 9\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 5) == 12\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 8],k = 4) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 3) == 4\n assert candidate(nums = [1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3],k = 10) == 17\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 15) == 25\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 4, 3, 2, 1],k = 10) == 16\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 3) == 8\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 10) == 20\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9],k = 10) == 14\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 15) == 19\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 2],k = 8) == 17\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 9) == 20\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 5) == 13\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3],k = 10) == 33\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 6, 6, 7, 8, 8, 9, 10, 10],k = 3) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4],k = 3) == 8\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5],k = 4) == 8\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],k = 3) == 10\n assert candidate(nums = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1, 12, 1, 13, 1],k = 15) == 20\n assert candidate(nums = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20],k = 20) == 61\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 2) == 6\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().maximumLength", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maximumLength(vector& nums, int k) {", "container": "Solution", "callable": "maximumLength", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3177, "task_id": "find-the-maximum-length-of-a-good-subsequence-ii", "difficulty": "Hard", "problem_description": "You are given an integer array nums and a non-negative integer k. A sequence of integers seq is called good if there are at most k indices i in the range [0, seq.length - 2] such that seq[i] != seq[i + 1].\nReturn the maximum possible length of a good subsequence of nums.\n \nExample 1:\n\nInput: nums = [1,2,1,1,3], k = 2\nOutput: 4\nExplanation:\nThe maximum length subsequence is [1,2,1,1,3].\n\nExample 2:\n\nInput: nums = [1,2,3,4,5,1], k = 0\nOutput: 2\nExplanation:\nThe maximum length subsequence is [1,2,3,4,5,1].\n\n \nConstraints:\n\n1 <= nums.length <= 5 * 103\n1 <= nums[i] <= 109\n0 <= k <= min(50, nums.length)\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 5, 5, 5, 5],k = 5) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 50) == 10\n assert candidate(nums = [1, 1, 1, 1, 1],k = 3) == 5\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 4) == 10\n assert candidate(nums = [1, 2, 3, 2, 1],k = 1) == 3\n assert candidate(nums = [1, 2, 1, 1, 3],k = 2) == 4\n assert candidate(nums = [1, 3, 5, 3, 1, 3, 5, 3, 1],k = 2) == 6\n assert candidate(nums = [1, 2, 3, 4, 5],k = 5) == 5\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5],k = 2) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 6\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 3) == 8\n assert candidate(nums = [10, 20, 20, 10, 10, 20, 10, 20, 10],k = 1) == 6\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 3) == 10\n assert candidate(nums = [1, 2, 3, 4, 5],k = 2) == 3\n assert candidate(nums = [1, 3, 5, 7, 9, 7, 5, 3, 1],k = 4) == 6\n assert candidate(nums = [5, 5, 5, 5, 5],k = 1) == 5\n assert candidate(nums = [1],k = 0) == 1\n assert candidate(nums = [5, 5, 5, 5, 5],k = 3) == 5\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 0) == 10\n assert candidate(nums = [10, 20, 10, 30, 10, 20, 30],k = 1) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 1],k = 0) == 2\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 6\n assert candidate(nums = [1, 2, 2, 2, 1, 2, 1],k = 1) == 5\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1],k = 2) == 6\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 0) == 2\n assert candidate(nums = [1, 1, 1, 1, 1],k = 0) == 5\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000],k = 0) == 5\n assert candidate(nums = [10, 20, 30, 20, 10, 10, 20, 30],k = 2) == 5\n assert candidate(nums = [1, 3, 1, 3, 1, 3, 1],k = 2) == 5\n assert candidate(nums = [1, 3, 2, 3, 1, 2, 1],k = 2) == 5\n assert candidate(nums = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1],k = 3) == 8\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14],k = 15) == 28\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 0) == 1\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],k = 20) == 50\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 12) == 13\n assert candidate(nums = [1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2],k = 25) == 41\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 5],k = 3) == 11\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2],k = 6) == 13\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 15) == 18\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 9) == 20\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5],k = 4) == 15\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 31\n assert candidate(nums = [1, 2, 2, 3, 3, 2, 2, 1, 1, 2, 2, 3, 3, 2, 2, 1, 1, 2, 2, 3, 3],k = 5) == 16\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 0) == 15\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],k = 10) == 16\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 1, 2, 3, 4, 5],k = 5) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 8) == 10\n assert candidate(nums = [9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8, 9, 8],k = 8) == 14\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 10) == 19\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10],k = 4) == 15\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20],k = 15) == 32\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],k = 15) == 16\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 15) == 17\n assert candidate(nums = [1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1],k = 20) == 28\n assert candidate(nums = [5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4],k = 5) == 13\n assert candidate(nums = [1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1],k = 7) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 9) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 5) == 6\n assert candidate(nums = [1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1],k = 5) == 20\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 15) == 23\n assert candidate(nums = [4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 4, 3, 2, 1],k = 4) == 8\n assert candidate(nums = [1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2],k = 10) == 28\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == 21\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 5) == 16\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 21\n assert candidate(nums = [1, 2, 2, 1, 2, 1, 2, 2, 1, 2, 1, 2, 2, 1, 2, 1, 2, 2, 1, 2],k = 10) == 17\n assert candidate(nums = [1, 1, 2, 3, 2, 3, 1, 2, 3, 4, 3, 4, 1, 2, 3, 4, 5, 4, 5, 6],k = 9) == 15\n assert candidate(nums = [5, 6, 7, 8, 7, 8, 7, 6, 5],k = 3) == 6\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],k = 7) == 16\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 7\n assert candidate(nums = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5],k = 5) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4) == 5\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 10) == 20\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 1) == 9\n assert candidate(nums = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1, 12, 1, 13, 1, 14, 1, 15, 1, 16, 1, 17, 1, 18, 1, 19, 1, 20],k = 10) == 24\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 5) == 12\n assert candidate(nums = [10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20, 30],k = 7) == 12\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 8) == 14\n assert candidate(nums = [1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1],k = 10) == 17\n assert candidate(nums = [1, 2, 1, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1],k = 5) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],k = 4) == 9\n assert candidate(nums = [10, 20, 30, 20, 10, 20, 30, 20, 10, 20, 30, 20, 10],k = 6) == 10\n assert candidate(nums = [10, 20, 10, 30, 20, 40, 30, 50, 40, 60, 50, 70, 60, 80, 70, 90, 80, 100, 90, 110],k = 10) == 14\n assert candidate(nums = [5, 5, 4, 4, 4, 3, 3, 3, 3, 2, 2, 1],k = 4) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4],k = 9) == 14\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 2, 2, 1, 1, 1],k = 5) == 13\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50],k = 0) == 2\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7],k = 7) == 21\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == 4\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],k = 15) == 26\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 11\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 4, 5, 6, 6, 6, 6, 7, 8, 8, 9],k = 3) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 11\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1],k = 3) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],k = 3) == 7\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2],k = 5) == 13\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 0) == 142\n assert candidate(nums = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1],k = 2) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 0) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 14\n assert candidate(nums = [2, 2, 3, 3, 2, 2, 3, 3, 2, 2],k = 1) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6],k = 5) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 10) == 11\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 0) == 10\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 0) == 2\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6],k = 10) == 21\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().maximumLength", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maximumLength(vector& nums, int k) {", "container": "Solution", "callable": "maximumLength", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3178, "task_id": "find-the-child-who-has-the-ball-after-k-seconds", "difficulty": "Easy", "problem_description": "You are given two positive integers n and k. There are n children numbered from 0 to n - 1 standing in a queue in order from left to right.\nInitially, child 0 holds a ball and the direction of passing the ball is towards the right direction. After each second, the child holding the ball passes it to the child next to them. Once the ball reaches either end of the line, i.e. child 0 or child n - 1, the direction of passing is reversed.\nReturn the number of the child who receives the ball after k seconds.\n \nExample 1:\n\nInput: n = 3, k = 5\nOutput: 1\nExplanation:\n\n\n\nTime elapsed\nChildren\n\n\n0\n[0, 1, 2]\n\n\n1\n[0, 1, 2]\n\n\n2\n[0, 1, 2]\n\n\n3\n[0, 1, 2]\n\n\n4\n[0, 1, 2]\n\n\n5\n[0, 1, 2]\n\n\n\n\nExample 2:\n\nInput: n = 5, k = 6\nOutput: 2\nExplanation:\n\n\n\nTime elapsed\nChildren\n\n\n0\n[0, 1, 2, 3, 4]\n\n\n1\n[0, 1, 2, 3, 4]\n\n\n2\n[0, 1, 2, 3, 4]\n\n\n3\n[0, 1, 2, 3, 4]\n\n\n4\n[0, 1, 2, 3, 4]\n\n\n5\n[0, 1, 2, 3, 4]\n\n\n6\n[0, 1, 2, 3, 4]\n\n\n\n\nExample 3:\n\nInput: n = 4, k = 2\nOutput: 2\nExplanation:\n\n\n\nTime elapsed\nChildren\n\n\n0\n[0, 1, 2, 3]\n\n\n1\n[0, 1, 2, 3]\n\n\n2\n[0, 1, 2, 3]\n\n\n\n\n \nConstraints:\n\n2 <= n <= 50\n1 <= k <= 50\n\n \nNote: This question is the same as 2582: Pass the Pillow.\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 50,k = 50) == 48\n assert candidate(n = 3,k = 5) == 1\n assert candidate(n = 2,k = 1) == 1\n assert candidate(n = 40,k = 20) == 20\n assert candidate(n = 5,k = 6) == 2\n assert candidate(n = 10,k = 15) == 3\n assert candidate(n = 2,k = 2) == 0\n assert candidate(n = 2,k = 50) == 0\n assert candidate(n = 4,k = 2) == 2\n assert candidate(n = 25,k = 50) == 2\n assert candidate(n = 49,k = 75) == 21\n assert candidate(n = 18,k = 36) == 2\n assert candidate(n = 20,k = 300) == 4\n assert candidate(n = 45,k = 270) == 6\n assert candidate(n = 45,k = 101) == 13\n assert candidate(n = 35,k = 99) == 31\n assert candidate(n = 33,k = 231) == 25\n assert candidate(n = 23,k = 60) == 16\n assert candidate(n = 15,k = 47) == 9\n assert candidate(n = 30,k = 85) == 27\n assert candidate(n = 12,k = 150) == 4\n assert candidate(n = 40,k = 199) == 35\n assert candidate(n = 49,k = 99) == 3\n assert candidate(n = 30,k = 90) == 26\n assert candidate(n = 50,k = 100) == 2\n assert candidate(n = 28,k = 99) == 9\n assert candidate(n = 17,k = 75) == 11\n assert candidate(n = 20,k = 60) == 16\n assert candidate(n = 45,k = 100) == 12\n assert candidate(n = 23,k = 115) == 17\n assert candidate(n = 29,k = 87) == 25\n assert candidate(n = 20,k = 75) == 1\n assert candidate(n = 40,k = 200) == 34\n assert candidate(n = 8,k = 100) == 2\n assert candidate(n = 35,k = 49) == 19\n assert candidate(n = 32,k = 150) == 26\n assert candidate(n = 18,k = 80) == 12\n assert candidate(n = 37,k = 110) == 34\n assert candidate(n = 30,k = 250) == 18\n assert candidate(n = 40,k = 85) == 7\n assert candidate(n = 17,k = 85) == 11\n assert candidate(n = 15,k = 225) == 1\n assert candidate(n = 41,k = 90) == 10\n assert candidate(n = 35,k = 140) == 4\n assert candidate(n = 15,k = 150) == 10\n assert candidate(n = 35,k = 100) == 32\n assert candidate(n = 18,k = 180) == 10\n assert candidate(n = 22,k = 55) == 13\n assert candidate(n = 50,k = 123) == 25\n assert candidate(n = 15,k = 60) == 4\n assert candidate(n = 28,k = 63) == 9\n assert candidate(n = 49,k = 49) == 47\n assert candidate(n = 35,k = 120) == 16\n assert candidate(n = 28,k = 100) == 8\n assert candidate(n = 50,k = 250) == 44\n assert candidate(n = 28,k = 196) == 20\n assert candidate(n = 18,k = 90) == 12\n assert candidate(n = 50,k = 125) == 27\n assert candidate(n = 30,k = 225) == 7\n assert candidate(n = 30,k = 98) == 18\n assert candidate(n = 35,k = 70) == 2\n assert candidate(n = 49,k = 48) == 48\n assert candidate(n = 35,k = 350) == 10\n assert candidate(n = 45,k = 120) == 32\n assert candidate(n = 28,k = 140) == 22\n assert candidate(n = 45,k = 200) == 24\n assert candidate(n = 20,k = 99) == 15\n assert candidate(n = 50,k = 49) == 49\n assert candidate(n = 20,k = 49) == 11\n assert candidate(n = 13,k = 195) == 3\n assert candidate(n = 45,k = 180) == 4\n assert candidate(n = 20,k = 199) == 9\n assert candidate(n = 40,k = 400) == 10\n assert candidate(n = 49,k = 225) == 33\n assert candidate(n = 35,k = 175) == 29\n assert candidate(n = 27,k = 70) == 18\n assert candidate(n = 49,k = 98) == 2\n assert candidate(n = 15,k = 120) == 8\n assert candidate(n = 28,k = 120) == 12\n assert candidate(n = 50,k = 25) == 25\n assert candidate(n = 30,k = 100) == 16\n assert candidate(n = 30,k = 180) == 6\n"}, "metadata": {"canonical_parameter_names": ["n", "k"], "leetcode_dataset_entry_point": "Solution().numberOfChild", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int numberOfChild(int n, int k) {", "container": "Solution", "callable": "numberOfChild", "parameters": [{"name": "n", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3179, "task_id": "find-the-n-th-value-after-k-seconds", "difficulty": "Medium", "problem_description": "You are given two integers n and k.\nInitially, you start with an array a of n integers where a[i] = 1 for all 0 <= i <= n - 1. After each second, you simultaneously update each element to be the sum of all its preceding elements plus the element itself. For example, after one second, a[0] remains the same, a[1] becomes a[0] + a[1], a[2] becomes a[0] + a[1] + a[2], and so on.\nReturn the value of a[n - 1] after k seconds.\nSince the answer may be very large, return it modulo 109 + 7.\n \nExample 1:\n\nInput: n = 4, k = 5\nOutput: 56\nExplanation:\n\n\n\nSecond\nState After\n\n\n0\n[1,1,1,1]\n\n\n1\n[1,2,3,4]\n\n\n2\n[1,3,6,10]\n\n\n3\n[1,4,10,20]\n\n\n4\n[1,5,15,35]\n\n\n5\n[1,6,21,56]\n\n\n\n\nExample 2:\n\nInput: n = 5, k = 3\nOutput: 35\nExplanation:\n\n\n\nSecond\nState After\n\n\n0\n[1,1,1,1,1]\n\n\n1\n[1,2,3,4,5]\n\n\n2\n[1,3,6,10,15]\n\n\n3\n[1,4,10,20,35]\n\n\n\n\n \nConstraints:\n\n1 <= n, k <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 7,k = 4) == 210\n assert candidate(n = 2,k = 4) == 5\n assert candidate(n = 2,k = 5) == 6\n assert candidate(n = 8,k = 4) == 330\n assert candidate(n = 2,k = 1) == 2\n assert candidate(n = 1,k = 1) == 1\n assert candidate(n = 3,k = 2) == 6\n assert candidate(n = 6,k = 2) == 21\n assert candidate(n = 4,k = 5) == 56\n assert candidate(n = 3,k = 7) == 36\n assert candidate(n = 10,k = 10) == 92378\n assert candidate(n = 5,k = 3) == 35\n assert candidate(n = 3,k = 100) == 5151\n assert candidate(n = 9,k = 4) == 495\n assert candidate(n = 200,k = 200) == 793946740\n assert candidate(n = 6,k = 8) == 1287\n assert candidate(n = 200,k = 100) == 824578740\n assert candidate(n = 15,k = 15) == 77558760\n assert candidate(n = 9,k = 18) == 1562275\n assert candidate(n = 7,k = 3) == 84\n assert candidate(n = 15,k = 3) == 680\n assert candidate(n = 15,k = 1) == 15\n assert candidate(n = 30,k = 20) == 527148437\n assert candidate(n = 20,k = 20) == 923263934\n assert candidate(n = 10,k = 1) == 10\n assert candidate(n = 2,k = 1000) == 1001\n assert candidate(n = 7,k = 15) == 54264\n assert candidate(n = 8,k = 1) == 8\n assert candidate(n = 100,k = 50) == 475860182\n assert candidate(n = 250,k = 500) == 540818587\n assert candidate(n = 999,k = 999) == 482800871\n assert candidate(n = 30,k = 25) == 462115415\n assert candidate(n = 10,k = 5) == 2002\n assert candidate(n = 5,k = 10) == 1001\n assert candidate(n = 8,k = 3) == 120\n assert candidate(n = 15,k = 10) == 1961256\n assert candidate(n = 6,k = 15) == 15504\n assert candidate(n = 30,k = 30) == 368504682\n assert candidate(n = 75,k = 75) == 133231804\n assert candidate(n = 8,k = 7) == 3432\n assert candidate(n = 7,k = 7) == 1716\n assert candidate(n = 500,k = 500) == 579917918\n assert candidate(n = 20,k = 5) == 42504\n assert candidate(n = 5,k = 5) == 126\n assert candidate(n = 20,k = 15) == 855967513\n assert candidate(n = 4,k = 20) == 1771\n assert candidate(n = 7,k = 5) == 462\n assert candidate(n = 50,k = 50) == 769496025\n assert candidate(n = 1000,k = 1000) == 36237869\n assert candidate(n = 6,k = 3) == 56\n assert candidate(n = 15,k = 7) == 116280\n assert candidate(n = 250,k = 50) == 46410598\n assert candidate(n = 6,k = 6) == 462\n assert candidate(n = 1000,k = 1) == 1000\n assert candidate(n = 8,k = 8) == 6435\n assert candidate(n = 300,k = 250) == 244556185\n assert candidate(n = 11,k = 25) == 183579396\n assert candidate(n = 7,k = 20) == 230230\n assert candidate(n = 12,k = 12) == 1352078\n assert candidate(n = 50,k = 40) == 280099481\n assert candidate(n = 1,k = 1000) == 1\n assert candidate(n = 100,k = 100) == 703668401\n assert candidate(n = 500,k = 250) == 81637167\n"}, "metadata": {"canonical_parameter_names": ["n", "k"], "leetcode_dataset_entry_point": "Solution().valueAfterKSeconds", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int valueAfterKSeconds(int n, int k) {", "container": "Solution", "callable": "valueAfterKSeconds", "parameters": [{"name": "n", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3180, "task_id": "maximum-total-reward-using-operations-i", "difficulty": "Medium", "problem_description": "You are given an integer array rewardValues of length n, representing the values of rewards.\nInitially, your total reward x is 0, and all indices are unmarked. You are allowed to perform the following operation any number of times:\n\nChoose an unmarked index i from the range [0, n - 1].\nIf rewardValues[i] is greater than your current total reward x, then add rewardValues[i] to x (i.e., x = x + rewardValues[i]), and mark the index i.\n\nReturn an integer denoting the maximum total reward you can collect by performing the operations optimally.\n \nExample 1:\n\nInput: rewardValues = [1,1,3,3]\nOutput: 4\nExplanation:\nDuring the operations, we can choose to mark the indices 0 and 2 in order, and the total reward will be 4, which is the maximum.\n\nExample 2:\n\nInput: rewardValues = [1,6,4,3,2]\nOutput: 11\nExplanation:\nMark the indices 0, 2, and 1 in order. The total reward will then be 11, which is the maximum.\n\n \nConstraints:\n\n1 <= rewardValues.length <= 2000\n1 <= rewardValues[i] <= 2000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(rewardValues = [1, 1, 3, 3]) == 4\n assert candidate(rewardValues = [2000, 1]) == 2001\n assert candidate(rewardValues = [1, 6, 4, 3, 2]) == 11\n assert candidate(rewardValues = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 37\n assert candidate(rewardValues = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 38\n assert candidate(rewardValues = [1]) == 1\n assert candidate(rewardValues = [2000, 1999, 1998, 1997, 1996, 1995, 1994, 1993, 1992, 1991]) == 3999\n assert candidate(rewardValues = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 19\n assert candidate(rewardValues = [10, 20, 30, 40, 50]) == 90\n assert candidate(rewardValues = [1, 2000]) == 2001\n assert candidate(rewardValues = [1500, 1000, 500, 100, 50, 25, 10, 5, 1]) == 2691\n assert candidate(rewardValues = [5, 5, 5, 5, 5]) == 5\n assert candidate(rewardValues = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 11\n assert candidate(rewardValues = [1000, 1000, 1000]) == 1000\n assert candidate(rewardValues = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 19\n assert candidate(rewardValues = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(rewardValues = [5, 4, 3, 2, 1]) == 9\n assert candidate(rewardValues = [2000, 1999, 1998, 1997, 1996]) == 3999\n assert candidate(rewardValues = [1000, 1000, 1000, 1000, 1000]) == 1000\n assert candidate(rewardValues = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 1900\n assert candidate(rewardValues = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 2047\n assert candidate(rewardValues = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(rewardValues = [2000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 2059\n assert candidate(rewardValues = [2000, 1999, 1998, 1997, 1996, 1995, 1994, 1993, 1992, 1991, 1990]) == 3999\n assert candidate(rewardValues = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 99\n assert candidate(rewardValues = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 39\n assert candidate(rewardValues = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(rewardValues = [1800, 1700, 1600, 1500, 1400, 1300, 1200, 1100, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 50, 25]) == 3575\n assert candidate(rewardValues = [1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500]) == 1500\n assert candidate(rewardValues = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 290\n assert candidate(rewardValues = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 57\n assert candidate(rewardValues = [500, 200, 800, 100, 600, 300, 700, 400, 900, 500, 1100, 600, 1200, 700, 1300, 800, 1400, 900, 1500, 1000]) == 2900\n assert candidate(rewardValues = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == 1000\n assert candidate(rewardValues = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 77\n assert candidate(rewardValues = [10, 20, 10, 30, 20, 40, 30, 50, 40, 60, 50, 70, 60, 80, 70, 90, 80, 100]) == 190\n assert candidate(rewardValues = [1, 2, 4, 8, 16, 32, 64, 128]) == 255\n assert candidate(rewardValues = [3, 6, 2, 8, 5, 10, 4, 12, 7, 14, 1, 16, 9, 18, 11, 20, 13, 22, 15, 24]) == 47\n assert candidate(rewardValues = [2000, 1, 2000, 2, 2000, 3, 2000, 4, 2000, 5]) == 2009\n assert candidate(rewardValues = [100, 50, 25, 125, 75, 150]) == 275\n assert candidate(rewardValues = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == 141\n assert candidate(rewardValues = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 19\n assert candidate(rewardValues = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99, 101, 103, 105, 107, 109, 111, 113, 115, 117, 119, 121, 123, 125, 127, 129, 131, 133, 135, 137, 139, 141, 143, 145, 147, 149, 151, 153, 155, 157, 159, 161, 163, 165, 167, 169, 171, 173, 175, 177, 179, 181, 183, 185, 187, 189, 191, 193, 195, 197, 199, 200]) == 399\n assert candidate(rewardValues = [1, 3, 2, 6, 5, 4, 9, 8, 7, 12, 11, 10]) == 23\n assert candidate(rewardValues = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 77\n assert candidate(rewardValues = [500, 1000, 1500, 2000, 1000, 500, 1500, 1000]) == 3500\n assert candidate(rewardValues = [200, 150, 100, 50, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 381\n assert candidate(rewardValues = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 19\n assert candidate(rewardValues = [100, 200, 300, 250, 150, 400, 350, 500, 450, 550]) == 1050\n assert candidate(rewardValues = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 57\n assert candidate(rewardValues = [1500, 500, 1500, 500, 1500, 500, 1500, 500, 1500, 500, 1500, 500, 1500, 500, 1500, 500, 1500, 500, 1500, 500]) == 2000\n assert candidate(rewardValues = [1500, 1000, 500, 250, 125, 62, 31, 15, 7, 3, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 2999\n assert candidate(rewardValues = [2000, 1000, 500, 250, 125, 62, 31, 15, 7, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 3994\n assert candidate(rewardValues = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20]) == 30\n assert candidate(rewardValues = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 58\n assert candidate(rewardValues = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]) == 2097151\n assert candidate(rewardValues = [100, 200, 300, 400, 500, 100, 200, 300, 400, 500]) == 900\n assert candidate(rewardValues = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 19\n assert candidate(rewardValues = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1994\n assert candidate(rewardValues = [2000, 1, 2000, 2, 2000, 3, 2000, 4, 2000, 5, 2000, 6, 2000, 7, 2000, 8, 2000, 9, 2000, 10]) == 2019\n assert candidate(rewardValues = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50]) == 90\n assert candidate(rewardValues = [1000, 1500, 500, 2000, 1000]) == 3500\n assert candidate(rewardValues = [71, 67, 61, 59, 53, 47, 43, 41, 37, 31, 29, 23, 19, 17, 13, 11, 7, 5, 3, 2]) == 141\n assert candidate(rewardValues = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(rewardValues = [1999, 1998, 1997, 1996, 1995, 1994, 1993, 1992, 1991, 1990, 1989, 1988, 1987, 1986, 1985]) == 3997\n assert candidate(rewardValues = [1500, 500, 250, 750, 1000, 1250, 1750, 2000, 2000, 2000]) == 3750\n assert candidate(rewardValues = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39, 40, 40]) == 79\n assert candidate(rewardValues = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 2047\n assert candidate(rewardValues = [1, 10, 100, 1000, 100, 10, 1, 1000, 100, 10]) == 1111\n assert candidate(rewardValues = [2000, 1999, 1998, 1997, 1996, 1995, 1994, 1993, 1992, 1991, 1990, 1989, 1988, 1987, 1986, 1985, 1984, 1983, 1982, 1981]) == 3999\n assert candidate(rewardValues = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 25, 26, 27, 28, 29, 30]) == 59\n assert candidate(rewardValues = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6]) == 17\n assert candidate(rewardValues = [1999, 1998, 1997, 1996, 1995, 1994, 1993, 1992, 1991, 1990, 1989, 1988, 1987, 1986, 1985, 1984, 1983, 1982, 1981, 1980]) == 3997\n assert candidate(rewardValues = [100, 50, 200, 150, 250, 300, 100]) == 550\n assert candidate(rewardValues = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210]) == 419\n assert candidate(rewardValues = [50, 45, 40, 35, 30, 25, 20, 15, 10, 5, 1, 2, 3, 4, 6, 7, 8, 9, 11, 12]) == 99\n assert candidate(rewardValues = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 49\n assert candidate(rewardValues = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 11\n assert candidate(rewardValues = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 2047\n assert candidate(rewardValues = [2000, 1999, 1998, 1997, 1996, 1995, 1994, 1993, 1992, 1991]) == 3999\n assert candidate(rewardValues = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 59\n assert candidate(rewardValues = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 195\n assert candidate(rewardValues = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50]) == 98\n assert candidate(rewardValues = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 2047\n assert candidate(rewardValues = [1999, 1998, 1997, 1996, 1995, 1994, 1993, 1992, 1991, 1990, 1989, 1988, 1987, 1986, 1985, 1984, 1983, 1982, 1981, 1980]) == 3997\n assert candidate(rewardValues = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 390\n assert candidate(rewardValues = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == 93\n assert candidate(rewardValues = [500, 1000, 1500, 2000, 1000, 500, 1500, 2000, 1000, 500]) == 3500\n assert candidate(rewardValues = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2000, 1999, 1998, 1997, 1996, 1995, 1994, 1993, 1992]) == 3999\n assert candidate(rewardValues = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 19\n assert candidate(rewardValues = [2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000]) == 2000\n assert candidate(rewardValues = [2, 1, 5, 6, 3, 4, 7]) == 13\n assert candidate(rewardValues = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 49\n assert candidate(rewardValues = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]) == 2097150\n assert candidate(rewardValues = [200, 100, 300, 150, 400, 250, 500, 350, 600, 450, 700, 550, 800, 650, 900, 750, 1000, 850, 1100, 950]) == 2150\n assert candidate(rewardValues = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 2047\n assert candidate(rewardValues = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 2\n assert candidate(rewardValues = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 19\n assert candidate(rewardValues = [2000, 1500, 1000, 500, 250, 125, 62, 31, 15, 7, 3, 1]) == 3994\n assert candidate(rewardValues = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 79\n assert candidate(rewardValues = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 21, 20]) == 41\n assert candidate(rewardValues = [1, 10, 100, 1000, 10, 100, 1000, 10, 100, 1000]) == 1111\n assert candidate(rewardValues = [2000, 1, 1999, 2, 1998, 3, 1997, 4, 1996, 5, 1995, 6, 1994, 7, 1993, 8, 1992, 9, 1991, 10]) == 3999\n assert candidate(rewardValues = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == 193\n assert candidate(rewardValues = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == 1900\n"}, "metadata": {"canonical_parameter_names": ["rewardValues"], "leetcode_dataset_entry_point": "Solution().maxTotalReward", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxTotalReward(vector& rewardValues) {", "container": "Solution", "callable": "maxTotalReward", "parameters": [{"name": "rewardValues", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3181, "task_id": "maximum-total-reward-using-operations-ii", "difficulty": "Hard", "problem_description": "You are given an integer array rewardValues of length n, representing the values of rewards.\nInitially, your total reward x is 0, and all indices are unmarked. You are allowed to perform the following operation any number of times:\n\nChoose an unmarked index i from the range [0, n - 1].\nIf rewardValues[i] is greater than your current total reward x, then add rewardValues[i] to x (i.e., x = x + rewardValues[i]), and mark the index i.\n\nReturn an integer denoting the maximum total reward you can collect by performing the operations optimally.\n \nExample 1:\n\nInput: rewardValues = [1,1,3,3]\nOutput: 4\nExplanation:\nDuring the operations, we can choose to mark the indices 0 and 2 in order, and the total reward will be 4, which is the maximum.\n\nExample 2:\n\nInput: rewardValues = [1,6,4,3,2]\nOutput: 11\nExplanation:\nMark the indices 0, 2, and 1 in order. The total reward will then be 11, which is the maximum.\n\n \nConstraints:\n\n1 <= rewardValues.length <= 5 * 104\n1 <= rewardValues[i] <= 5 * 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(rewardValues = [1, 2, 3, 4, 5]) == 9\n assert candidate(rewardValues = [1, 1, 3, 3]) == 4\n assert candidate(rewardValues = [50000, 40000, 30000, 20000, 10000]) == 90000\n assert candidate(rewardValues = [1, 2, 2, 1, 1, 2, 2, 1, 1, 2]) == 3\n assert candidate(rewardValues = [1, 6, 4, 3, 2]) == 11\n assert candidate(rewardValues = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 37\n assert candidate(rewardValues = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(rewardValues = [10000, 10000, 10000, 10000, 10000]) == 10000\n assert candidate(rewardValues = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 17\n assert candidate(rewardValues = [10, 9, 8, 7, 6]) == 19\n assert candidate(rewardValues = [1]) == 1\n assert candidate(rewardValues = [10, 20, 30, 40, 50]) == 90\n assert candidate(rewardValues = [50000, 25000, 12500, 6250, 3125]) == 96875\n assert candidate(rewardValues = [5, 5, 5, 5, 5]) == 5\n assert candidate(rewardValues = [50000, 40000, 30000, 20000, 10000]) == 90000\n assert candidate(rewardValues = [1, 5, 1, 5, 1]) == 6\n assert candidate(rewardValues = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 2\n assert candidate(rewardValues = [50000, 50000, 50000, 50000, 50000]) == 50000\n assert candidate(rewardValues = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 1023\n assert candidate(rewardValues = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 19\n assert candidate(rewardValues = [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000]) == 19000\n assert candidate(rewardValues = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 1023\n assert candidate(rewardValues = [1, 1, 1, 1, 1]) == 1\n assert candidate(rewardValues = [5, 4, 3, 2, 1]) == 9\n assert candidate(rewardValues = [42, 35, 18, 27, 5, 14, 8, 23, 9, 22]) == 83\n assert candidate(rewardValues = [3, 6, 2, 8, 5, 10, 4, 12, 7, 14, 1, 9, 11, 13, 15]) == 29\n assert candidate(rewardValues = [50000, 40000, 30000, 20000, 10000, 9000, 8000, 7000, 6000, 5000]) == 99000\n assert candidate(rewardValues = [50000, 10000, 20000, 30000, 40000, 5000, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000]) == 99000\n assert candidate(rewardValues = [50000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 50019\n assert candidate(rewardValues = [99999, 49999, 24999, 12499, 6249, 3124, 1562, 781, 390, 195, 97, 48, 24, 12, 6, 3, 1]) == 199988\n assert candidate(rewardValues = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 29\n assert candidate(rewardValues = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 1111111111\n assert candidate(rewardValues = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7, 9, 5, 0]) == 17\n assert candidate(rewardValues = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == 3900\n assert candidate(rewardValues = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 99\n assert candidate(rewardValues = [4, 3, 2, 1, 8, 7, 6, 5, 12, 11, 10, 9, 16, 15, 14, 13]) == 31\n assert candidate(rewardValues = [5, 3, 8, 6, 2, 7, 4, 1, 9, 10]) == 19\n assert candidate(rewardValues = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 190\n assert candidate(rewardValues = [50000, 40000, 30000, 20000, 10000, 5000, 1000, 500, 100, 50]) == 96650\n assert candidate(rewardValues = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == 10000\n assert candidate(rewardValues = [1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 39\n assert candidate(rewardValues = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(rewardValues = [2, 3, 7, 8, 10, 14, 15, 18, 20, 22, 25, 28, 30]) == 59\n assert candidate(rewardValues = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(rewardValues = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536]) == 131071\n assert candidate(rewardValues = [25000, 24000, 23000, 22000, 21000, 20000, 19000, 18000, 17000, 16000, 15000, 14000, 13000, 12000, 11000, 10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000]) == 49000\n assert candidate(rewardValues = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 39\n assert candidate(rewardValues = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 2047\n assert candidate(rewardValues = [1, 2, 4, 8, 16, 32, 64, 128]) == 255\n assert candidate(rewardValues = [50000, 40000, 30000, 20000, 10000, 5000, 2500, 1250, 625, 312, 156, 78, 39, 19, 9, 4, 2, 1]) == 99995\n assert candidate(rewardValues = [1, 10, 100, 1000, 10000, 100000, 50000, 25000, 12500, 6250, 3125]) == 198611\n assert candidate(rewardValues = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120]) == 239\n assert candidate(rewardValues = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 290\n assert candidate(rewardValues = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 2\n assert candidate(rewardValues = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 49\n assert candidate(rewardValues = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == 10000\n assert candidate(rewardValues = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == 1048575\n assert candidate(rewardValues = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 17\n assert candidate(rewardValues = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991]) == 19999\n assert candidate(rewardValues = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6]) == 17\n assert candidate(rewardValues = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144]) == 287\n assert candidate(rewardValues = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1]) == 6\n assert candidate(rewardValues = [1, 3, 2, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 21, 20]) == 41\n assert candidate(rewardValues = [10, 1, 10, 1, 10, 1, 10, 1, 10, 1]) == 11\n assert candidate(rewardValues = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == 65535\n assert candidate(rewardValues = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 77\n assert candidate(rewardValues = [3125, 6250, 12500, 25000, 50000, 100000, 10000, 1000, 100, 10, 1]) == 198611\n assert candidate(rewardValues = [1, 10000, 2, 9999, 3, 9998, 4, 9997, 5, 9996, 6, 9995, 7, 9994, 8, 9993]) == 19999\n assert candidate(rewardValues = [50000, 45000, 40000, 35000, 30000, 25000, 20000, 15000, 10000, 5000]) == 95000\n assert candidate(rewardValues = [10000, 20000, 15000, 5000, 2500, 7500, 30000, 1000, 500, 1500]) == 59500\n assert candidate(rewardValues = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 2\n assert candidate(rewardValues = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991]) == 19999\n assert candidate(rewardValues = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996, 6, 99995, 7, 99994, 8, 99993]) == 199999\n assert candidate(rewardValues = [20000, 18000, 16000, 14000, 12000, 10000, 8000, 6000, 4000, 2000, 1000, 500, 250, 125, 62, 31]) == 39968\n assert candidate(rewardValues = [50000, 40000, 30000, 20000, 10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 99990\n assert candidate(rewardValues = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000]) == 50000\n assert candidate(rewardValues = [25000, 20000, 15000, 10000, 5000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 45019\n assert candidate(rewardValues = [100, 200, 300, 400, 500, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 990\n assert candidate(rewardValues = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == 65534\n assert candidate(rewardValues = [10, 15, 20, 25, 30, 35, 40, 45, 50]) == 95\n assert candidate(rewardValues = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 11\n assert candidate(rewardValues = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 17\n assert candidate(rewardValues = [50, 40, 30, 20, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 99\n assert candidate(rewardValues = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == 141\n assert candidate(rewardValues = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == 10000\n assert candidate(rewardValues = [10000, 20000, 30000, 40000, 50000, 50000, 40000, 30000, 20000, 10000]) == 90000\n assert candidate(rewardValues = [10000, 20000, 30000, 40000, 50000, 1, 2, 3, 4, 5]) == 90009\n"}, "metadata": {"canonical_parameter_names": ["rewardValues"], "leetcode_dataset_entry_point": "Solution().maxTotalReward", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxTotalReward(vector& rewardValues) {", "container": "Solution", "callable": "maxTotalReward", "parameters": [{"name": "rewardValues", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3184, "task_id": "count-pairs-that-form-a-complete-day-i", "difficulty": "Easy", "problem_description": "Given an integer array hours representing times in hours, return an integer denoting the number of pairs i, j where i < j and hours[i] + hours[j] forms a complete day.\nA complete day is defined as a time duration that is an exact multiple of 24 hours.\nFor example, 1 day is 24 hours, 2 days is 48 hours, 3 days is 72 hours, and so on.\n \nExample 1:\n\nInput: hours = [12,12,30,24,24]\nOutput: 2\nExplanation:\nThe pairs of indices that form a complete day are (0, 1) and (3, 4).\n\nExample 2:\n\nInput: hours = [72,48,24,3]\nOutput: 3\nExplanation:\nThe pairs of indices that form a complete day are (0, 1), (0, 2), and (1, 2).\n\n \nConstraints:\n\n1 <= hours.length <= 100\n1 <= hours[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(hours = [23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 11\n assert candidate(hours = [24, 48, 72, 96, 120]) == 10\n assert candidate(hours = [1000000000, 1000000000, 1000000000, 1000000000]) == 0\n assert candidate(hours = [10, 14, 10, 14, 48]) == 4\n assert candidate(hours = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]) == 11\n assert candidate(hours = [24, 48, 72, 96]) == 6\n assert candidate(hours = [1, 2, 3, 4, 5]) == 0\n assert candidate(hours = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(hours = [12, 12, 30, 24, 24]) == 2\n assert candidate(hours = [1, 2, 3, 23]) == 1\n assert candidate(hours = [24, 24, 24, 24]) == 6\n assert candidate(hours = [24, 24, 24, 24, 24]) == 10\n assert candidate(hours = [72, 48, 24, 3]) == 3\n assert candidate(hours = [23, 1, 23, 1]) == 4\n assert candidate(hours = [23, 1, 22, 2, 21, 3, 20, 4, 19, 5]) == 5\n assert candidate(hours = [23, 1, 23, 1, 23]) == 6\n assert candidate(hours = [12, 36, 60, 84]) == 6\n assert candidate(hours = [12, 24, 36, 48, 60, 72, 84, 96]) == 12\n assert candidate(hours = [5, 5, 5, 5, 5]) == 0\n assert candidate(hours = [10, 14, 10, 14]) == 4\n assert candidate(hours = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23]) == 6\n assert candidate(hours = [24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24]) == 435\n assert candidate(hours = [24, 48, 72, 96, 120, 144, 168]) == 21\n assert candidate(hours = [23, 1, 47, 25, 71, 49, 95, 73, 119, 97, 143, 121]) == 36\n assert candidate(hours = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 12\n assert candidate(hours = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144, 152, 160, 168, 176, 184, 192, 200, 208, 216, 224, 232, 240]) == 145\n assert candidate(hours = [20, 44, 68, 92, 116, 140, 164, 188, 212, 236]) == 0\n assert candidate(hours = [23, 23, 23, 23, 23, 1, 1, 1, 1, 1, 47, 47, 47, 47, 47, 71, 71, 71, 71, 71]) == 75\n assert candidate(hours = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23]) == 200\n assert candidate(hours = [5, 19, 10, 34, 15, 29, 20, 24, 25, 19]) == 4\n assert candidate(hours = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 12\n assert candidate(hours = [23, 1, 23, 1, 23, 1, 23, 1, 23, 1]) == 25\n assert candidate(hours = [23, 47, 71, 95, 119, 143, 167, 191, 215, 239, 263, 287]) == 0\n assert candidate(hours = [12, 24, 36, 48, 60, 72, 84, 96]) == 12\n assert candidate(hours = [10, 34, 58, 82, 106, 130, 154, 178, 202, 226]) == 0\n assert candidate(hours = [24, 48, 72, 96, 120, 144]) == 15\n assert candidate(hours = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]) == 20\n assert candidate(hours = [120, 144, 168, 192, 216, 240, 264, 288, 312, 336, 360, 384, 408, 432, 456, 480, 504, 528, 552, 576]) == 190\n assert candidate(hours = [2, 22, 46, 68, 94, 120, 146, 172, 198, 224, 250, 276, 302, 328, 354, 380, 406, 432]) == 14\n assert candidate(hours = [23, 47, 71, 95, 119, 143, 167, 191, 215, 239, 263, 287, 311, 335, 359, 383, 407, 431, 455, 479]) == 0\n assert candidate(hours = [5, 19, 33, 47, 61, 75, 89, 103, 117, 131, 145, 159, 173, 187, 201, 215, 229, 243, 257, 271]) == 16\n assert candidate(hours = [24, 48, 72, 96, 120, 144, 168, 192, 216]) == 36\n assert candidate(hours = [5, 19, 33, 47, 61, 75, 89, 103, 117, 131, 145, 159, 173, 187, 201, 215, 229]) == 12\n assert candidate(hours = [24, 48, 72, 96, 120, 144, 168, 192, 216, 240, 264, 288, 312, 336, 360, 384, 408, 432, 456, 480]) == 190\n assert candidate(hours = [12, 36, 48, 60, 84, 108, 132, 156, 180]) == 28\n assert candidate(hours = [11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == 16\n assert candidate(hours = [24, 48, 72, 96, 120, 144, 168, 192, 216, 240]) == 45\n assert candidate(hours = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 0\n assert candidate(hours = [2, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145]) == 17\n assert candidate(hours = [23, 47, 71, 95, 119, 143, 167, 191, 215, 239]) == 0\n assert candidate(hours = [24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24]) == 190\n assert candidate(hours = [1, 5, 7, 11, 13, 17, 19, 23, 25, 29, 31, 35, 37, 41, 43, 47, 53, 59, 61, 65, 67, 71, 73, 77, 79, 83, 85, 89, 91, 95, 97, 101, 103, 107, 109, 113, 115, 119, 121, 125, 127, 131, 133, 137, 139, 143, 145, 149, 151, 155, 157, 161, 163, 167, 169, 173, 175, 179, 181, 185, 187, 191, 193, 197, 199]) == 264\n assert candidate(hours = [10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62, 66, 70, 74, 78, 82, 86]) == 34\n assert candidate(hours = [12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12]) == 435\n assert candidate(hours = [48, 96, 144, 192, 240, 288, 336, 384, 432, 480, 528, 576, 624, 672, 720, 768, 816, 864, 912, 960]) == 190\n assert candidate(hours = [11, 13, 35, 47, 59, 71, 83, 95, 107, 119]) == 5\n assert candidate(hours = [12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12]) == 66\n assert candidate(hours = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(hours = [144, 168, 192, 216, 240, 264, 288, 312, 336, 360]) == 45\n assert candidate(hours = [23, 1, 47, 24, 25, 48, 49, 23, 1, 24, 24, 24]) == 22\n assert candidate(hours = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]) == 11\n assert candidate(hours = [13, 11, 25, 19, 49, 23, 35, 17, 55, 15]) == 5\n assert candidate(hours = [5, 19, 29, 43, 53, 67, 77, 91, 101, 115]) == 25\n assert candidate(hours = [15, 9, 27, 3, 39, 51, 63, 75, 87, 99, 111, 123, 135, 147, 159, 171, 183, 195, 207, 219]) == 9\n assert candidate(hours = [23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 1]) == 29\n assert candidate(hours = [15, 9, 27, 39, 51, 63, 75, 87, 99, 111, 123, 135]) == 6\n assert candidate(hours = [123456789, 987654321, 123456789, 987654321, 123456789, 987654321]) == 0\n assert candidate(hours = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072]) == 56\n assert candidate(hours = [5, 19, 9, 15, 9, 15, 9, 15, 29, 11, 13, 21, 23, 47, 71, 95, 119, 143, 167, 191]) == 12\n assert candidate(hours = [3, 21, 39, 57, 75, 93, 111, 129, 147, 165, 183, 201, 219, 237, 255, 273, 291, 309, 327, 345]) == 50\n assert candidate(hours = [12, 12, 12, 12, 12, 12, 12, 12, 12, 12]) == 45\n assert candidate(hours = [24, 24, 24, 24, 24, 24, 24, 24, 24, 24]) == 45\n assert candidate(hours = [3, 21, 6, 18, 9, 15, 12, 12, 12, 12]) == 9\n assert candidate(hours = [3, 9, 21, 39, 57, 75, 93, 111, 129, 147, 165, 183, 201, 219, 237, 255, 273, 291]) == 40\n assert candidate(hours = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144, 152, 160]) == 64\n assert candidate(hours = [100, 144, 48, 24, 72, 96, 120]) == 15\n assert candidate(hours = [60, 108, 156, 204, 252, 300, 348, 396, 444, 492, 540, 588, 636, 684, 732, 780]) == 120\n assert candidate(hours = [6, 18, 30, 42, 54, 66, 78, 90, 102, 114, 126, 138]) == 36\n assert candidate(hours = [48, 24, 72, 96, 120, 24, 48]) == 21\n assert candidate(hours = [59, 119, 179, 239, 299, 359, 419, 479, 539, 599, 659, 719, 779, 839, 899, 959]) == 0\n assert candidate(hours = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156, 168, 180, 192, 204, 216, 228, 240, 252, 264, 276, 288, 300, 312, 324, 336, 348, 360]) == 210\n assert candidate(hours = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120]) == 145\n assert candidate(hours = [240, 480, 720, 960, 1200, 1440, 1680, 1920, 2160, 2400, 2640, 2880, 3120, 3360, 3600, 3840, 4080, 4320, 4560, 4800, 5040, 5280, 5520, 5760, 6000, 6240, 6480, 6720, 6960, 7200]) == 435\n"}, "metadata": {"canonical_parameter_names": ["hours"], "leetcode_dataset_entry_point": "Solution().countCompleteDayPairs", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int countCompleteDayPairs(vector& hours) {", "container": "Solution", "callable": "countCompleteDayPairs", "parameters": [{"name": "hours", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3185, "task_id": "count-pairs-that-form-a-complete-day-ii", "difficulty": "Medium", "problem_description": "Given an integer array hours representing times in hours, return an integer denoting the number of pairs i, j where i < j and hours[i] + hours[j] forms a complete day.\nA complete day is defined as a time duration that is an exact multiple of 24 hours.\nFor example, 1 day is 24 hours, 2 days is 48 hours, 3 days is 72 hours, and so on.\n \nExample 1:\n\nInput: hours = [12,12,30,24,24]\nOutput: 2\nExplanation: The pairs of indices that form a complete day are (0, 1) and (3, 4).\n\nExample 2:\n\nInput: hours = [72,48,24,3]\nOutput: 3\nExplanation: The pairs of indices that form a complete day are (0, 1), (0, 2), and (1, 2).\n\n \nConstraints:\n\n1 <= hours.length <= 5 * 105\n1 <= hours[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(hours = [5, 19, 15, 1, 23, 7, 17, 11, 3, 21, 9, 13, 20, 18, 4, 16, 8, 12, 6, 22, 14, 2, 10, 10, 10]) == 13\n assert candidate(hours = [24, 48, 72, 96, 120, 144, 168, 192, 216, 240, 264, 288, 312, 336, 360, 384, 408, 432, 456, 480, 504, 528, 552, 576, 600]) == 300\n assert candidate(hours = [24, 48, 72, 96, 120]) == 10\n assert candidate(hours = [1, 2, 3, 23, 47, 71]) == 3\n assert candidate(hours = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 0\n assert candidate(hours = [12, 12, 30, 24, 24]) == 2\n assert candidate(hours = [1, 23, 2, 22, 3, 21, 4, 20, 5, 19]) == 5\n assert candidate(hours = [24]) == 0\n assert candidate(hours = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 4\n assert candidate(hours = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(hours = [72, 48, 24, 3]) == 3\n assert candidate(hours = [5, 19, 29, 39, 49, 59, 69, 79, 89, 99, 109, 119, 129, 139, 149, 159, 169, 179, 189, 199]) == 16\n assert candidate(hours = [10, 14, 16, 8, 12]) == 2\n assert candidate(hours = [1, 2, 3, 4, 5, 23, 22, 21, 20, 19]) == 5\n assert candidate(hours = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]) == 11\n assert candidate(hours = [24, 48, 72, 96]) == 6\n assert candidate(hours = [48, 24, 96, 72, 144, 120, 192, 168, 240, 216, 336, 312, 384, 360, 456, 432, 528, 504, 600, 576, 768, 744, 840, 816, 912, 888]) == 325\n assert candidate(hours = [20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300, 320, 340, 360, 380, 400, 420, 440, 460, 480, 500, 520, 540, 560, 580, 600]) == 70\n assert candidate(hours = [1, 5, 23, 29, 35, 41, 47, 53, 59, 65, 71, 77, 83, 89, 95, 101, 107, 113, 119, 125, 131, 137, 143, 149, 155, 161, 167, 173, 179, 185]) == 7\n assert candidate(hours = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500, 510, 520, 530, 540, 550, 560, 570, 580, 590, 600, 610, 620, 630, 640, 650, 660, 670, 680, 690, 700, 710, 720, 730, 740, 750, 760, 770, 780, 790, 800, 810, 820, 830, 840, 850, 860, 870, 880, 890, 900, 910, 920, 930, 940, 950, 960, 970, 980, 990, 1000, 1010, 1020, 1030, 1040, 1050, 1060, 1070, 1080, 1090, 1100, 1110, 1120, 1130, 1140, 1150, 1160, 1170, 1180, 1190, 1200]) == 590\n assert candidate(hours = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144, 152, 160, 168, 176, 184, 192, 200, 208, 216, 224, 232, 240]) == 145\n assert candidate(hours = [240, 480, 720, 960, 1200, 1440, 1680, 1920, 2160, 2400, 2640, 2880, 3120, 3360, 3600, 3840, 4080, 4320, 4560, 4800, 5040, 5280, 5520, 5760, 6000, 6240, 6480, 6720, 6960, 7200, 7440, 7680, 7920, 8160, 8400, 8640, 8880, 9120, 9360, 9600, 9840, 10080, 10320, 10560, 10800, 11040, 11280, 11520, 11760, 12000, 12240, 12480, 12720, 12960, 13200, 13440, 13680, 13920, 14160, 14400, 14640, 14880, 15120, 15360, 15600, 15840, 16080, 16320, 16560, 16800, 17040, 17280, 17520, 17760, 18000, 18240, 18480, 18720, 18960, 19200, 19440, 19680, 19920, 20160]) == 3486\n assert candidate(hours = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99, 101, 103, 105, 107, 109, 111, 113, 115, 117, 119, 121, 123, 125, 127]) == 117\n assert candidate(hours = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156, 168, 180, 192, 204, 216, 228, 240, 252, 264, 276, 288, 300, 312, 324, 336, 348, 360, 372, 384, 396, 408, 420, 432, 444, 456, 468, 480, 492, 504, 516, 528, 540, 552, 564, 576, 588, 600, 612, 624, 636, 648, 660, 672, 684, 696, 708, 720, 732, 744, 756, 768, 780, 792, 804, 816, 828, 840, 852, 864, 876, 888, 900, 912, 924, 936, 948, 960, 972, 984, 996, 1008, 1020, 1032, 1044, 1056, 1068, 1080, 1092, 1104, 1116, 1128, 1140, 1152, 1164, 1176, 1188, 1200, 1212, 1224, 1236, 1248, 1260, 1272, 1284, 1296, 1308, 1320, 1332, 1344, 1356, 1368, 1380, 1392, 1404, 1416, 1428, 1440]) == 3540\n assert candidate(hours = [1000000000, 2000000000, 3000000000, 4000000000, 5000000000, 6000000000, 7000000000, 8000000000, 9000000000, 10000000000, 11000000000, 12000000000]) == 22\n assert candidate(hours = [1, 2, 3, 23, 47, 71, 95, 119, 143, 167, 191, 215, 239, 263, 287, 311, 335, 359, 383, 407, 431, 455, 479, 503, 527, 551, 575, 599, 623, 647, 671, 695, 719, 743, 767, 791, 815, 839, 863, 887, 911, 935, 959, 983, 1007, 1031, 1055, 1079, 1103, 1127, 1151, 1175, 1199, 1223, 1247, 1271, 1295, 1319, 1343, 1367, 1391, 1415, 1439, 1463, 1487, 1511, 1535, 1559, 1583, 1607, 1631, 1655, 1679, 1703, 1727, 1751, 1775, 1799, 1823, 1847, 1871, 1895, 1919, 1943, 1967, 1991, 2015, 2039, 2063, 2087, 2111, 2135, 2159, 2183, 2207, 2231, 2255, 2279, 2303, 2327, 2351, 2375, 2399]) == 100\n assert candidate(hours = [23, 49, 73, 97, 121, 145, 169, 193, 217, 241, 265, 289, 313, 337, 361, 385, 409, 433, 457, 481, 505, 529, 553, 577, 601]) == 24\n assert candidate(hours = [24, 48, 72, 96, 120, 144, 168, 192, 216, 240, 264, 288, 312, 336, 360, 384, 408, 432, 456, 480, 504, 528, 552, 576, 600, 624, 648, 672, 696, 720, 744, 768, 792, 816, 840, 864, 888, 912, 936, 960, 984, 1008, 1032, 1056, 1080]) == 990\n assert candidate(hours = [123456789, 123456789, 246913578, 246913578, 370370370, 370370370, 493826958, 493826958, 617283546, 617283546, 740740134, 740740134]) == 24\n assert candidate(hours = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150, 155, 160, 165, 170, 175, 180, 185, 190, 195, 200, 205, 210, 215, 220, 225, 230, 235, 240, 245, 250, 255, 260, 265, 270, 275, 280, 285, 290, 295, 300]) == 70\n assert candidate(hours = [22, 46, 70, 94, 118, 142, 166, 190, 214, 238, 262, 286, 310, 334, 358, 382, 406, 430, 454, 478, 502, 526, 550, 574, 598]) == 0\n assert candidate(hours = [1, 23, 47, 71, 95, 119, 143, 167, 191, 215, 239, 263, 287, 311, 335, 359, 383, 407, 431, 455, 479, 503, 527, 551, 575, 599, 623, 647, 671, 695, 719, 743, 767, 791, 815, 839, 863, 887, 911, 935, 959, 983, 1007, 1031, 1055, 1079, 1103, 1127, 1151, 1175, 1199, 1223, 1247, 1271, 1295, 1319, 1343, 1367, 1391, 1415, 1439]) == 60\n assert candidate(hours = [12, 12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156, 168, 180, 192, 204, 216, 228, 240, 252, 264, 276, 288, 300, 312, 324, 336, 348, 360]) == 225\n assert candidate(hours = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59]) == 36\n assert candidate(hours = [14, 28, 42, 56, 70, 84, 98, 112, 126, 140, 154, 168, 182, 196, 210, 224, 238, 252, 266, 280, 294, 308, 322, 336, 350, 364, 378, 392, 406, 420]) == 34\n assert candidate(hours = [1000000000, 1000000024, 1000000048, 1000000072, 1000000096, 1000000120, 1000000144, 1000000168, 1000000192, 1000000216]) == 0\n assert candidate(hours = [5, 29, 19, 43, 67, 91, 115, 139, 163, 187, 211, 235, 259, 283, 307, 331, 355, 379, 403, 427, 451, 475, 499, 523, 547, 571, 595, 619, 643, 667, 691, 715, 739, 763, 787, 811, 835, 859, 883, 907, 931, 955, 979]) == 82\n assert candidate(hours = [24, 48, 24, 72, 96, 120, 144, 168, 192, 216, 240, 264, 288, 312, 336, 360, 384, 408, 432, 456, 480, 504, 528, 552, 576, 600, 12, 60, 84, 108, 132, 156, 180, 204, 228, 252, 276, 300, 324, 348, 372, 396, 420, 444, 468, 492, 516, 540, 564, 588]) == 601\n assert candidate(hours = [3, 21, 39, 57, 75, 93, 111, 129, 147, 165, 183, 201, 219, 237, 255, 273, 291, 309, 327, 345, 363, 381, 399, 417, 435, 453, 471, 489, 507, 525, 543, 561, 579, 597, 615, 633, 651, 669, 687, 705, 723, 741, 759, 777, 795, 813, 831, 849, 867, 885, 903, 921, 939, 957, 975, 993]) == 392\n assert candidate(hours = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500, 510, 520, 530, 540, 550, 560, 570, 580, 590, 600, 610, 620, 630, 640, 650, 660, 670, 680, 690, 700, 710, 720, 730, 740, 750, 760, 770, 780, 790, 800, 810, 820, 830, 840, 850, 860, 870, 880, 890, 900, 910, 920, 930, 940, 950, 960, 970, 980, 990, 1000]) == 408\n assert candidate(hours = [24, 48, 24, 72, 96, 120, 144, 168, 192, 216, 240, 264, 288, 312, 336, 360, 384, 408, 432, 456, 480, 504, 528, 552, 576, 600, 12, 60, 84, 108, 132, 156, 180, 204, 228, 252, 276, 300, 324, 348, 372, 396, 420, 444, 468, 492, 516, 540, 564, 588, 123, 246, 369, 492, 615, 738, 861, 984, 1107, 1230, 1353, 1476, 1599, 1722, 1845, 1968, 2091, 2214, 2337, 2460]) == 747\n assert candidate(hours = [12, 36, 60, 84, 108, 132, 156, 180, 204, 228, 252, 276, 300, 324, 348, 372, 396, 420, 444, 468, 492, 516, 540, 564, 588, 612, 636, 660, 684, 708, 732, 756, 780, 804, 828, 852, 876, 900, 924, 948, 972, 996]) == 861\n assert candidate(hours = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156, 168, 180, 192, 204, 216, 228, 240, 252, 264, 276, 288, 300]) == 144\n assert candidate(hours = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 220, 231, 242, 253, 264, 275, 286, 297, 308, 319, 330, 341, 352, 363, 374, 385, 396, 407, 418, 429, 440, 451, 462, 473, 484, 495, 506, 517, 528, 539, 550, 561, 572, 583, 594, 605, 616, 627, 638, 649, 660, 671, 682, 693, 704, 715, 726, 737, 748, 759, 770, 781, 792, 803, 814, 825, 836, 847, 858, 869, 880, 891, 902, 913, 924, 935, 946, 957, 968, 979, 990, 1001, 1012, 1023, 1034, 1045, 1056, 1067, 1078, 1089, 1100, 1111, 1122, 1133, 1144, 1155, 1166, 1177, 1188, 1199]) == 241\n assert candidate(hours = [12, 48, 84, 120, 156, 192, 228, 264, 300, 336, 372, 408, 444, 480, 516, 552, 588, 624, 660, 696, 732, 768, 804, 840, 876, 912, 948, 984, 1020, 1056, 1092, 1128, 1164, 1200, 1236, 1272, 1308, 1344, 1380, 1416, 1452, 1488, 1524, 1560, 1596, 1632, 1668, 1704, 1740, 1776, 1812, 1848, 1884, 1920, 1956, 1992, 2028, 2064, 2100, 2136, 2172, 2208, 2244, 2280, 2316, 2352, 2388, 2424, 2460, 2496, 2532, 2568, 2604, 2640, 2676, 2712, 2748, 2784, 2820, 2856, 2892, 2928, 2964, 3000]) == 1722\n assert candidate(hours = [5, 19, 29, 35, 43, 59, 65, 77, 83, 95, 101, 113, 119, 131, 137, 149, 155, 167, 173, 185, 191, 203, 209, 221, 227]) == 14\n assert candidate(hours = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156, 168, 180, 192, 204, 216, 228, 240, 252, 264, 276, 288, 300, 312, 324, 336, 348, 360, 372, 384, 396, 408, 420, 432, 444, 456, 468, 480, 492, 504, 516, 528, 540, 552, 564, 576, 588, 600]) == 600\n assert candidate(hours = [1, 2, 3, 22, 23, 46, 47, 70, 71, 94, 95, 118, 119, 142, 143, 166, 167, 190, 191, 214, 215, 238, 239, 262, 263, 286, 287, 310, 311, 334, 335, 358, 359, 382, 383, 406, 407, 430, 431, 454, 455, 478, 479, 502, 503, 526, 527, 550, 551, 574, 575, 598, 599, 622, 623, 646, 647, 670, 671, 694, 695, 718, 719, 742, 743, 766, 767, 790, 791, 814, 815, 838, 839, 862, 863, 886, 887, 910, 911, 934, 935, 958, 959, 982, 983, 1006, 1007, 1030, 1031, 1054, 1055, 1078, 1079, 1102, 1103, 1126, 1127, 1150, 1151, 1174, 1175, 1198, 1199]) == 100\n assert candidate(hours = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99, 101, 103, 105, 107, 109, 111, 113, 115, 117, 119, 121, 123, 125, 127, 129, 131, 133, 135, 137, 139, 141, 143, 145, 147, 149, 151, 153, 155, 157, 159, 161, 163, 165, 167, 169, 171, 173, 175, 177, 179, 181, 183, 185, 187, 189, 191, 193, 195, 197, 199, 201, 203, 205, 207, 209, 211, 213, 215, 217, 219, 221, 223, 225, 227, 229, 231, 233, 235, 237, 239]) == 600\n assert candidate(hours = [48, 96, 144, 192, 240, 288, 336, 384, 432, 480, 528, 576, 624, 672, 720, 768, 816, 864, 912, 960, 1008, 1056, 1104, 1152, 1200, 1248, 1296, 1344, 1392, 1440]) == 435\n assert candidate(hours = [1, 23, 47, 71, 95, 119, 143, 167, 191, 215, 239, 263, 287, 311, 335, 359, 383, 407, 431, 455, 479, 503, 527, 551, 575, 599, 623, 647, 671, 695, 719, 743, 767, 791, 815, 839, 863, 887, 911, 935, 959, 983, 1007, 1031, 1055, 1079, 1103, 1127, 1151, 1175, 1199, 1223, 1247, 1271, 1295, 1319, 1343, 1367, 1391, 1415, 1439, 1463, 1487, 1511, 1535, 1559, 1583, 1607, 1631, 1655, 1679, 1703, 1727, 1751, 1775, 1799, 1823, 1847, 1871, 1895, 1919, 1943, 1967, 1991, 2015]) == 84\n assert candidate(hours = [7, 17, 27, 37, 47, 57, 67, 77, 87, 97, 107, 117, 127, 137, 147, 157, 167, 177, 187, 197, 207, 217, 227, 237, 247, 257, 267, 277, 287, 297]) == 37\n assert candidate(hours = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156, 168, 180, 192, 204, 216, 228, 240, 252, 264, 276, 288, 290, 292, 294, 296, 298, 300, 312, 324, 336, 348, 360, 372, 384, 396, 408, 420, 432, 444, 456, 468, 480, 492, 504, 516, 528, 540, 552, 564, 576, 588, 600, 612, 624, 636, 648, 660, 672, 684, 696, 708, 720]) == 870\n assert candidate(hours = [24, 48, 72, 96, 120, 144, 168, 192, 216, 240, 264, 288, 312, 336, 360, 384, 408, 432, 456, 480, 504, 528, 552, 576, 600, 624, 648, 672, 696, 720]) == 435\n assert candidate(hours = [23, 1, 22, 2, 21, 3, 20, 4, 19, 5, 18, 6, 17, 7, 16, 8, 15, 9, 14, 10, 13, 11]) == 11\n assert candidate(hours = [3, 21, 39, 57, 75, 93, 111, 129, 147, 165, 183, 201, 219, 237, 255, 273, 291, 309, 327, 345, 363, 381, 399, 417, 435]) == 78\n assert candidate(hours = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156, 168, 180, 192, 204, 216, 228, 240, 252, 264, 276, 288, 299, 311, 323, 335, 347, 359]) == 132\n assert candidate(hours = [25, 19, 7, 23, 11, 17, 9, 15, 13, 1, 19, 21, 23, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == 50\n assert candidate(hours = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156, 168, 180, 192, 204, 216, 228, 240, 252, 264, 276, 288, 300, 312, 324, 336, 348, 360, 372, 384, 396, 408, 420, 432, 444, 456, 468, 480, 492, 504, 516, 528, 540, 552, 564, 576, 588, 600, 612, 624, 636, 648, 660, 672, 684, 696, 708, 720, 732, 744, 756, 768, 780, 792, 804, 816, 828, 840]) == 1190\n assert candidate(hours = [11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109]) == 40\n assert candidate(hours = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156, 168, 180, 192, 204, 216, 228, 240, 252, 264, 276, 288, 300, 312, 324, 336, 348, 360, 372, 384, 396, 408, 420, 432, 444, 456, 468, 480, 492, 504, 516, 528, 540, 552, 564, 576, 588, 600, 612, 624, 636, 648, 660, 672, 684, 696, 708, 720, 732, 744, 756, 768, 780, 792, 804, 816, 828, 840, 852, 864, 876, 888, 900, 912, 924, 936, 948, 960, 972, 984, 996, 1008]) == 1722\n assert candidate(hours = [11, 13, 23, 35, 47, 59, 71, 83, 95, 107, 119, 131, 143, 155, 167, 179, 191, 203, 215, 227, 239, 251, 263, 275, 287, 299, 311, 323, 335, 347]) == 15\n assert candidate(hours = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156, 168, 180, 192, 204, 216, 228, 240, 252, 264, 276, 288, 290, 292, 294, 296, 298, 300]) == 144\n assert candidate(hours = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156, 168, 180, 192, 204, 216, 228, 240, 252, 264, 276, 288, 299]) == 132\n assert candidate(hours = [24, 48, 72, 96, 120, 144, 168, 192, 216, 240, 264, 288, 312, 336, 360, 384, 408, 432, 456, 480, 504, 528, 552, 576, 600, 624, 648, 672, 696, 720, 744, 768, 792, 816, 840, 864, 888, 912, 936, 960, 984, 1008, 1032, 1056, 1080, 1104, 1128, 1152, 1176, 1200, 1224, 1248, 1272, 1296, 1320, 1344, 1368, 1392, 1416, 1440]) == 1770\n assert candidate(hours = [1, 5, 11, 13, 19, 21, 25, 27, 31, 33, 37, 39, 43, 45, 49, 51, 55, 57, 61, 63, 67, 69, 73, 75, 79, 81, 85, 87, 91, 93, 97, 99, 103, 105, 109, 111, 115, 117, 121, 123, 127, 129, 133, 135, 139, 141, 145, 147, 151, 153, 157, 159, 163, 165, 169, 171, 175, 177, 181, 183, 187, 189, 193, 195, 199, 201, 205, 207, 211, 213, 217, 219, 223, 225, 229, 231, 235, 237, 241, 243, 247, 249, 253, 255, 259, 261, 265, 267, 271, 273, 277, 279, 283, 285, 289, 291, 295, 297, 301, 303, 307, 309, 313, 315, 319, 321, 325, 327, 331, 333, 337, 339, 343, 345, 349, 351, 355, 357, 361, 363, 367, 369, 373, 375, 379, 381, 385, 387, 391, 393, 397, 399, 403, 405, 409, 411, 415, 417, 421, 423, 427, 429, 433, 435, 439, 441, 445, 447, 451, 453, 457, 459, 463, 465, 469, 471, 475, 477, 481, 483, 487, 489, 493, 495, 499, 501, 505, 507, 511, 513, 517, 519, 523, 525, 529, 531, 535, 537, 541, 543, 547, 549, 553, 555, 559, 561, 565, 567, 571, 573, 577, 579, 583, 585, 589, 591, 595, 597, 601, 603, 607, 609, 613, 615, 619, 621, 625, 627, 631, 633, 637, 639, 643, 645, 649, 651, 655, 657, 661, 663, 667, 669, 673, 675, 679, 681, 685, 687, 691, 693, 697, 699, 703, 705, 709, 711, 715, 717, 721, 723, 727, 729, 733, 735, 739, 741, 745, 747, 751, 753, 757, 759, 763, 765, 769, 771, 775, 777, 781, 783, 787, 789, 793, 795, 799, 801, 805, 807, 811, 813, 817, 819, 823, 825, 829, 831, 835, 837, 841, 843, 847, 849, 853, 855, 859, 861, 865, 867, 871, 873, 877, 879, 883, 885, 889, 891, 895, 897, 901, 903, 907, 909, 913, 915, 919, 921, 925, 927, 931, 933, 937, 939, 943, 945, 949, 951, 955, 957, 961, 963, 967, 969, 973, 975, 979, 981, 985, 987, 991, 993, 997, 999]) == 3445\n assert candidate(hours = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, 2600, 2700, 2800, 2900, 3000, 3100, 3200, 3300, 3400, 3500, 3600, 3700, 3800, 3900, 4000, 4100, 4200, 4300, 4400, 4500, 4600, 4700, 4800, 4900, 5000]) == 200\n assert candidate(hours = [12, 36, 60, 84, 108, 132, 156, 180, 204, 228, 252, 276, 300, 324, 348, 372, 396, 420, 444, 468, 492, 516, 540, 564, 588, 612, 636, 660, 684, 708]) == 435\n assert candidate(hours = [13, 37, 61, 85, 109, 133, 157, 181, 205, 229, 253, 277, 301, 325, 349, 373, 397, 421, 445, 469, 493, 517, 541, 565, 589, 613, 637, 661, 685, 709, 733, 757, 781, 805, 829, 853, 877, 901, 925, 949, 973, 997, 1021, 1045, 1069, 1093, 1117, 1141, 1165, 1189, 1213, 1237, 1261, 1285, 1309, 1333, 1357, 1381, 1405, 1429, 1453, 1477, 1501, 1525, 1549, 1573, 1597, 1621, 1645, 1669, 1693, 1717, 1741, 1765, 1789, 1813, 1837, 1861, 1885, 1909, 1933, 1957, 1981, 2005]) == 0\n assert candidate(hours = [23, 47, 71, 95, 119, 143, 167, 191, 215, 239, 263, 287, 311, 335, 359, 383, 407, 431, 455, 479, 503, 527, 551, 575, 599, 623, 647, 671, 695, 719, 743, 767, 791, 815, 839, 863, 887, 911, 935, 959, 983, 1007, 1031, 1055, 1079, 1103, 1127, 1151, 1175, 1199]) == 0\n assert candidate(hours = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156, 168, 180, 192, 204, 216, 228, 240, 252, 264, 276, 288, 300, 312, 324, 336, 348, 360, 372, 384, 396, 408, 420, 432, 444, 456, 468, 480, 492, 504, 516, 528, 540, 552, 564, 576, 588, 600, 612, 624, 636, 648, 660, 672, 684, 696, 708, 720, 732, 744, 756, 768, 780, 792, 804, 816, 828, 840, 852, 864, 876, 888, 900, 912, 924, 936, 948, 960, 972, 984, 996]) == 1681\n assert candidate(hours = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 93, 96, 99, 102, 105, 108, 111, 114, 117, 120, 123, 126, 129, 132, 135, 138, 141, 144, 147, 150, 153, 156, 159, 162, 165, 168, 171, 174, 177, 180, 183, 186, 189, 192, 195, 198, 201, 204, 207, 210, 213, 216, 219, 222, 225, 228, 231, 234, 237, 240]) == 390\n assert candidate(hours = [5, 19, 29, 35, 41, 47, 53, 59, 65, 71, 77, 83, 89, 95, 101, 107, 113, 119, 125, 131, 137, 143, 149, 155, 161, 167, 173, 179, 185, 191, 197, 203, 209, 215, 221, 227, 233, 239]) == 10\n"}, "metadata": {"canonical_parameter_names": ["hours"], "leetcode_dataset_entry_point": "Solution().countCompleteDayPairs", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "long long countCompleteDayPairs(vector& hours) {", "container": "Solution", "callable": "countCompleteDayPairs", "parameters": [{"name": "hours", "type": "vector&"}], "return_type": "long long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3186, "task_id": "maximum-total-damage-with-spell-casting", "difficulty": "Medium", "problem_description": "A magician has various spells.\nYou are given an array power, where each element represents the damage of a spell. Multiple spells can have the same damage value.\nIt is a known fact that if a magician decides to cast a spell with a damage of power[i], they cannot cast any spell with a damage of power[i] - 2, power[i] - 1, power[i] + 1, or power[i] + 2.\nEach spell can be cast only once.\nReturn the maximum possible total damage that a magician can cast.\n \nExample 1:\n\nInput: power = [1,1,3,4]\nOutput: 6\nExplanation:\nThe maximum possible damage of 6 is produced by casting spells 0, 1, 3 with damage 1, 1, 4.\n\nExample 2:\n\nInput: power = [7,1,6,6]\nOutput: 13\nExplanation:\nThe maximum possible damage of 13 is produced by casting spells 1, 2, 3 with damage 1, 6, 6.\n\n \nConstraints:\n\n1 <= power.length <= 105\n1 <= power[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(power = [5, 5, 5, 5, 5]) == 25\n assert candidate(power = [1, 10, 19, 28, 37, 46, 55, 64, 73, 82, 91]) == 506\n assert candidate(power = [5, 3, 8, 9, 2]) == 16\n assert candidate(power = [5, 11, 17, 23, 29, 35, 41, 47, 53, 59]) == 320\n assert candidate(power = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 55\n assert candidate(power = [3, 8, 3, 10, 1, 3, 3, 9, 5]) == 22\n assert candidate(power = [10, 20, 30, 40, 50]) == 150\n assert candidate(power = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 60\n assert candidate(power = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 5000000000\n assert candidate(power = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 60\n assert candidate(power = [10, 20, 30, 40, 50]) == 150\n assert candidate(power = [1000000000, 1, 2, 3, 1000000000]) == 2000000003\n assert candidate(power = [1, 1, 3, 4]) == 6\n assert candidate(power = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(power = [7, 1, 6, 6]) == 13\n assert candidate(power = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 22\n assert candidate(power = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 22\n assert candidate(power = [5, 5, 5, 5]) == 20\n assert candidate(power = [1, 2, 3, 6, 7, 8, 11, 12, 13]) == 24\n assert candidate(power = [1000000000, 1000000000, 1000000000, 1000000000]) == 4000000000\n assert candidate(power = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 55\n assert candidate(power = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 550\n assert candidate(power = [1, 10, 19, 28, 37, 46, 55, 64, 73, 82]) == 415\n assert candidate(power = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 2650\n assert candidate(power = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 100\n assert candidate(power = [5, 6, 8, 10, 11, 13, 15, 17, 18, 20]) == 66\n assert candidate(power = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 77\n assert candidate(power = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 1111111111\n assert candidate(power = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50, 53, 56, 59, 62, 65, 68, 71, 74]) == 950\n assert candidate(power = [1, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84]) == 1218\n assert candidate(power = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 18\n assert candidate(power = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 117\n assert candidate(power = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 5, 6, 7, 8, 9, 1, 2, 3, 4, 11, 12, 13, 14, 15, 16, 17, 18, 19, 21, 22]) == 612\n assert candidate(power = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 210\n assert candidate(power = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 1045\n assert candidate(power = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250]) == 3250\n assert candidate(power = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == 21000\n assert candidate(power = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 44\n assert candidate(power = [1, 6, 11, 16, 21, 26, 31, 36, 41, 46, 51, 56, 61, 66, 71, 76, 81, 86, 91, 96]) == 970\n assert candidate(power = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 1050\n assert candidate(power = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 120\n assert candidate(power = [10, 1, 20, 2, 30, 3, 40, 4, 50, 5]) == 157\n assert candidate(power = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 44\n assert candidate(power = [1000000000, 999999998, 999999996, 999999994, 999999992, 999999990, 999999988, 999999986, 999999984, 999999982, 999999980, 999999978, 999999976, 999999974, 999999972, 999999970, 999999968, 999999966, 999999964, 999999962]) == 9999999820\n assert candidate(power = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 44\n assert candidate(power = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == 66\n assert candidate(power = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39]) == 255\n assert candidate(power = [1, 2, 3, 6, 7, 8, 11, 12, 13, 16, 17, 18]) == 42\n assert candidate(power = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120]) == 777\n assert candidate(power = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37]) == 190\n assert candidate(power = [2, 7, 12, 17, 22, 27, 32, 37, 42, 47, 52, 57, 62, 67, 72, 77, 82, 87, 92, 97]) == 990\n assert candidate(power = [1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 10, 10, 11, 11, 12, 12]) == 66\n assert candidate(power = [1000000000, 999999998, 999999996, 999999994, 999999992, 999999990, 999999988, 999999986, 999999984, 999999982]) == 4999999960\n assert candidate(power = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 5500\n assert candidate(power = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 999999990]) == 3999999982\n assert candidate(power = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 210\n assert candidate(power = [1000000000, 999999998, 999999996, 999999994, 999999992]) == 2999999988\n assert candidate(power = [1000000000, 999999998, 999999996, 999999994, 999999992, 999999990, 999999988]) == 3999999976\n assert candidate(power = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 150\n assert candidate(power = [1, 2, 5, 9, 10, 11, 14, 18, 20, 21, 23, 27, 28, 30, 31, 34, 38, 40, 41, 43]) == 251\n assert candidate(power = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97]) == 1225\n assert candidate(power = [1, 1000000000, 2, 999999998, 3, 999999996, 4, 999999994, 5, 999999992, 6, 999999990, 7, 999999988, 8, 999999986, 9, 999999984, 10, 999999982]) == 4999999982\n assert candidate(power = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60]) == 480\n assert candidate(power = [1, 3, 6, 8, 11, 13, 16, 18, 21, 23, 26, 28, 31, 33, 36, 38, 41, 43, 46, 48, 51, 53, 56, 58, 61, 63]) == 429\n assert candidate(power = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == 325\n assert candidate(power = [10, 10, 15, 15, 20, 20, 25, 25, 30, 30, 35, 35, 40, 40, 45, 45, 50, 50, 55, 55]) == 650\n assert candidate(power = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9]) == 90\n assert candidate(power = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 1, 3, 5, 7, 9]) == 220\n assert candidate(power = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 105\n assert candidate(power = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150]) == 2325\n assert candidate(power = [1, 2, 2, 3, 4, 5, 5, 6, 7, 8, 8, 9, 10, 10, 11, 12, 12, 13, 14, 15]) == 69\n assert candidate(power = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44]) == 345\n assert candidate(power = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300]) == 4650\n assert candidate(power = [1, 1000000000, 2, 999999999, 3, 999999998, 4, 999999997, 5, 999999996, 6, 999999995, 7, 999999994, 8, 999999993]) == 3000000006\n assert candidate(power = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 551\n assert candidate(power = [1, 1, 1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == 73\n assert candidate(power = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 147\n assert candidate(power = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90]) == 1395\n assert candidate(power = [1000000000, 1000000000, 1000000000, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992]) == 4999999991\n assert candidate(power = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 239\n assert candidate(power = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135, 144, 153, 162, 171, 180]) == 1890\n assert candidate(power = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52, 55, 58, 61, 64, 67, 70, 73, 76, 79, 82, 85, 88, 91, 94, 97, 100]) == 1717\n assert candidate(power = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209]) == 1236\n assert candidate(power = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59]) == 465\n assert candidate(power = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == 90\n assert candidate(power = [10, 12, 10, 14, 12, 16, 14, 18, 16, 20, 18, 22, 20, 24, 22, 26, 24, 28, 26, 30]) == 210\n assert candidate(power = [5, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 221\n assert candidate(power = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == 90\n assert candidate(power = [9, 2, 8, 3, 7, 4, 6, 5, 1, 10, 19, 11, 18, 12, 17, 13, 16, 14, 15, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 165\n assert candidate(power = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 165\n assert candidate(power = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 30\n assert candidate(power = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 2100\n assert candidate(power = [1, 6, 11, 16, 21, 26, 31, 36, 41, 46]) == 235\n assert candidate(power = [3, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == 325\n assert candidate(power = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 100\n assert candidate(power = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125]) == 1625\n assert candidate(power = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5]) == 28\n assert candidate(power = [1, 3, 6, 8, 10, 13, 15, 18, 20, 23, 25, 28, 30, 33, 35, 38, 40, 43, 45, 48, 50, 53, 55, 58, 60, 63, 65, 68, 70, 73, 75]) == 604\n assert candidate(power = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 12000\n"}, "metadata": {"canonical_parameter_names": ["power"], "leetcode_dataset_entry_point": "Solution().maximumTotalDamage", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "long long maximumTotalDamage(vector& power) {", "container": "Solution", "callable": "maximumTotalDamage", "parameters": [{"name": "power", "type": "vector&"}], "return_type": "long long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3187, "task_id": "peaks-in-array", "difficulty": "Hard", "problem_description": "A peak in an array arr is an element that is greater than its previous and next element in arr.\nYou are given an integer array nums and a 2D integer array queries.\nYou have to process queries of two types:\n\nqueries[i] = [1, li, ri], determine the count of peak elements in the subarray nums[li..ri].\nqueries[i] = [2, indexi, vali], change nums[indexi] to vali.\n\nReturn an array answer containing the results of the queries of the first type in order.\nNotes:\n\nThe first and the last element of an array or a subarray cannot be a peak.\n\n \nExample 1:\n\nInput: nums = [3,1,4,2,5], queries = [[2,3,4],[1,0,4]]\nOutput: [0]\nExplanation:\nFirst query: We change nums[3] to 4 and nums becomes [3,1,4,4,5].\nSecond query: The number of peaks in the [3,1,4,4,5] is 0.\n\nExample 2:\n\nInput: nums = [4,1,4,2,1,5], queries = [[2,2,4],[1,0,2],[1,0,4]]\nOutput: [0,1]\nExplanation:\nFirst query: nums[2] should become 4, but it is already set to 4.\nSecond query: The number of peaks in the [4,1,4] is 0.\nThird query: The second 4 is a peak in the [4,1,4,2,1].\n\n \nConstraints:\n\n3 <= nums.length <= 105\n1 <= nums[i] <= 105\n1 <= queries.length <= 105\nqueries[i][0] == 1 or queries[i][0] == 2\nFor all i that:\n\t\nqueries[i][0] == 1: 0 <= queries[i][1] <= queries[i][2] <= nums.length - 1\nqueries[i][0] == 2: 0 <= queries[i][1] <= nums.length - 1, 1 <= queries[i][2] <= 105\n\n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [3, 1, 4, 2, 5],queries = [[2, 3, 4], [1, 0, 4]]) == [0]\n assert candidate(nums = [4, 1, 4, 2, 1, 5],queries = [[2, 2, 4], [1, 0, 2], [1, 0, 4]]) == [0, 1]\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5],queries = [[1, 1, 8], [2, 3, 1], [1, 1, 8], [2, 5, 7], [1, 0, 4]]) == [3, 2, 1]\n assert candidate(nums = [5, 1, 5, 1, 5, 1, 5, 1, 5],queries = [[1, 1, 7], [2, 2, 6], [2, 4, 3], [1, 0, 8]]) == [3, 3]\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1],queries = [[2, 0, 10], [1, 1, 11], [2, 1, 9], [1, 1, 11], [2, 2, 8], [1, 1, 11], [2, 3, 7], [1, 1, 11], [2, 4, 6], [1, 1, 11]]) == [3, 2, 2, 2, 2]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[2, 10, 8], [1, 0, 28], [2, 15, 13], [1, 8, 20]]) == [1, 2]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],queries = [[1, 1, 13], [2, 7, 1], [1, 1, 13]]) == [0, 1]\n assert candidate(nums = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5],queries = [[1, 1, 10], [2, 4, 3], [1, 3, 11], [2, 8, 4], [1, 0, 12]]) == [4, 4, 5]\n assert candidate(nums = [5, 1, 5, 1, 5, 1, 5, 1, 5],queries = [[1, 0, 8], [2, 1, 3], [1, 0, 8], [2, 3, 5], [1, 0, 8], [2, 5, 7], [1, 0, 8]]) == [3, 3, 1, 1]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [[1, 0, 9], [2, 1, 10], [1, 0, 8], [2, 3, 9], [1, 2, 7]]) == [0, 0, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],queries = [[1, 0, 14], [2, 6, 10], [1, 0, 14], [2, 4, 8], [1, 0, 14], [2, 7, 11], [1, 0, 14]]) == [0, 1, 2, 2]\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [[1, 0, 14], [2, 7, 18], [1, 0, 14], [2, 10, 12], [1, 0, 14]]) == [0, 1, 2]\n assert candidate(nums = [10, 20, 10, 20, 10, 20, 10, 20, 10],queries = [[1, 0, 8], [2, 1, 25], [1, 0, 8], [2, 3, 30], [1, 0, 8]]) == [4, 4, 4]\n assert candidate(nums = [100, 50, 100, 50, 100, 50, 100, 50, 100],queries = [[1, 1, 7], [2, 2, 150], [1, 0, 8], [2, 4, 200], [1, 0, 8]]) == [3, 3, 3]\n assert candidate(nums = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[1, 1, 9], [2, 2, 8], [1, 1, 9], [2, 4, 6], [1, 1, 9], [2, 6, 4], [1, 1, 9]]) == [0, 1, 2, 2]\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10],queries = [[2, 2, 5], [1, 0, 9], [2, 6, 8], [1, 1, 8]]) == [4, 3]\n assert candidate(nums = [7, 2, 8, 3, 9, 4, 10, 5, 11, 6, 12, 7, 13, 8, 14, 9, 15],queries = [[1, 0, 16], [2, 1, 5], [1, 3, 15], [2, 9, 12], [1, 0, 16]]) == [7, 6, 5]\n assert candidate(nums = [1, 5, 1, 5, 1, 5, 1, 5, 1, 5],queries = [[1, 1, 8], [2, 4, 3], [1, 1, 8], [2, 6, 2], [1, 1, 8]]) == [3, 3, 3]\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9],queries = [[2, 2, 4], [1, 0, 16], [2, 8, 7], [1, 6, 12]]) == [6, 1]\n assert candidate(nums = [5, 1, 4, 1, 5, 1, 4, 1, 5, 1, 4, 1, 5, 1, 4],queries = [[1, 1, 13], [2, 2, 3], [1, 1, 13], [2, 4, 5], [1, 1, 13], [2, 6, 7], [1, 1, 13], [2, 8, 9], [1, 1, 13], [2, 10, 11], [1, 1, 13], [2, 12, 13], [1, 1, 13]]) == [6, 6, 6, 6, 6, 6, 6]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[1, 1, 8], [2, 5, 10], [1, 1, 8]]) == [0, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [[2, 5, 6], [1, 0, 18], [2, 10, 9], [1, 4, 14]]) == [1, 1]\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5],queries = [[1, 0, 10], [2, 4, 10], [1, 0, 10], [2, 2, 1], [1, 0, 10]]) == [5, 4, 4]\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [[1, 2, 18], [2, 9, 12], [1, 2, 18], [2, 12, 8], [1, 2, 18]]) == [1, 2, 2]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [[1, 0, 18], [2, 4, 5], [1, 0, 18], [2, 10, 11], [1, 0, 18]]) == [1, 1, 1]\n assert candidate(nums = [5, 3, 4, 2, 3, 1, 2, 3, 1, 2],queries = [[1, 0, 9], [2, 2, 5], [1, 1, 8], [2, 5, 3], [1, 0, 8]]) == [3, 3, 2]\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7],queries = [[1, 2, 8], [2, 3, 3], [1, 0, 9], [2, 5, 8], [1, 1, 7]]) == [3, 3, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],queries = [[1, 0, 14], [2, 7, 20], [1, 0, 14], [2, 10, 15], [1, 0, 14]]) == [0, 1, 2]\n assert candidate(nums = [10, 20, 15, 25, 20, 30, 25, 35, 30, 40],queries = [[1, 1, 9], [2, 4, 25], [1, 0, 8], [2, 7, 34], [1, 2, 7]]) == [3, 3, 1]\n assert candidate(nums = [7, 3, 8, 2, 9, 1, 10, 4, 11, 5, 12, 6, 13],queries = [[1, 1, 12], [2, 5, 1], [1, 1, 12], [2, 9, 8], [1, 0, 13]]) == [5, 5, 5]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[2, 5, 3], [1, 0, 9], [2, 4, 5], [1, 2, 7]]) == [1, 1]\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1],queries = [[1, 0, 12], [2, 5, 4], [1, 3, 9], [2, 6, 3], [1, 0, 12]]) == [3, 1, 3]\n assert candidate(nums = [1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9],queries = [[1, 0, 18], [2, 1, 2], [1, 0, 18], [2, 3, 4], [1, 0, 18], [2, 5, 6], [1, 0, 18], [2, 7, 8], [1, 0, 18], [2, 9, 10], [1, 0, 18], [2, 11, 12], [1, 0, 18]]) == [9, 9, 9, 9, 9, 9, 9]\n assert candidate(nums = [100, 90, 110, 80, 120, 70, 130, 60, 140, 50],queries = [[1, 2, 8], [2, 3, 100], [1, 0, 9], [2, 6, 90], [1, 1, 7]]) == [2, 4, 3]\n assert candidate(nums = [8, 1, 9, 2, 10, 3, 11, 4, 12, 5, 13, 6, 14, 7, 15, 8, 16, 9, 17, 10, 18],queries = [[1, 0, 20], [2, 2, 7], [1, 1, 19], [2, 6, 12], [1, 0, 20]]) == [9, 9, 9]\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12],queries = [[1, 1, 12], [2, 3, 6], [1, 2, 11], [2, 7, 10], [1, 0, 13]]) == [5, 4, 6]\n assert candidate(nums = [5, 3, 4, 2, 5, 4, 3, 6, 4, 7, 5, 8, 6, 9, 7],queries = [[1, 1, 14], [2, 3, 3], [1, 1, 14], [2, 10, 10], [1, 1, 14]]) == [6, 6, 5]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[1, 1, 17], [2, 9, 2], [1, 1, 17], [2, 12, 3], [1, 1, 17]]) == [0, 1, 2]\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1],queries = [[1, 2, 10], [2, 5, 5], [1, 2, 10], [2, 7, 7], [1, 2, 10]]) == [2, 3, 4]\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1],queries = [[1, 1, 8], [2, 3, 3], [1, 0, 9], [2, 5, 2], [1, 1, 7]]) == [3, 3, 1]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [[2, 3, 6], [1, 1, 8], [2, 5, 7], [1, 3, 7]]) == [0, 1]\n assert candidate(nums = [5, 1, 4, 3, 2, 6, 7, 8, 9, 10, 5, 1],queries = [[2, 4, 7], [1, 0, 10], [2, 8, 2], [1, 3, 9]]) == [3, 2]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],queries = [[1, 0, 10], [2, 5, 5], [2, 6, 6], [1, 0, 10]]) == [0, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[1, 0, 9], [2, 4, 5], [1, 0, 9], [2, 2, 3], [1, 0, 9], [2, 6, 7], [1, 0, 9]]) == [0, 0, 0, 0]\n assert candidate(nums = [5, 10, 5, 10, 5, 10, 5, 10, 5],queries = [[1, 0, 8], [2, 1, 7], [1, 0, 8], [2, 3, 9], [1, 0, 8], [2, 5, 8], [1, 0, 8]]) == [4, 4, 4, 4]\n assert candidate(nums = [1, 3, 2, 1, 3, 2, 1, 3, 2, 1],queries = [[1, 0, 9], [2, 1, 4], [1, 0, 9], [2, 3, 5], [1, 0, 9], [2, 5, 7], [1, 0, 9]]) == [3, 3, 3, 4]\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8],queries = [[1, 0, 14], [2, 1, 1], [1, 0, 14], [2, 3, 4], [1, 0, 14], [2, 5, 6], [1, 0, 14]]) == [7, 6, 6, 6]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],queries = [[1, 2, 12], [2, 5, 55], [1, 2, 12], [2, 9, 95], [1, 2, 12]]) == [0, 0, 0]\n assert candidate(nums = [10, 20, 15, 25, 20, 30, 25, 35, 30, 40, 35, 45],queries = [[1, 1, 10], [2, 5, 28], [1, 2, 9], [2, 8, 33], [1, 3, 11]]) == [4, 3, 3]\n assert candidate(nums = [5, 1, 4, 3, 2, 8, 7, 9, 6, 10],queries = [[1, 1, 9], [2, 4, 7], [2, 6, 5], [1, 1, 9]]) == [3, 3]\n assert candidate(nums = [9, 1, 9, 1, 9, 1, 9, 1, 9],queries = [[1, 0, 8], [2, 1, 2], [1, 0, 8], [2, 3, 4], [1, 0, 8], [2, 5, 6], [1, 0, 8], [2, 7, 8], [1, 0, 8]]) == [3, 3, 3, 3, 3]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [[1, 0, 8], [2, 4, 10], [1, 0, 8]]) == [0, 1]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [[1, 2, 8], [2, 3, 11], [1, 2, 8], [2, 7, 12], [1, 2, 8]]) == [0, 1, 2]\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 21],queries = [[1, 1, 19], [2, 2, 10], [1, 1, 19], [2, 4, 20], [1, 1, 19], [2, 6, 30], [1, 1, 19], [2, 8, 40], [1, 1, 19], [2, 10, 50], [1, 1, 19], [2, 12, 60], [1, 1, 19], [2, 14, 70], [1, 1, 19], [2, 16, 80], [1, 1, 19], [2, 18, 90], [1, 1, 19]]) == [8, 8, 8, 8, 8, 8, 8, 8, 8, 9]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[1, 0, 8], [2, 3, 2], [1, 1, 7]]) == [0, 1]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],queries = [[1, 1, 8], [2, 3, 65], [1, 2, 9], [2, 6, 55], [1, 0, 9]]) == [0, 0, 1]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9],queries = [[2, 5, 5], [1, 0, 16], [2, 10, 10], [1, 5, 11]]) == [0, 1]\n assert candidate(nums = [1000, 999, 1001, 998, 1002, 997, 1003, 996, 1004, 995],queries = [[1, 0, 9], [2, 2, 1000], [1, 1, 8], [2, 4, 1001], [1, 0, 8]]) == [4, 3, 3]\n assert candidate(nums = [10, 20, 15, 25, 20, 30, 25, 35, 30, 40],queries = [[1, 0, 9], [2, 3, 50], [1, 2, 8], [2, 6, 10], [1, 0, 9]]) == [4, 3, 4]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[1, 0, 9], [2, 4, 5], [1, 0, 9], [2, 3, 6], [1, 0, 9]]) == [0, 0, 1]\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5],queries = [[1, 1, 8], [2, 2, 10], [2, 4, 20], [1, 0, 8]]) == [3, 3]\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1],queries = [[1, 0, 16], [2, 6, 6], [1, 3, 13], [2, 10, 10], [1, 0, 16]]) == [2, 3, 4]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[2, 5, 3], [1, 0, 9], [2, 4, 10], [1, 1, 8], [2, 8, 5]]) == [1, 1]\n assert candidate(nums = [100, 200, 150, 300, 250, 400, 350, 500, 450, 600, 550],queries = [[1, 0, 10], [2, 2, 225], [1, 0, 10], [2, 6, 375], [1, 0, 10]]) == [5, 4, 4]\n assert candidate(nums = [10, 20, 10, 30, 20, 40, 30, 50, 40],queries = [[1, 0, 8], [2, 3, 15], [1, 0, 8], [1, 2, 6]]) == [4, 3, 1]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [[1, 1, 7], [2, 5, 7], [1, 1, 7]]) == [0, 1]\n assert candidate(nums = [10, 20, 15, 30, 25, 40, 35, 50, 45, 60, 55, 70, 65],queries = [[1, 1, 11], [2, 2, 18], [1, 1, 11], [2, 4, 28], [1, 1, 11], [2, 6, 38], [1, 1, 11], [2, 8, 48], [1, 1, 11]]) == [4, 4, 4, 4, 4]\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5],queries = [[1, 0, 8], [2, 1, 2], [2, 3, 3], [1, 0, 8]]) == [4, 2]\n assert candidate(nums = [1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1],queries = [[1, 0, 20], [2, 1, 10], [1, 0, 20], [2, 3, 15], [1, 0, 20], [2, 5, 18], [1, 0, 20], [2, 7, 20], [1, 0, 20]]) == [7, 7, 7, 8, 8]\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2],queries = [[1, 0, 9], [2, 2, 3], [1, 1, 8], [2, 4, 5], [1, 2, 7]]) == [4, 3, 1]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [[1, 0, 9], [2, 5, 6], [1, 0, 9], [2, 4, 7], [1, 0, 9]]) == [0, 0, 0]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [[1, 1, 7], [2, 4, 5], [1, 1, 7]]) == [0, 0]\n assert candidate(nums = [5, 1, 3, 2, 4, 6, 5, 7, 8, 9, 7, 11, 10],queries = [[1, 0, 12], [2, 2, 5], [1, 1, 11], [2, 5, 8], [1, 0, 12]]) == [4, 3, 4]\n assert candidate(nums = [5, 3, 4, 6, 7, 8, 2, 4, 5, 6, 3, 2, 1],queries = [[1, 1, 12], [2, 5, 10], [1, 1, 12], [2, 8, 9], [1, 1, 12]]) == [2, 2, 2]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],queries = [[1, 1, 7], [2, 3, 5], [1, 1, 7]]) == [0, 0]\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7],queries = [[1, 0, 9], [2, 4, 6], [1, 0, 9], [2, 5, 8], [1, 0, 9]]) == [4, 3, 3]\n assert candidate(nums = [100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100],queries = [[2, 1, 50], [1, 0, 10], [2, 3, 50], [1, 2, 8]]) == [4, 2]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[1, 1, 8], [2, 4, 5], [1, 1, 8], [2, 7, 8], [1, 0, 9]]) == [0, 0, 0]\n assert candidate(nums = [10, 20, 15, 25, 30, 5, 40, 35, 50, 45, 60],queries = [[1, 0, 10], [2, 4, 20], [1, 3, 9], [2, 6, 30], [1, 5, 8]]) == [4, 2, 0]\n assert candidate(nums = [10, 11, 10, 12, 11, 13, 12, 14, 13, 15],queries = [[1, 1, 8], [2, 3, 15], [1, 0, 9], [2, 6, 11], [1, 2, 7]]) == [3, 4, 2]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],queries = [[1, 1, 7], [2, 4, 10], [1, 1, 7]]) == [0, 1]\n assert candidate(nums = [5, 3, 7, 5, 9, 7, 11, 9, 13, 11, 15],queries = [[1, 1, 9], [2, 4, 8], [1, 1, 9], [2, 6, 10], [1, 1, 9], [2, 8, 14], [1, 1, 9]]) == [4, 4, 4, 4]\n assert candidate(nums = [3, 1, 4, 2, 5, 3, 1, 4, 2, 5],queries = [[2, 3, 4], [1, 0, 4], [2, 5, 6], [1, 4, 9]]) == [0, 2]\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 8, 9],queries = [[1, 2, 5], [2, 4, 6], [1, 2, 5], [2, 3, 5], [1, 2, 5]]) == [1, 0, 0]\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1],queries = [[1, 0, 16], [2, 2, 10], [1, 0, 16], [2, 5, 8], [1, 0, 16], [2, 8, 12], [1, 0, 16]]) == [4, 4, 4, 5]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [[1, 0, 9], [2, 5, 6], [1, 0, 9], [2, 4, 3], [1, 0, 9]]) == [0, 0, 1]\n"}, "metadata": {"canonical_parameter_names": ["nums", "queries"], "leetcode_dataset_entry_point": "Solution().countOfPeaks", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector countOfPeaks(vector& nums, vector>& queries) {", "container": "Solution", "callable": "countOfPeaks", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "queries", "type": "vector>&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3190, "task_id": "find-minimum-operations-to-make-all-elements-divisible-by-three", "difficulty": "Easy", "problem_description": "You are given an integer array nums. In one operation, you can add or subtract 1 from any element of nums.\nReturn the minimum number of operations to make all elements of nums divisible by 3.\n \nExample 1:\n\nInput: nums = [1,2,3,4]\nOutput: 3\nExplanation:\nAll array elements can be made divisible by 3 using 3 operations:\n\nSubtract 1 from 1.\nAdd 1 to 2.\nSubtract 1 from 4.\n\n\nExample 2:\n\nInput: nums = [3,6,9]\nOutput: 0\n\n \nConstraints:\n\n1 <= nums.length <= 50\n1 <= nums[i] <= 50\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 4, 5]) == 4\n assert candidate(nums = [1, 1, 1, 1]) == 4\n assert candidate(nums = [3, 3, 3, 3]) == 0\n assert candidate(nums = [1, 2, 4, 5, 7]) == 5\n assert candidate(nums = [1, 2, 4, 5, 7, 8]) == 6\n assert candidate(nums = [11, 22, 33, 44]) == 3\n assert candidate(nums = [15, 18, 21, 24]) == 0\n assert candidate(nums = [50, 49, 48, 47, 46]) == 4\n assert candidate(nums = [1, 2, 3, 4]) == 3\n assert candidate(nums = [47, 49, 50]) == 3\n assert candidate(nums = [2, 4, 8, 10]) == 4\n assert candidate(nums = [2, 4, 8, 16]) == 4\n assert candidate(nums = [1, 4, 7, 10]) == 4\n assert candidate(nums = [1, 5, 7, 10]) == 4\n assert candidate(nums = [1, 1, 1, 1, 1]) == 5\n assert candidate(nums = [33, 36, 39, 42]) == 0\n assert candidate(nums = [2, 2, 2, 2]) == 4\n assert candidate(nums = [2, 5, 8, 11]) == 4\n assert candidate(nums = [5, 10, 15, 20, 25]) == 4\n assert candidate(nums = [2, 5, 8, 11, 14]) == 5\n assert candidate(nums = [5, 10, 15, 20]) == 3\n assert candidate(nums = [4, 5, 6, 7]) == 3\n assert candidate(nums = [1, 2, 5]) == 3\n assert candidate(nums = [1, 5, 7]) == 3\n assert candidate(nums = [3, 6, 9]) == 0\n assert candidate(nums = [30, 33, 36, 39]) == 0\n assert candidate(nums = [7, 14, 21, 28]) == 3\n assert candidate(nums = [2, 2, 2, 2, 2]) == 5\n assert candidate(nums = [10, 20, 30, 40]) == 3\n assert candidate(nums = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 50, 1, 2, 3]) == 11\n assert candidate(nums = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49]) == 17\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 14\n assert candidate(nums = [47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67]) == 8\n assert candidate(nums = [9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 8\n assert candidate(nums = [8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50]) == 15\n assert candidate(nums = [1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20, 22, 23, 25, 26, 28, 29]) == 20\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99]) == 0\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33]) == 0\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]) == 8\n assert candidate(nums = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35]) == 11\n assert candidate(nums = [15, 18, 21, 24, 27, 30, 33, 36, 39, 42]) == 0\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48]) == 0\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 4, 9, 14, 19, 24, 29, 34, 39, 44, 49, 3, 6, 9, 12, 18, 21, 27, 33, 36, 39, 42, 48]) == 14\n assert candidate(nums = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]) == 7\n assert candidate(nums = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44]) == 8\n assert candidate(nums = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50]) == 17\n assert candidate(nums = [25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]) == 8\n assert candidate(nums = [30, 32, 35, 38, 41, 44, 47, 50]) == 7\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 100]) == 7\n assert candidate(nums = [17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 9\n assert candidate(nums = [45, 46, 47, 48, 49, 50, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31]) == 14\n assert candidate(nums = [1, 5, 7, 8, 10]) == 5\n assert candidate(nums = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47]) == 16\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 50]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 8\n assert candidate(nums = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29]) == 10\n assert candidate(nums = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34]) == 12\n assert candidate(nums = [31, 32, 34, 35, 37, 38, 40, 41, 43, 44, 46, 47, 49]) == 13\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110]) == 7\n assert candidate(nums = [19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49]) == 11\n assert candidate(nums = [29, 38, 47, 56, 65, 74, 83, 92, 101, 110, 119]) == 11\n assert candidate(nums = [1, 4, 7, 10, 13, 16, 19]) == 7\n assert candidate(nums = [29, 30, 31, 32, 33, 34, 35, 36]) == 5\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 6\n assert candidate(nums = [29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 20\n assert candidate(nums = [2, 3, 5, 6, 8, 9, 11, 12, 14, 15, 17, 18]) == 6\n assert candidate(nums = [29, 32, 35, 38, 41, 44, 47, 50, 53]) == 9\n assert candidate(nums = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48]) == 8\n assert candidate(nums = [25, 26, 27, 28, 29, 30, 31, 32, 33]) == 6\n assert candidate(nums = [1, 5, 10, 15, 20, 25]) == 5\n assert candidate(nums = [1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20, 22, 23, 25, 26]) == 18\n assert candidate(nums = [1, 5, 7, 8, 11, 13]) == 6\n assert candidate(nums = [45, 46, 47, 48, 49, 1, 2, 3, 4, 5, 6]) == 7\n assert candidate(nums = [8, 17, 26, 35, 44, 53]) == 6\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 10\n assert candidate(nums = [1, 5, 7, 8, 10, 12, 14, 16, 19, 22]) == 9\n assert candidate(nums = [49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33]) == 11\n assert candidate(nums = [10, 20, 30, 40, 50]) == 4\n assert candidate(nums = [41, 44, 47, 50, 1, 4, 7, 10, 13, 16]) == 10\n assert candidate(nums = [1, 5, 7, 11, 13, 17, 19]) == 7\n assert candidate(nums = [13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49]) == 13\n assert candidate(nums = [1, 5, 7, 11, 14, 17, 20, 23]) == 8\n assert candidate(nums = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43]) == 15\n assert candidate(nums = [1, 2, 4, 5, 7, 8, 10]) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 14\n assert candidate(nums = [15, 16, 18, 20, 21, 23, 25, 27, 28, 30, 32, 34, 36, 38, 40]) == 9\n assert candidate(nums = [29, 28, 27, 26, 25, 24, 23, 22, 21, 20]) == 7\n assert candidate(nums = [4, 6, 8, 10, 12, 14, 16]) == 5\n assert candidate(nums = [1, 5, 7, 10, 11, 14, 16]) == 7\n assert candidate(nums = [30, 33, 36, 39, 42, 45, 48, 51]) == 0\n assert candidate(nums = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56]) == 10\n assert candidate(nums = [45, 46, 47, 48, 49, 50, 1, 2, 3]) == 6\n assert candidate(nums = [11, 13, 17, 19, 23, 29, 31]) == 7\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70]) == 5\n assert candidate(nums = [29, 58, 87, 116, 145, 174, 203, 232, 261, 290]) == 7\n assert candidate(nums = [3, 5, 6, 9, 12, 15, 18, 21]) == 1\n assert candidate(nums = [4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49]) == 16\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 13\n assert candidate(nums = [37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 1, 2, 3, 4, 5, 6]) == 13\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72]) == 0\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108]) == 0\n assert candidate(nums = [29, 28, 27, 26, 25, 24, 23, 22, 21]) == 6\n assert candidate(nums = [29, 31, 32, 34, 35]) == 5\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 7\n assert candidate(nums = [45, 46, 47, 48, 49, 50, 1, 2, 3, 4]) == 7\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96]) == 8\n assert candidate(nums = [2, 4, 8, 10, 14, 16, 20, 22, 26, 28, 32, 34, 38, 40, 44, 46, 50]) == 17\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 4, 4, 4, 5, 5, 5, 7, 7, 7, 8, 8, 8]) == 18\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53]) == 15\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36]) == 0\n assert candidate(nums = [31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 7\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55]) == 8\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54]) == 0\n assert candidate(nums = [1, 2, 4, 5, 7, 8, 10, 11, 13, 14]) == 10\n assert candidate(nums = [1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20, 22, 23, 25, 26, 28, 29, 31, 32, 34, 35, 37, 38, 40, 41, 43, 44, 46, 47, 49]) == 33\n assert candidate(nums = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60]) == 10\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minimumOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumOperations(vector& nums) {", "container": "Solution", "callable": "minimumOperations", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3191, "task_id": "minimum-operations-to-make-binary-array-elements-equal-to-one-i", "difficulty": "Medium", "problem_description": "You are given a binary array nums.\nYou can do the following operation on the array any number of times (possibly zero):\n\nChoose any 3 consecutive elements from the array and flip all of them.\n\nFlipping an element means changing its value from 0 to 1, and from 1 to 0.\nReturn the minimum number of operations required to make all elements in nums equal to 1. If it is impossible, return -1.\n \nExample 1:\n\nInput: nums = [0,1,1,1,0,0]\nOutput: 3\nExplanation:\nWe can do the following operations:\n\nChoose the elements at indices 0, 1 and 2. The resulting array is nums = [1,0,0,1,0,0].\nChoose the elements at indices 1, 2 and 3. The resulting array is nums = [1,1,1,0,0,0].\nChoose the elements at indices 3, 4 and 5. The resulting array is nums = [1,1,1,1,1,1].\n\n\nExample 2:\n\nInput: nums = [0,1,1,1]\nOutput: -1\nExplanation:\nIt is impossible to make all elements equal to 1.\n\n \nConstraints:\n\n3 <= nums.length <= 105\n0 <= nums[i] <= 1\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [0, 1, 0, 1, 0, 1]) == 3\n assert candidate(nums = [0, 0, 1, 1, 1, 0, 0]) == -1\n assert candidate(nums = [0, 0, 1, 0, 0, 1, 0, 1, 1, 0]) == 4\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1]) == -1\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 0, 0, 0]) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1, 0, 0, 1, 0, 0]) == 2\n assert candidate(nums = [0, 1, 1, 1]) == -1\n assert candidate(nums = [0, 0, 0]) == 1\n assert candidate(nums = [1, 0, 1, 0, 1, 0]) == 3\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 1, 1]) == 2\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0]) == -1\n assert candidate(nums = [0, 1, 1, 1, 0, 0]) == 3\n assert candidate(nums = [0, 0, 0, 0, 0, 0]) == 2\n assert candidate(nums = [1, 1, 0, 0, 0, 1, 1]) == 1\n assert candidate(nums = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1]) == -1\n assert candidate(nums = [1, 1, 1, 0, 0, 0]) == 1\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1]) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0]) == -1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == -1\n assert candidate(nums = [0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0]) == 6\n assert candidate(nums = [0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1]) == -1\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == -1\n assert candidate(nums = [1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == -1\n assert candidate(nums = [0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0]) == -1\n assert candidate(nums = [0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0]) == -1\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 6\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == -1\n assert candidate(nums = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == -1\n assert candidate(nums = [1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == -1\n assert candidate(nums = [1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1]) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1]) == 3\n assert candidate(nums = [1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1]) == 6\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == -1\n assert candidate(nums = [1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0]) == -1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == -1\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 15\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 24\n assert candidate(nums = [0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1]) == -1\n assert candidate(nums = [0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == -1\n assert candidate(nums = [0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0]) == 10\n assert candidate(nums = [0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1]) == 8\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]) == -1\n assert candidate(nums = [0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0]) == 8\n assert candidate(nums = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1]) == -1\n assert candidate(nums = [0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1]) == -1\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1]) == 4\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == -1\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0]) == -1\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 6\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 9\n assert candidate(nums = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == -1\n assert candidate(nums = [0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == 11\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1]) == 2\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == -1\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0]) == -1\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1]) == 5\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == -1\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == -1\n assert candidate(nums = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0]) == -1\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0]) == 3\n assert candidate(nums = [0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == -1\n assert candidate(nums = [1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1]) == -1\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0]) == 12\n assert candidate(nums = [0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1]) == -1\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1]) == -1\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == -1\n assert candidate(nums = [0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == -1\n assert candidate(nums = [0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1]) == -1\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 6\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0]) == -1\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1]) == 4\n assert candidate(nums = [1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1]) == -1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == -1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == -1\n assert candidate(nums = [0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1]) == -1\n assert candidate(nums = [1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1]) == 4\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0]) == 4\n assert candidate(nums = [0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0]) == -1\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1]) == -1\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0]) == -1\n assert candidate(nums = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == 6\n assert candidate(nums = [1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0]) == -1\n assert candidate(nums = [1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0]) == 3\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 12\n assert candidate(nums = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == -1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == -1\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == -1\n assert candidate(nums = [0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1]) == -1\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 9\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == -1\n assert candidate(nums = [1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1]) == -1\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == -1\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == -1\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0]) == 2\n assert candidate(nums = [0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0]) == -1\n assert candidate(nums = [0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0]) == 10\n assert candidate(nums = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == -1\n assert candidate(nums = [1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1]) == 2\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0]) == -1\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minOperations(vector& nums) {", "container": "Solution", "callable": "minOperations", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3192, "task_id": "minimum-operations-to-make-binary-array-elements-equal-to-one-ii", "difficulty": "Medium", "problem_description": "You are given a binary array nums.\nYou can do the following operation on the array any number of times (possibly zero):\n\nChoose any index i from the array and flip all the elements from index i to the end of the array.\n\nFlipping an element means changing its value from 0 to 1, and from 1 to 0.\nReturn the minimum number of operations required to make all elements in nums equal to 1.\n \nExample 1:\n\nInput: nums = [0,1,1,0,1]\nOutput: 4\nExplanation:\nWe can do the following operations:\n\nChoose the index i = 1. The resulting array will be nums = [0,0,0,1,0].\nChoose the index i = 0. The resulting array will be nums = [1,1,1,0,1].\nChoose the index i = 4. The resulting array will be nums = [1,1,1,0,0].\nChoose the index i = 3. The resulting array will be nums = [1,1,1,1,1].\n\n\nExample 2:\n\nInput: nums = [1,0,0,0]\nOutput: 1\nExplanation:\nWe can do the following operation:\n\nChoose the index i = 1. The resulting array will be nums = [1,1,1,1].\n\n\n \nConstraints:\n\n1 <= nums.length <= 105\n0 <= nums[i] <= 1\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [0, 1, 0, 1, 0, 1]) == 6\n assert candidate(nums = [1, 0, 1, 0, 1]) == 4\n assert candidate(nums = [0, 1, 0, 1, 0]) == 5\n assert candidate(nums = [0, 0, 1, 1, 1, 0]) == 3\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1]) == 8\n assert candidate(nums = [1]) == 0\n assert candidate(nums = [1, 1, 0, 0, 1, 1, 0, 0]) == 3\n assert candidate(nums = [1, 0, 0, 0]) == 1\n assert candidate(nums = [0, 0, 0, 0, 0]) == 1\n assert candidate(nums = [1, 0, 0, 1, 0, 0]) == 3\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 10\n assert candidate(nums = [1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [0]) == 1\n assert candidate(nums = [1, 0, 1, 0, 1, 0]) == 5\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0]) == 7\n assert candidate(nums = [0, 0, 1, 1, 0, 0, 1, 1]) == 4\n assert candidate(nums = [0, 0, 0, 1, 1]) == 2\n assert candidate(nums = [1, 1, 0, 0, 0]) == 1\n assert candidate(nums = [0, 1, 1, 0, 1]) == 4\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1]) == 6\n assert candidate(nums = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1]) == 8\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1\n assert candidate(nums = [1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0]) == 9\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(nums = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0]) == 3\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0]) == 7\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1]) == 6\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 14\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 16\n assert candidate(nums = [1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0]) == 11\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1\n assert candidate(nums = [0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 3\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 9\n assert candidate(nums = [1, 1, 1, 1, 1, 0, 0, 0, 0, 0]) == 1\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 18\n assert candidate(nums = [0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 14\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1]) == 2\n assert candidate(nums = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == 11\n assert candidate(nums = [1, 1, 0, 0, 1, 0, 1, 0, 0]) == 5\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1]) == 2\n assert candidate(nums = [1, 1, 0, 1, 0, 0, 1, 0]) == 5\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 15\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 22\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 60\n assert candidate(nums = [1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1\n assert candidate(nums = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == 7\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1]) == 8\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 16\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1]) == 10\n assert candidate(nums = [1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1]) == 2\n assert candidate(nums = [0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1]) == 8\n assert candidate(nums = [0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1]) == 14\n assert candidate(nums = [1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1]) == 6\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 35\n assert candidate(nums = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1]) == 4\n assert candidate(nums = [1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1]) == 8\n assert candidate(nums = [0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0]) == 9\n assert candidate(nums = [1, 1, 0, 1, 0, 0, 1, 1, 0]) == 5\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 2\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 2\n assert candidate(nums = [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0]) == 29\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 25\n assert candidate(nums = [1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0]) == 5\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minOperations(vector& nums) {", "container": "Solution", "callable": "minOperations", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3193, "task_id": "count-the-number-of-inversions", "difficulty": "Hard", "problem_description": "You are given an integer n and a 2D array requirements, where requirements[i] = [endi, cnti] represents the end index and the inversion count of each requirement.\nA pair of indices (i, j) from an integer array nums is called an inversion if:\n\ni < j and nums[i] > nums[j]\n\nReturn the number of permutations perm of [0, 1, 2, ..., n - 1] such that for all requirements[i], perm[0..endi] has exactly cnti inversions.\nSince the answer may be very large, return it modulo 109 + 7.\n \nExample 1:\n\nInput: n = 3, requirements = [[2,2],[0,0]]\nOutput: 2\nExplanation:\nThe two permutations are:\n\n[2, 0, 1]\n\nPrefix [2, 0, 1] has inversions (0, 1) and (0, 2).\nPrefix [2] has 0 inversions.\n\n\n[1, 2, 0]\n\nPrefix [1, 2, 0] has inversions (0, 2) and (1, 2).\nPrefix [1] has 0 inversions.\n\n\n\n\nExample 2:\n\nInput: n = 3, requirements = [[2,2],[1,1],[0,0]]\nOutput: 1\nExplanation:\nThe only satisfying permutation is [2, 0, 1]:\n\nPrefix [2, 0, 1] has inversions (0, 1) and (0, 2).\nPrefix [2, 0] has an inversion (0, 1).\nPrefix [2] has 0 inversions.\n\n\nExample 3:\n\nInput: n = 2, requirements = [[0,0],[1,0]]\nOutput: 1\nExplanation:\nThe only satisfying permutation is [0, 1]:\n\nPrefix [0] has 0 inversions.\nPrefix [0, 1] has an inversion (0, 1).\n\n\n \nConstraints:\n\n2 <= n <= 300\n1 <= requirements.length <= n\nrequirements[i] = [endi, cnti]\n0 <= endi <= n - 1\n0 <= cnti <= 400\nThe input is generated such that there is at least one i such that endi == n - 1.\nThe input is generated such that all endi are unique.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 4,requirements = [[3, 3], [1, 1], [2, 2], [0, 0]]) == 1\n assert candidate(n = 5,requirements = [[4, 6], [2, 2], [3, 3], [1, 1], [0, 0]]) == 1\n assert candidate(n = 2,requirements = [[0, 0], [1, 0]]) == 1\n assert candidate(n = 3,requirements = [[2, 2], [0, 0]]) == 2\n assert candidate(n = 3,requirements = [[2, 2], [1, 1], [0, 0]]) == 1\n assert candidate(n = 5,requirements = [[4, 5], [2, 2], [0, 0]]) == 8\n assert candidate(n = 15,requirements = [[14, 50], [10, 25], [6, 15], [4, 10], [2, 5], [0, 0]]) == 0\n assert candidate(n = 6,requirements = [[5, 6], [3, 3], [1, 1], [0, 0]]) == 12\n assert candidate(n = 7,requirements = [[6, 15], [4, 10], [2, 5], [0, 0]]) == 0\n assert candidate(n = 30,requirements = [[29, 150], [24, 75], [19, 40], [15, 20], [11, 10], [7, 5], [5, 3], [3, 1], [1, 0], [0, 0]]) == 363866727\n assert candidate(n = 15,requirements = [[14, 60], [8, 20], [9, 30], [4, 8], [5, 12], [2, 4], [3, 6], [6, 18], [7, 24], [10, 40], [11, 50], [12, 60], [13, 70], [1, 2], [0, 0]]) == 0\n assert candidate(n = 8,requirements = [[7, 14], [5, 6], [3, 3], [1, 1], [2, 2], [4, 4], [6, 8], [0, 0]]) == 1\n assert candidate(n = 15,requirements = [[14, 85], [12, 45], [10, 20], [8, 10], [6, 6], [4, 3], [2, 2], [0, 0], [3, 5], [5, 8], [7, 12], [9, 18], [11, 30], [13, 50]]) == 0\n assert candidate(n = 20,requirements = [[19, 90], [16, 60], [13, 40], [10, 20], [7, 10], [4, 5], [2, 2], [0, 0]]) == 358259893\n assert candidate(n = 5,requirements = [[4, 10], [3, 6], [2, 3], [1, 1], [0, 0]]) == 1\n assert candidate(n = 15,requirements = [[14, 91], [13, 78], [12, 65], [11, 52], [10, 39], [9, 26], [8, 13], [7, 0], [6, 0], [5, 0], [4, 0], [3, 0], [2, 0], [1, 0], [0, 0]]) == 0\n assert candidate(n = 12,requirements = [[11, 40], [9, 25], [7, 15], [5, 10], [3, 5], [1, 2], [0, 0]]) == 0\n assert candidate(n = 7,requirements = [[6, 21], [5, 15], [4, 10], [3, 6], [2, 3], [1, 1], [0, 0]]) == 1\n assert candidate(n = 8,requirements = [[7, 18], [5, 10], [4, 7], [3, 4], [2, 3], [1, 2], [0, 0]]) == 0\n assert candidate(n = 10,requirements = [[9, 30], [7, 15], [5, 8], [3, 4], [1, 2], [0, 0]]) == 0\n assert candidate(n = 9,requirements = [[8, 20], [6, 12], [5, 8], [4, 5], [3, 3], [2, 2], [1, 1], [0, 0]]) == 8\n assert candidate(n = 6,requirements = [[5, 10], [3, 4], [2, 2], [1, 1], [0, 0]]) == 4\n assert candidate(n = 20,requirements = [[19, 171], [18, 153], [17, 136], [16, 119], [15, 102], [14, 85], [13, 68], [12, 51], [11, 34], [10, 17], [9, 0], [8, 0], [7, 0], [6, 0], [5, 0], [4, 0], [3, 0], [2, 0], [1, 0], [0, 0]]) == 0\n assert candidate(n = 15,requirements = [[14, 105], [11, 40], [8, 15], [6, 7], [3, 3], [2, 1], [1, 0], [0, 0]]) == 0\n assert candidate(n = 8,requirements = [[7, 28], [6, 21], [5, 15], [4, 10], [3, 6], [2, 3], [1, 1], [0, 0]]) == 1\n assert candidate(n = 8,requirements = [[7, 20], [6, 15], [5, 10], [4, 6], [3, 4], [2, 3], [1, 2], [0, 0]]) == 0\n assert candidate(n = 12,requirements = [[11, 45], [9, 25], [7, 15], [5, 8], [3, 4], [1, 2], [0, 0]]) == 0\n assert candidate(n = 9,requirements = [[8, 18], [6, 12], [4, 8], [2, 4], [0, 0]]) == 0\n assert candidate(n = 10,requirements = [[9, 35], [8, 25], [7, 20], [6, 15], [5, 10], [4, 6], [3, 4], [2, 3], [1, 2], [0, 0]]) == 0\n assert candidate(n = 25,requirements = [[24, 100], [15, 30], [16, 40], [12, 20], [13, 25], [8, 10], [9, 15], [6, 5], [7, 10], [4, 3], [5, 6], [2, 2], [3, 3], [17, 50], [18, 60], [19, 70], [20, 80], [21, 90], [22, 100], [23, 110], [1, 1], [0, 0]]) == 0\n assert candidate(n = 12,requirements = [[11, 66], [8, 30], [6, 15], [4, 7], [2, 2], [0, 0]]) == 0\n assert candidate(n = 8,requirements = [[7, 10], [4, 4], [5, 5], [2, 1], [3, 2], [6, 6], [1, 0], [0, 0]]) == 1\n assert candidate(n = 25,requirements = [[24, 150], [21, 105], [18, 70], [15, 45], [12, 30], [9, 20], [6, 15], [3, 10], [0, 0]]) == 0\n assert candidate(n = 9,requirements = [[8, 25], [7, 20], [6, 15], [5, 10], [4, 6], [3, 4], [2, 3], [1, 2], [0, 0]]) == 0\n assert candidate(n = 7,requirements = [[6, 15], [4, 8], [2, 4], [0, 0]]) == 0\n assert candidate(n = 6,requirements = [[5, 6], [4, 3], [3, 2], [2, 1], [1, 0], [0, 0]]) == 1\n assert candidate(n = 7,requirements = [[6, 10], [4, 5], [3, 3], [2, 1], [1, 0], [0, 0]]) == 6\n assert candidate(n = 10,requirements = [[9, 30], [5, 10], [6, 15], [3, 4], [4, 8], [2, 2], [7, 20], [8, 25], [1, 1], [0, 0]]) == 1\n assert candidate(n = 6,requirements = [[5, 10], [3, 5], [1, 2], [0, 0]]) == 0\n assert candidate(n = 6,requirements = [[5, 6], [3, 2], [2, 1], [1, 0], [0, 0]]) == 5\n assert candidate(n = 25,requirements = [[24, 250], [22, 170], [20, 100], [18, 60], [16, 40], [14, 20], [12, 10], [10, 6], [8, 4], [6, 3], [4, 2], [2, 1], [0, 0], [1, 1], [3, 3], [5, 5], [7, 7], [9, 9], [11, 11], [13, 13], [15, 15], [17, 17], [19, 19], [21, 21], [23, 23]]) == 0\n assert candidate(n = 10,requirements = [[9, 45], [7, 21], [5, 10], [4, 6], [3, 4], [2, 2], [1, 1], [0, 0]]) == 0\n assert candidate(n = 10,requirements = [[9, 25], [7, 15], [5, 10], [3, 5], [1, 2], [0, 0]]) == 0\n assert candidate(n = 8,requirements = [[7, 10], [5, 5], [3, 3], [1, 1], [0, 0]]) == 54\n assert candidate(n = 10,requirements = [[9, 28], [7, 15], [5, 6], [3, 3], [1, 1], [2, 2], [4, 4], [6, 8], [8, 20], [0, 0]]) == 1\n assert candidate(n = 6,requirements = [[5, 9], [4, 7], [3, 5], [2, 3], [1, 1], [0, 0]]) == 1\n assert candidate(n = 18,requirements = [[17, 60], [13, 30], [9, 15], [6, 10], [4, 5], [2, 2], [0, 0]]) == 217514306\n assert candidate(n = 7,requirements = [[6, 15], [5, 10], [4, 6], [3, 4], [2, 2], [1, 1], [0, 0]]) == 1\n assert candidate(n = 8,requirements = [[7, 21], [5, 10], [4, 6], [3, 4], [2, 2], [1, 1], [0, 0]]) == 3\n assert candidate(n = 15,requirements = [[14, 50], [12, 30], [10, 20], [8, 15], [6, 10], [4, 5], [2, 3], [0, 0]]) == 57024\n assert candidate(n = 8,requirements = [[7, 15], [3, 5], [5, 10], [2, 2], [1, 1], [0, 0]]) == 30\n assert candidate(n = 7,requirements = [[6, 15], [4, 10], [2, 3], [0, 0], [3, 4], [5, 9], [1, 1]]) == 0\n assert candidate(n = 20,requirements = [[19, 130], [17, 80], [15, 40], [13, 20], [11, 10], [9, 6], [7, 4], [5, 3], [3, 2], [1, 1], [0, 0], [2, 2], [4, 4], [6, 6], [8, 8], [10, 10], [12, 12], [14, 14], [16, 16], [18, 18]]) == 0\n assert candidate(n = 12,requirements = [[11, 66], [10, 55], [9, 45], [8, 36], [7, 28], [6, 21], [5, 15], [4, 10], [3, 6], [2, 3], [1, 1], [0, 0]]) == 1\n assert candidate(n = 6,requirements = [[5, 12], [4, 8], [3, 5], [2, 3], [1, 1], [0, 0]]) == 1\n assert candidate(n = 18,requirements = [[17, 63], [14, 42], [11, 28], [8, 21], [5, 14], [2, 7], [0, 0]]) == 0\n assert candidate(n = 15,requirements = [[14, 45], [11, 25], [8, 10], [5, 5], [2, 2], [0, 0]]) == 5518800\n assert candidate(n = 12,requirements = [[11, 28], [8, 15], [5, 8], [2, 3], [0, 0]]) == 51170\n assert candidate(n = 10,requirements = [[9, 45], [8, 36], [7, 28], [6, 21], [5, 15], [4, 10], [3, 6], [2, 3], [1, 1], [0, 0]]) == 1\n assert candidate(n = 25,requirements = [[24, 100], [20, 50], [15, 25], [11, 15], [7, 10], [5, 5], [3, 2], [1, 0], [0, 0]]) == 195391545\n assert candidate(n = 10,requirements = [[9, 35], [8, 25], [7, 18], [6, 12], [5, 8], [4, 5], [3, 3], [2, 2], [1, 1], [0, 0]]) == 0\n assert candidate(n = 8,requirements = [[7, 21], [4, 10], [3, 5], [2, 3], [1, 1], [0, 0]]) == 0\n assert candidate(n = 8,requirements = [[7, 10], [6, 5], [5, 2], [4, 1], [3, 0], [2, 0], [1, 0], [0, 0]]) == 1\n assert candidate(n = 9,requirements = [[8, 36], [7, 28], [6, 21], [5, 15], [4, 10], [3, 6], [2, 3], [1, 1], [0, 0]]) == 1\n assert candidate(n = 15,requirements = [[14, 105], [13, 84], [12, 63], [11, 42], [10, 28], [9, 21], [8, 15], [7, 10], [6, 6], [5, 4], [4, 2], [3, 1], [2, 1], [1, 0], [0, 0]]) == 0\n assert candidate(n = 12,requirements = [[11, 30], [8, 15], [5, 8], [3, 3], [1, 1], [0, 0]]) == 47250\n assert candidate(n = 20,requirements = [[19, 190], [18, 171], [17, 153], [16, 136], [15, 119], [14, 105], [13, 92], [12, 80], [11, 69], [10, 58], [9, 48], [8, 39], [7, 31], [6, 24], [5, 18], [4, 13], [3, 9], [2, 6], [1, 4], [0, 0]]) == 0\n assert candidate(n = 5,requirements = [[4, 6], [3, 4], [2, 3], [1, 2], [0, 0]]) == 0\n assert candidate(n = 8,requirements = [[7, 14], [5, 7], [3, 3], [1, 1], [0, 0]]) == 105\n assert candidate(n = 10,requirements = [[9, 45], [5, 15], [3, 5], [2, 3], [1, 1], [0, 0]]) == 0\n assert candidate(n = 8,requirements = [[7, 20], [5, 10], [3, 5], [1, 2], [0, 0], [6, 12], [4, 6]]) == 0\n assert candidate(n = 8,requirements = [[7, 21], [5, 12], [3, 6], [1, 3], [0, 0]]) == 0\n assert candidate(n = 9,requirements = [[8, 28], [6, 18], [4, 10], [2, 5], [0, 0]]) == 0\n assert candidate(n = 10,requirements = [[9, 40], [7, 25], [5, 15], [4, 10], [3, 6], [2, 4], [1, 2], [0, 0]]) == 0\n assert candidate(n = 6,requirements = [[5, 6], [3, 3], [1, 1], [2, 2], [4, 4], [0, 0]]) == 1\n assert candidate(n = 10,requirements = [[9, 20], [6, 10], [4, 5], [2, 2], [0, 0]]) == 2688\n assert candidate(n = 7,requirements = [[6, 15], [5, 10], [4, 6], [2, 3], [0, 0]]) == 4\n assert candidate(n = 5,requirements = [[4, 6], [3, 4], [2, 2], [1, 1], [0, 0]]) == 1\n assert candidate(n = 20,requirements = [[19, 80], [15, 40], [11, 20], [7, 10], [5, 5], [3, 2], [1, 0], [0, 0]]) == 208478921\n assert candidate(n = 15,requirements = [[14, 91], [12, 50], [10, 25], [8, 15], [6, 8], [4, 4], [2, 2], [0, 0]]) == 0\n assert candidate(n = 6,requirements = [[5, 15], [4, 10], [3, 6], [2, 3], [1, 1], [0, 0]]) == 1\n assert candidate(n = 6,requirements = [[5, 6], [3, 3], [2, 1], [1, 0], [0, 0]]) == 4\n assert candidate(n = 10,requirements = [[9, 20], [8, 15], [7, 10], [6, 5], [5, 3], [4, 2], [3, 1], [2, 0], [1, 0], [0, 0]]) == 1\n assert candidate(n = 20,requirements = [[19, 150], [10, 50], [11, 60], [7, 20], [8, 30], [5, 10], [6, 15], [3, 5], [4, 10], [1, 2], [2, 3], [12, 70], [13, 80], [14, 90], [15, 100], [16, 110], [17, 120], [18, 130], [0, 0]]) == 0\n"}, "metadata": {"canonical_parameter_names": ["n", "requirements"], "leetcode_dataset_entry_point": "Solution().numberOfPermutations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int numberOfPermutations(int n, vector>& requirements) {", "container": "Solution", "callable": "numberOfPermutations", "parameters": [{"name": "n", "type": "int"}, {"name": "requirements", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3194, "task_id": "minimum-average-of-smallest-and-largest-elements", "difficulty": "Easy", "problem_description": "You have an array of floating point numbers averages which is initially empty. You are given an array nums of n integers where n is even.\nYou repeat the following procedure n / 2 times:\n\nRemove the smallest element, minElement, and the largest element maxElement, from nums.\nAdd (minElement + maxElement) / 2 to averages.\n\nReturn the minimum element in averages.\n \nExample 1:\n\nInput: nums = [7,8,3,4,15,13,4,1]\nOutput: 5.5\nExplanation:\n\n\n\nstep\nnums\naverages\n\n\n0\n[7,8,3,4,15,13,4,1]\n[]\n\n\n1\n[7,8,3,4,13,4]\n[8]\n\n\n2\n[7,8,4,4]\n[8,8]\n\n\n3\n[7,4]\n[8,8,6]\n\n\n4\n[]\n[8,8,6,5.5]\n\n\n\nThe smallest element of averages, 5.5, is returned.\nExample 2:\n\nInput: nums = [1,9,8,3,10,5]\nOutput: 5.5\nExplanation:\n\n\n\nstep\nnums\naverages\n\n\n0\n[1,9,8,3,10,5]\n[]\n\n\n1\n[9,8,3,5]\n[5.5]\n\n\n2\n[8,5]\n[5.5,6]\n\n\n3\n[]\n[5.5,6,6.5]\n\n\n\n\nExample 3:\n\nInput: nums = [1,2,3,7,8,9]\nOutput: 5.0\nExplanation:\n\n\n\nstep\nnums\naverages\n\n\n0\n[1,2,3,7,8,9]\n[]\n\n\n1\n[2,3,7,8]\n[5]\n\n\n2\n[3,7]\n[5,5]\n\n\n3\n[]\n[5,5,5]\n\n\n\n\n \nConstraints:\n\n2 <= n == nums.length <= 50\nn is even.\n1 <= nums[i] <= 50\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [2, 1, 5, 4, 9, 8]) == 4.5\n assert candidate(nums = [1, 9, 8, 3, 10, 5]) == 5.5\n assert candidate(nums = [10, 20, 30, 40, 50, 60]) == 35.0\n assert candidate(nums = [25, 25, 25, 25, 25, 25]) == 25.0\n assert candidate(nums = [2, 3, 10, 1, 11, 5, 4, 8]) == 4.5\n assert candidate(nums = [50, 49, 48, 47, 46, 45]) == 47.5\n assert candidate(nums = [2, 4, 6, 8, 10, 12]) == 7.0\n assert candidate(nums = [1, 5, 9, 13, 17, 21]) == 11.0\n assert candidate(nums = [2, 3, 1, 4, 6, 5]) == 3.5\n assert candidate(nums = [1, 3, 5, 7, 9, 11]) == 6.0\n assert candidate(nums = [2, 2, 2, 2, 2, 2]) == 2.0\n assert candidate(nums = [1, 2, 3, 4, 5, 6]) == 3.5\n assert candidate(nums = [50, 1, 25, 2, 50, 24]) == 24.5\n assert candidate(nums = [42, 3, 51, 6, 32, 28]) == 24.0\n assert candidate(nums = [30, 20, 10, 40, 60, 50]) == 35.0\n assert candidate(nums = [25, 10, 30, 5, 40, 15]) == 20.0\n assert candidate(nums = [7, 8, 3, 4, 15, 13, 4, 1]) == 5.5\n assert candidate(nums = [5, 5, 5, 5, 5, 5]) == 5.0\n assert candidate(nums = [45, 30, 35, 20, 50, 40]) == 35.0\n assert candidate(nums = [50, 1, 50, 2, 50, 3]) == 25.5\n assert candidate(nums = [15, 15, 15, 15, 15, 15]) == 15.0\n assert candidate(nums = [1, 2, 3, 7, 8, 9]) == 5.0\n assert candidate(nums = [10, 20, 30, 40]) == 25.0\n assert candidate(nums = [25, 20, 15, 10, 5, 0, -5, -10, -15, -20, -25, -30, -35, -40, -45, -50]) == -12.5\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36]) == 19.5\n assert candidate(nums = [7, 3, 9, 1, 5, 11, 13, 2, 8, 6, 10, 4]) == 6.5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 5.5\n assert candidate(nums = [48, 46, 44, 42, 40, 38, 36, 34]) == 41.0\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29]) == 15.0\n assert candidate(nums = [27, 37, 23, 33, 29, 39, 21, 31]) == 30.0\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 2.0\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 1, 8, 15]) == 18.0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 6.5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 8.5\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 7.0\n assert candidate(nums = [45, 30, 15, 5, 50, 35, 20, 10, 40, 25]) == 27.5\n assert candidate(nums = [10, 20, 30, 40, 50, 1]) == 25.0\n assert candidate(nums = [10, 20, 30, 40, 50, 1, 2, 3, 4, 5]) == 7.5\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80]) == 45.0\n assert candidate(nums = [24, 12, 36, 6, 48, 24]) == 24.0\n assert candidate(nums = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]) == 15.5\n assert candidate(nums = [1, 99, 2, 98, 3, 97, 4, 96, 5, 95, 6, 94]) == 50.0\n assert candidate(nums = [23, 17, 11, 5, 31, 29, 25, 19, 35, 33, 37, 13]) == 21.0\n assert candidate(nums = [30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]) == 30.0\n assert candidate(nums = [49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30]) == 39.5\n assert candidate(nums = [20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10]) == 15.0\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 3.0\n assert candidate(nums = [29, 10, 34, 15, 40, 5, 30, 20]) == 22.0\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128]) == 68.0\n assert candidate(nums = [49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38]) == 43.5\n assert candidate(nums = [23, 29, 27, 25, 21, 28, 26, 22, 24, 20, 19, 30, 18, 31, 17, 32, 16, 33, 15, 34, 14, 35, 13, 36, 12, 37, 11, 38, 10, 39, 9, 40, 8, 41, 7, 42, 6, 43, 5, 44, 4, 45, 3, 46, 2, 47, 1, 48, 50]) == 25.0\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == 42.0\n assert candidate(nums = [4, 8, 12, 16, 20, 24, 28, 32]) == 18.0\n assert candidate(nums = [17, 18, 19, 20, 21, 22, 23, 24, 25, 26]) == 21.5\n assert candidate(nums = [48, 49, 50, 1, 2, 3, 47, 46, 45, 44]) == 25.5\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 5.5\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64]) == 36.0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 10.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == 20.0\n assert candidate(nums = [50, 25, 1, 30, 45, 20, 15, 40]) == 25.5\n assert candidate(nums = [45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45]) == 45.0\n assert candidate(nums = [1, 50, 2, 49, 3, 48, 4, 47, 5, 46]) == 25.5\n assert candidate(nums = [21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 25.5\n assert candidate(nums = [28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28]) == 28.0\n assert candidate(nums = [49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38]) == 43.5\n assert candidate(nums = [23, 46, 69, 92, 115, 138, 161, 184, 207, 230, 253, 276, 299, 322, 345, 368]) == 195.5\n assert candidate(nums = [29, 29, 29, 29, 1, 1, 1, 1, 14, 14, 14, 14]) == 14.0\n assert candidate(nums = [29, 19, 28, 18, 27, 17, 26, 16, 25, 15, 24, 14]) == 21.5\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70]) == 38.5\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41]) == 45.5\n assert candidate(nums = [34, 34, 12, 12, 56, 56, 28, 28, 42, 42]) == 34.0\n assert candidate(nums = [3, 11, 7, 15, 9, 17, 5, 13]) == 10.0\n assert candidate(nums = [1, 50, 2, 49, 3, 48, 4, 47, 5, 46, 6, 45, 7, 44, 8, 43, 9, 42, 10, 41]) == 25.5\n assert candidate(nums = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40]) == 22.0\n assert candidate(nums = [47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47]) == 47.0\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 3.0\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == 8.0\n assert candidate(nums = [20, 10, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 65.0\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 12, 20]) == 22.0\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85]) == 50.0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5.0\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41]) == 45.5\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19]) == 10.5\n assert candidate(nums = [15, 20, 5, 10, 25, 30, 35, 40, 50, 55]) == 27.5\n assert candidate(nums = [30, 30, 29, 29, 28, 28, 27, 27, 26, 26, 25, 25]) == 27.5\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 55.0\n assert candidate(nums = [45, 42, 43, 41, 44, 46, 47, 48]) == 44.5\n assert candidate(nums = [29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29]) == 29.0\n assert candidate(nums = [3, 9, 15, 21, 27, 33, 39, 45, 51, 57]) == 30.0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 5.5\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 12.0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15]) == 8.0\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 21.0\n assert candidate(nums = [28, 22, 16, 10, 4, 32, 26, 20, 14, 8, 30, 12]) == 18.0\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 11.0\n assert candidate(nums = [22, 38, 26, 40, 24, 36, 28, 34]) == 31.0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1.0\n assert candidate(nums = [45, 46, 47, 48, 49, 50, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 8.5\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 65.0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 10.5\n assert candidate(nums = [15, 25, 35, 5, 30, 20, 40, 10]) == 22.5\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 4, 8, 12]) == 32.5\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == 16.5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 25.5\n assert candidate(nums = [2, 6, 10, 14, 18, 22, 26, 30, 34, 38]) == 20.0\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 1, 8, 15, 22, 29]) == 21.5\n assert candidate(nums = [10, 20, 30, 40, 50, 1]) == 25.0\n assert candidate(nums = [1, 50, 2, 49, 3, 48, 4, 47]) == 25.5\n assert candidate(nums = [4, 8, 15, 16, 23, 42, 1, 2, 3, 5, 7, 11, 13, 17, 19, 29]) == 11.0\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9]) == 4.0\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]) == 13.0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 30]) == 15.5\n assert candidate(nums = [42, 43, 44, 45, 46, 47, 48, 49, 50, 1]) == 25.5\n assert candidate(nums = [10, 20, 30, 40, 50, 1, 2, 3, 4, 5]) == 7.5\n assert candidate(nums = [10, 20, 30, 40, 50, 5, 15, 25]) == 22.5\n assert candidate(nums = [17, 18, 19, 20, 21, 22, 23, 24, 25, 26]) == 21.5\n assert candidate(nums = [5, 15, 25, 35, 45, 50, 40, 30, 20, 10]) == 27.5\n assert candidate(nums = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45]) == 22.5\n assert candidate(nums = [12, 24, 36, 48, 18, 30, 42, 54]) == 33.0\n assert candidate(nums = [8, 24, 3, 12, 18, 6, 21, 9, 15, 1, 19, 7, 22, 10, 16, 4, 23, 2, 11, 13, 17, 14, 25, 20, 5]) == 13.0\n assert candidate(nums = [50, 1, 49, 2, 48, 3, 47, 4, 46, 5, 45, 6]) == 25.5\n assert candidate(nums = [10, 20, 30, 40, 50, 5, 15, 25, 35, 45]) == 27.5\n assert candidate(nums = [25, 26, 27, 28, 29, 30, 31, 32, 33, 34]) == 29.5\n assert candidate(nums = [25, 24, 23, 22, 21, 20, 19, 18]) == 21.5\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 50]) == 28.5\n assert candidate(nums = [21, 18, 15, 12, 9, 6, 3, 0]) == 10.5\n assert candidate(nums = [49, 2, 48, 3, 47, 4, 46, 5, 45, 6]) == 25.5\n assert candidate(nums = [45, 44, 43, 42, 41, 40, 39, 38, 37, 36]) == 40.5\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23]) == 12.0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80]) == 45.0\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 2.0\n assert candidate(nums = [33, 17, 47, 31, 27, 13, 41, 23, 39, 29, 35, 19]) == 29.0\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minimumAverage", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "double minimumAverage(vector& nums) {", "container": "Solution", "callable": "minimumAverage", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "double", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3195, "task_id": "find-the-minimum-area-to-cover-all-ones-i", "difficulty": "Medium", "problem_description": "You are given a 2D binary array grid. Find a rectangle with horizontal and vertical sides with the smallest area, such that all the 1's in grid lie inside this rectangle.\nReturn the minimum possible area of the rectangle.\n \nExample 1:\n\nInput: grid = [[0,1,0],[1,0,1]]\nOutput: 6\nExplanation:\n\nThe smallest rectangle has a height of 2 and a width of 3, so it has an area of 2 * 3 = 6.\n\nExample 2:\n\nInput: grid = [[1,0],[0,0]]\nOutput: 1\nExplanation:\n\nThe smallest rectangle has both height and width 1, so its area is 1 * 1 = 1.\n\n \nConstraints:\n\n1 <= grid.length, grid[i].length <= 1000\ngrid[i][j] is either 0 or 1.\nThe input is generated such that there is at least one 1 in grid.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[0, 0, 0], [0, 1, 0], [0, 0, 0]]) == 1\n assert candidate(grid = [[0, 0, 0], [0, 0, 0], [1, 0, 0]]) == 1\n assert candidate(grid = [[1, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 1]]) == 20\n assert candidate(grid = [[0, 0, 0, 1], [0, 1, 0, 0], [1, 0, 0, 0]]) == 12\n assert candidate(grid = [[1, 0], [0, 0]]) == 1\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 9\n assert candidate(grid = [[1, 0, 1, 0, 1]]) == 5\n assert candidate(grid = [[1], [0], [1], [0], [1]]) == 5\n assert candidate(grid = [[1, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 1]]) == 16\n assert candidate(grid = [[0, 1, 0, 1], [1, 1, 1, 1], [0, 1, 0, 1]]) == 12\n assert candidate(grid = [[0, 0, 1, 0], [0, 1, 1, 0], [1, 1, 1, 1]]) == 12\n assert candidate(grid = [[0], [1], [0]]) == 1\n assert candidate(grid = [[1, 1, 1], [1, 0, 1], [1, 1, 1]]) == 9\n assert candidate(grid = [[0, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 0]]) == 4\n assert candidate(grid = [[1, 0, 0, 1], [0, 0, 0, 0], [1, 0, 0, 1]]) == 12\n assert candidate(grid = [[1, 1], [1, 1]]) == 4\n assert candidate(grid = [[0, 1, 0], [1, 0, 1]]) == 6\n assert candidate(grid = [[1]]) == 1\n assert candidate(grid = [[0, 0, 0, 1], [0, 1, 1, 1], [0, 0, 0, 1]]) == 9\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 0, 0, 0, 0], [1, 0, 1, 0, 1]]) == 15\n assert candidate(grid = [[0, 0, 1, 0], [0, 0, 0, 0], [1, 0, 0, 1]]) == 12\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 0, 0], [0, 1, 0, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 1, 0, 0], [0, 1, 1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == 20\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == 100\n assert candidate(grid = [[0, 1, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 1, 0]]) == 49\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == 25\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0, 0], [0, 0, 1, 0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 12\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 9\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 0, 0], [0, 0, 1, 0, 0, 1, 0, 0], [0, 0, 1, 0, 0, 1, 0, 0], [0, 0, 1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == 16\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 1, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 1, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == 30\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 1, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 1, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 64\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0], [0, 1, 0, 1, 0, 0], [0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0]]) == 9\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 1, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 1, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 56\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 361\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]]) == 5\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1]]) == 49\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 1, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 1, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == 90\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 72\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0], [0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == 20\n assert candidate(grid = [[0, 0, 1, 0, 0], [0, 1, 1, 1, 0], [1, 1, 1, 1, 1], [0, 1, 1, 1, 0], [0, 0, 1, 0, 0]]) == 25\n assert candidate(grid = [[0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0]]) == 81\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 20\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0]]) == 64\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 1, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == 25\n assert candidate(grid = [[1, 1, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 1, 1], [0, 0, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0], [1, 1, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 1, 1]]) == 49\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 0, 0], [0, 1, 0, 1, 1, 0, 1], [0, 0, 1, 1, 1, 1, 0], [0, 0, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == 24\n assert candidate(grid = [[1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 1, 1, 1]]) == 35\n assert candidate(grid = [[1, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0], [1, 0, 0, 0, 0, 1]]) == 30\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 1, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 1, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 1, 0, 0, 0]]) == 18\n assert candidate(grid = [[1, 1, 0, 0, 0, 1], [1, 1, 0, 0, 0, 1], [0, 0, 0, 1, 1, 0], [0, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 0]]) == 30\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == 165\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0], [0, 1, 0, 1, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == 9\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 1, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == 81\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 32\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 1, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 1, 0, 0, 0, 1, 0], [1, 0, 0, 0, 0, 0, 1]]) == 42\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == 420\n assert candidate(grid = [[0, 0, 1, 0, 0], [0, 0, 0, 0, 0], [1, 0, 0, 0, 1], [0, 0, 0, 0, 0], [0, 1, 1, 1, 0]]) == 25\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == 100\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 1]]) == 35\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0], [1, 0, 1, 1, 0, 1], [0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1]]) == 42\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 1, 0, 1, 0, 0], [0, 1, 0, 0, 0, 1, 0], [0, 0, 1, 0, 1, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == 25\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 72\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 4\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 1, 0, 0], [0, 0, 0, 1, 0, 0, 1, 0, 0], [0, 0, 0, 1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 12\n assert candidate(grid = [[1, 0, 0, 0, 1], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [1, 0, 0, 0, 1], [0, 0, 1, 0, 0]]) == 25\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 0, 0, 1, 0], [0, 1, 1, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 0, 0], [0, 0, 0, 1, 1, 0, 0]]) == 25\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 1, 0], [0, 1, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 1, 0], [0, 1, 0, 0, 1, 0]]) == 20\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 81\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == 20\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 0, 0], [0, 1, 1, 1, 1, 0], [0, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0]]) == 12\n assert candidate(grid = [[1, 0, 0, 0, 1, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 1, 0, 0, 0, 1]]) == 45\n assert candidate(grid = [[1, 1, 0, 0, 0, 1], [1, 1, 0, 0, 1, 1], [0, 0, 0, 1, 1, 0], [0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 0, 1]]) == 30\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]]) == 25\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 25\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 1, 0, 0], [0, 0, 1, 1, 0, 0, 0], [0, 0, 1, 1, 0, 0, 0], [0, 1, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == 16\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 1]]) == 63\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0, 0], [0, 1, 1, 1, 0, 1, 1, 0, 0], [0, 1, 0, 1, 1, 1, 0, 1, 0], [0, 1, 1, 1, 0, 1, 1, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 49\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().minimumArea", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumArea(vector>& grid) {", "container": "Solution", "callable": "minimumArea", "parameters": [{"name": "grid", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3196, "task_id": "maximize-total-cost-of-alternating-subarrays", "difficulty": "Medium", "problem_description": "You are given an integer array nums with length n.\nThe cost of a subarray nums[l..r], where 0 <= l <= r < n, is defined as:\ncost(l, r) = nums[l] - nums[l + 1] + ... + nums[r] * (−1)r − l\nYour task is to split nums into subarrays such that the total cost of the subarrays is maximized, ensuring each element belongs to exactly one subarray.\nFormally, if nums is split into k subarrays, where k > 1, at indices i1, i2, ..., ik − 1, where 0 <= i1 < i2 < ... < ik - 1 < n - 1, then the total cost will be:\ncost(0, i1) + cost(i1 + 1, i2) + ... + cost(ik − 1 + 1, n − 1)\nReturn an integer denoting the maximum total cost of the subarrays after splitting the array optimally.\nNote: If nums is not split into subarrays, i.e. k = 1, the total cost is simply cost(0, n - 1).\n \nExample 1:\n\nInput: nums = [1,-2,3,4]\nOutput: 10\nExplanation:\nOne way to maximize the total cost is by splitting [1, -2, 3, 4] into subarrays [1, -2, 3] and [4]. The total cost will be (1 + 2 + 3) + 4 = 10.\n\nExample 2:\n\nInput: nums = [1,-1,1,-1]\nOutput: 4\nExplanation:\nOne way to maximize the total cost is by splitting [1, -1, 1, -1] into subarrays [1, -1] and [1, -1]. The total cost will be (1 + 1) + (1 + 1) = 4.\n\nExample 3:\n\nInput: nums = [0]\nOutput: 0\nExplanation:\nWe cannot split the array further, so the answer is 0.\n\nExample 4:\n\nInput: nums = [1,-1]\nOutput: 2\nExplanation:\nSelecting the whole array gives a total cost of 1 + 1 = 2, which is the maximum.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n-109 <= nums[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, -3, 8, 7, -2, 6]) == 31\n assert candidate(nums = [5, -3, 2, 7, -6, 1]) == 24\n assert candidate(nums = [5, -3, 2, -4, 6]) == 20\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [1, -1, 1, -1]) == 4\n assert candidate(nums = [1, -2, 3, 4]) == 10\n assert candidate(nums = [1, -1]) == 2\n assert candidate(nums = [1000000000, -1000000000, 1000000000, -1000000000, 1000000000]) == 5000000000\n assert candidate(nums = [-1, -2, -3, -4, -5]) == 1\n assert candidate(nums = [-5, -3, -8, -7, -2, -6]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5]) == 15\n assert candidate(nums = [-5, 3, -2, 7, -6, 1]) == 14\n assert candidate(nums = [5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == 164\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(nums = [0]) == 0\n assert candidate(nums = [5, 3, -5, 2, -3, 3, 9, -1]) == 31\n assert candidate(nums = [-1, -2, -3, -4]) == 2\n assert candidate(nums = [1, 2]) == 3\n assert candidate(nums = [1000000000, -1000000000, 1000000000, -1000000000]) == 4000000000\n assert candidate(nums = [0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10]) == 100\n assert candidate(nums = [10, -5, 10, -5, 10, -5, 10, -5, 10, -5, 10, -5]) == 90\n assert candidate(nums = [-1, 0, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, 8, -9, 9, -10, 10, -11, 11, -12, 12, -13, 13, -14]) == 194\n assert candidate(nums = [0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1]) == 10\n assert candidate(nums = [-1000000000, 1000000000, -1000000000, 1000000000, -1000000000, 1000000000, -1000000000, 1000000000]) == 6000000000\n assert candidate(nums = [5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5]) == 140\n assert candidate(nums = [1000000000, -1000000000, 1000000000, -1000000000, 1000000000, -1000000000, 1000000000, -1000000000, 1000000000]) == 9000000000\n assert candidate(nums = [5, 3, 1, -2, -4, -6, 7, 9, -11, 13]) == 53\n assert candidate(nums = [1000000000, 1000000000, -1000000000, -1000000000, 1000000000, 1000000000, -1000000000, -1000000000]) == 4000000000\n assert candidate(nums = [1, 2, -1, 3, -4, 5, -6, 7, -8]) == 37\n assert candidate(nums = [-5, 4, -3, 2, -1, 0, 1, -2, 3, -4]) == 15\n assert candidate(nums = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000]) == 5500\n assert candidate(nums = [1000000000, -999999999, 999999998, -999999997, 999999996, -999999995]) == 5999999985\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 44\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 465\n assert candidate(nums = [1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, -5, -4, -3, -2, -1]) == 36\n assert candidate(nums = [9, -8, 7, -6, 5, -4, 3, -2, 1, 0, -1, 2, -3, 4, -5, 6, -7, 8, -9, 10]) == 100\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 20\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20]) == 210\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 820\n assert candidate(nums = [-10, 20, -30, 40, -50, 60, -70, 80, -90, 100]) == 530\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20]) == 208\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 20\n assert candidate(nums = [10, -1, 3, -2, 15, -8, 7, -6, 5, -4]) == 61\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50]) == 300\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16]) == 134\n assert candidate(nums = [0, 1, -1, 0, 1, -1, 0, 1, -1, 0]) == 6\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20, 21, -22, 23, -24, 25, -26, 27, -28, 29, -30, 31]) == 496\n assert candidate(nums = [1, -3, 2, -4, 3, -5, 4, -6, 5, -7, 6, -8, 7, -9, 8, -10]) == 88\n assert candidate(nums = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100]) == 550\n assert candidate(nums = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5]) == 18\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991]) == 9999999955\n assert candidate(nums = [100, -99, 100, -99, 100, -99, 100, -99, 100, -99, 100, -99, 100, -99, 100, -99]) == 1592\n assert candidate(nums = [-1000000000, 999999999, -999999998, 999999997, -999999996, 999999995]) == 3999999985\n assert candidate(nums = [1000000000, 2000000000, 3000000000, 4000000000, 5000000000, 6000000000, 7000000000, 8000000000, 9000000000, 10000000000]) == 55000000000\n assert candidate(nums = [1, -3, 5, -7, 9, -11, 13, -15, 17]) == 81\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(nums = [50, -30, 20, -10, 0, 10, -20, 30, -40, 50]) == 260\n assert candidate(nums = [1000000000, -500000000, 1000000000, -500000000, 1000000000, -500000000, 1000000000, -500000000, 1000000000, -500000000]) == 7500000000\n assert candidate(nums = [-1, -3, -5, -7, -9, -11, -13, -15, -17, -19, -21, -23, -25, -27, -29, -31, -33, -35, -37, -39]) == 20\n assert candidate(nums = [10, -5, 3, -8, 2, 1, -4, 6, -7, 9]) == 55\n assert candidate(nums = [10, -1, 100, -10, 1000, -100, 10000, -1000, 100000, -10000]) == 122221\n assert candidate(nums = [-1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000]) == 6000\n assert candidate(nums = [100, 200, -300, 400, -500, 600, -700, 800, -900, 1000]) == 5500\n assert candidate(nums = [1000000000, 500000000, -500000000, 250000000, -250000000, 125000000, -125000000, 62500000, -62500000, 31250000]) == 2906250000\n assert candidate(nums = [-10, -20, 30, -40, 50, -60, 70, -80, 90, -100]) == 530\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]) == 110\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == 15\n assert candidate(nums = [1, 3, -5, 7, -9, 11, -13, 15, -17, 19]) == 100\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 120\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [1000000000, 2000000000, -3000000000, 4000000000, -5000000000, 6000000000]) == 21000000000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1]) == 60\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10]) == 55\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12]) == 76\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, -1000, -900, -800, -700, -600, -500, -400, -300, -200, -100]) == 6000\n assert candidate(nums = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5]) == 12\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [5, -3, 8, 7, -2, 6, -1, 4, 3, -5, 2, -8, 9, -4, 7, -6, 1, -2, 3, -10]) == 96\n assert candidate(nums = [1000000000, 1000000000, -1000000000, -1000000000, 1000000000, 1000000000]) == 4000000000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(nums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1]) == -5\n assert candidate(nums = [1, 2, -3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14]) == 99\n assert candidate(nums = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100]) == 550\n assert candidate(nums = [100, -50, 50, -50, 50, -50, 50, -50, 50, -50]) == 550\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, -1000000000, -1000000000, -1000000000, -1000000000, -1000000000]) == 6000000000\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15]) == 6\n assert candidate(nums = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000, 1100, -1200, 1300, -1400, 1500, -1600, 1700, -1800, 1900, -2000]) == 21000\n assert candidate(nums = [1, 2, 3, 4, 5, -5, -4, -3, -2, -1]) == 18\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50]) == 250\n assert candidate(nums = [500000000, -500000000, 500000000, -500000000, 500000000, -500000000, 500000000, -500000000, 500000000, -500000000]) == 5000000000\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 5\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 10\n assert candidate(nums = [9, -7, 5, -3, 1, -8, 6, -4, 2, -9, 7, -5, 3, -1, 0]) == 70\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 0\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == 30\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 550\n assert candidate(nums = [1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1]) == 11\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 10\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 16\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15]) == 120\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == 50\n assert candidate(nums = [-9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 40\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maximumTotalCost", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "long long maximumTotalCost(vector& nums) {", "container": "Solution", "callable": "maximumTotalCost", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "long long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3197, "task_id": "find-the-minimum-area-to-cover-all-ones-ii", "difficulty": "Hard", "problem_description": "You are given a 2D binary array grid. You need to find 3 non-overlapping rectangles having non-zero areas with horizontal and vertical sides such that all the 1's in grid lie inside these rectangles.\nReturn the minimum possible sum of the area of these rectangles.\nNote that the rectangles are allowed to touch.\n \nExample 1:\n\nInput: grid = [[1,0,1],[1,1,1]]\nOutput: 5\nExplanation:\n\n\nThe 1's at (0, 0) and (1, 0) are covered by a rectangle of area 2.\nThe 1's at (0, 2) and (1, 2) are covered by a rectangle of area 2.\nThe 1 at (1, 1) is covered by a rectangle of area 1.\n\n\nExample 2:\n\nInput: grid = [[1,0,1,0],[0,1,0,1]]\nOutput: 5\nExplanation:\n\n\nThe 1's at (0, 0) and (0, 2) are covered by a rectangle of area 3.\nThe 1 at (1, 1) is covered by a rectangle of area 1.\nThe 1 at (1, 3) is covered by a rectangle of area 1.\n\n\n \nConstraints:\n\n1 <= grid.length, grid[i].length <= 30\ngrid[i][j] is either 0 or 1.\nThe input is generated such that there are at least three 1's in grid.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 0, 1, 0], [0, 1, 0, 1]]) == 5\n assert candidate(grid = [[1, 1, 0, 0, 1], [1, 1, 0, 0, 1], [0, 0, 1, 1, 0], [0, 0, 1, 1, 0]]) == 10\n assert candidate(grid = [[1, 0, 0, 0, 1], [0, 1, 1, 0, 0], [0, 1, 1, 0, 0], [1, 0, 0, 1, 0]]) == 13\n assert candidate(grid = [[1, 0, 0, 1], [0, 1, 1, 0], [0, 1, 1, 0], [1, 0, 0, 1]]) == 12\n assert candidate(grid = [[1, 0, 1], [1, 1, 1]]) == 5\n assert candidate(grid = [[1, 1, 1, 0, 0], [1, 1, 1, 0, 0], [0, 0, 0, 1, 1], [0, 0, 0, 1, 1], [0, 0, 0, 1, 1]]) == 12\n assert candidate(grid = [[1, 0, 0, 1, 0, 0, 1], [0, 1, 1, 0, 0, 1, 0], [0, 1, 1, 0, 0, 1, 0], [1, 0, 0, 1, 0, 0, 1], [0, 0, 0, 0, 1, 0, 0]]) == 25\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == 42\n assert candidate(grid = [[1, 0, 0, 0, 1, 0, 1], [0, 1, 1, 0, 0, 1, 0], [0, 1, 1, 0, 0, 0, 1], [1, 0, 0, 1, 0, 1, 1]]) == 24\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1], [0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1]]) == 37\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == 36\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 1, 1, 1, 1, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == 51\n assert candidate(grid = [[0, 0, 1, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 1, 1, 0, 0, 1, 0, 0], [0, 1, 0, 0, 1, 0, 1, 0, 0, 1], [0, 0, 1, 1, 1, 1, 1, 1, 0, 0], [0, 1, 0, 0, 1, 0, 1, 0, 0, 1], [0, 0, 0, 1, 1, 0, 0, 1, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 1, 0]]) == 53\n assert candidate(grid = [[1, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 1], [0, 0, 1, 1, 0, 0], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1]]) == 26\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 27\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 1, 0], [0, 0, 1, 0, 1, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 1, 0, 1, 0, 0], [0, 1, 0, 0, 0, 1, 0], [1, 0, 0, 0, 0, 0, 1]]) == 37\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 1], [0, 1, 1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 1, 0], [1, 0, 0, 0, 0, 0, 0, 1]]) == 44\n assert candidate(grid = [[1, 1, 0, 0, 0, 0, 1, 1], [0, 0, 1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 1, 0, 0], [1, 1, 0, 0, 0, 0, 1, 1]]) == 48\n assert candidate(grid = [[1, 1, 0, 0, 0, 0, 0, 1], [0, 0, 1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 0, 0], [0, 0, 0, 0, 1, 1, 0, 0]]) == 16\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 1]]) == 36\n assert candidate(grid = [[1, 1, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 1, 1], [0, 0, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0], [1, 1, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 1, 1]]) == 30\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 0, 1, 1, 1], [0, 0, 0, 1, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1]]) == 22\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1]]) == 47\n assert candidate(grid = [[1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0]]) == 20\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 1], [0, 0, 1, 0, 0, 1, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0], [1, 0, 0, 1, 1, 0, 0, 1], [0, 1, 1, 0, 0, 1, 1, 0], [0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 1, 0, 0, 1, 0, 0], [1, 0, 0, 0, 0, 0, 0, 1]]) == 52\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1], [0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1], [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1]]) == 34\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 1, 0, 1], [0, 1, 1, 1, 0, 1, 0, 1, 0], [0, 1, 1, 1, 0, 1, 0, 1, 0], [1, 0, 0, 0, 1, 0, 1, 0, 1], [0, 1, 1, 1, 0, 1, 0, 1, 0], [0, 1, 1, 1, 0, 1, 0, 1, 0]]) == 47\n assert candidate(grid = [[0, 0, 1, 0, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 0]]) == 24\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 45\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 43\n assert candidate(grid = [[1, 0, 0, 0, 1, 0, 0, 0, 1], [0, 1, 1, 1, 0, 1, 1, 1, 0], [0, 1, 1, 1, 0, 1, 1, 1, 0], [1, 0, 0, 0, 1, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 1, 0, 0, 0, 1], [0, 1, 1, 1, 0, 1, 1, 1, 0], [0, 1, 1, 1, 0, 1, 1, 1, 0], [1, 0, 0, 0, 1, 0, 0, 0, 1]]) == 72\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 1], [0, 1, 1, 0, 1, 1, 0, 0], [0, 1, 1, 0, 1, 1, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0], [0, 1, 1, 0, 1, 1, 0, 0], [0, 1, 1, 0, 1, 1, 0, 0], [1, 0, 0, 0, 0, 0, 0, 1]]) == 39\n assert candidate(grid = [[1, 0, 0, 0, 1, 0, 1], [0, 1, 1, 1, 0, 1, 0], [1, 0, 0, 0, 1, 0, 1], [0, 1, 1, 1, 0, 1, 0]]) == 24\n assert candidate(grid = [[0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0]]) == 21\n assert candidate(grid = [[1, 1, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0], [1, 0, 0, 0, 1, 0], [0, 1, 1, 1, 0, 1], [0, 0, 1, 0, 0, 1]]) == 25\n assert candidate(grid = [[1, 0, 0, 1, 0, 0, 0, 1], [0, 1, 1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1, 1, 0], [1, 0, 0, 1, 0, 0, 0, 1]]) == 24\n assert candidate(grid = [[1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0], [0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1], [0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0], [1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1]]) == 37\n assert candidate(grid = [[1, 1, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 1, 1], [0, 0, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0], [1, 1, 0, 0, 0, 1, 1]]) == 26\n assert candidate(grid = [[0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0]]) == 24\n assert candidate(grid = [[1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0]]) == 12\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0]]) == 20\n assert candidate(grid = [[1, 0, 0, 1, 0, 0, 1], [0, 1, 1, 0, 1, 1, 0], [0, 1, 1, 0, 1, 1, 0], [1, 0, 0, 1, 0, 0, 1]]) == 24\n assert candidate(grid = [[1, 1, 0, 0, 0, 0, 1, 1], [0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 0], [0, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0], [1, 1, 0, 0, 0, 0, 1, 1]]) == 52\n assert candidate(grid = [[1, 1, 1, 0, 0, 0, 0, 1, 1, 1], [1, 1, 1, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 1, 1, 1], [1, 1, 1, 0, 0, 0, 0, 1, 1, 1]]) == 52\n assert candidate(grid = [[1, 0, 0, 0, 0, 1, 0, 1, 0, 1], [0, 1, 1, 0, 0, 1, 0, 0, 1, 0], [0, 1, 1, 0, 0, 0, 1, 0, 0, 1], [1, 0, 0, 1, 0, 1, 1, 0, 0, 0]]) == 31\n assert candidate(grid = [[1, 1, 0, 0, 0, 1, 1], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [1, 1, 0, 0, 0, 1, 1], [0, 0, 0, 1, 0, 0, 0]]) == 20\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]]) == 25\n assert candidate(grid = [[1, 0, 0, 0, 1, 0, 0, 0, 1], [0, 1, 1, 0, 0, 1, 1, 0, 0], [0, 1, 1, 0, 0, 1, 1, 0, 0], [1, 0, 0, 0, 1, 0, 0, 0, 1], [0, 1, 1, 0, 0, 1, 1, 0, 0], [0, 1, 1, 0, 0, 1, 1, 0, 0]]) == 40\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 1], [0, 1, 1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 1, 0], [1, 0, 0, 0, 0, 0, 0, 1]]) == 36\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 25\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 0, 1], [0, 1, 1, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 1, 0, 1, 0, 0], [0, 1, 0, 1, 1, 0, 1, 0, 0], [0, 1, 1, 0, 0, 0, 0, 1, 0], [1, 0, 0, 0, 0, 0, 0, 0, 1]]) == 38\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == 44\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 0, 1], [0, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 1, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 1, 1, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0], [1, 0, 0, 0, 0, 0, 0, 0, 1]]) == 67\n assert candidate(grid = [[1, 1, 1, 0, 0, 0, 1], [1, 1, 1, 0, 0, 0, 1], [0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 1, 1, 1, 0], [1, 1, 1, 0, 0, 0, 1]]) == 26\n assert candidate(grid = [[1, 1, 0, 0, 0, 0, 0, 1], [1, 1, 0, 0, 0, 0, 0, 1], [0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1, 0], [0, 0, 0, 0, 0, 1, 1, 0]]) == 22\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 1, 0, 0, 0], [1, 1, 1, 0, 1, 1, 1], [0, 0, 0, 1, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1]]) == 29\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1]]) == 33\n assert candidate(grid = [[1, 0, 0, 1, 0, 0, 1], [0, 1, 1, 0, 1, 1, 0], [0, 1, 1, 0, 1, 1, 0], [1, 0, 0, 1, 0, 0, 1], [0, 1, 1, 0, 1, 1, 0], [0, 1, 1, 0, 1, 1, 0]]) == 36\n assert candidate(grid = [[1, 0, 0, 0, 1, 0, 1, 0, 1], [0, 1, 1, 0, 0, 1, 0, 1, 0], [0, 1, 1, 0, 0, 0, 1, 0, 1], [1, 0, 0, 1, 0, 1, 1, 0, 0]]) == 31\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == 10\n assert candidate(grid = [[1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1]]) == 26\n assert candidate(grid = [[1, 0, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 0, 0], [0, 1, 0, 0, 1, 0, 0], [0, 1, 0, 0, 1, 0, 0], [0, 1, 1, 1, 1, 0, 0], [1, 0, 0, 0, 0, 1, 0]]) == 28\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().minimumSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumSum(vector>& grid) {", "container": "Solution", "callable": "minimumSum", "parameters": [{"name": "grid", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3200, "task_id": "maximum-height-of-a-triangle", "difficulty": "Easy", "problem_description": "You are given two integers red and blue representing the count of red and blue colored balls. You have to arrange these balls to form a triangle such that the 1st row will have 1 ball, the 2nd row will have 2 balls, the 3rd row will have 3 balls, and so on.\nAll the balls in a particular row should be the same color, and adjacent rows should have different colors.\nReturn the maximum height of the triangle that can be achieved.\n \nExample 1:\n\nInput: red = 2, blue = 4\nOutput: 3\nExplanation:\n\nThe only possible arrangement is shown above.\n\nExample 2:\n\nInput: red = 2, blue = 1\nOutput: 2\nExplanation:\n\nThe only possible arrangement is shown above.\n\nExample 3:\n\nInput: red = 1, blue = 1\nOutput: 1\n\nExample 4:\n\nInput: red = 10, blue = 1\nOutput: 2\nExplanation:\n\nThe only possible arrangement is shown above.\n\n \nConstraints:\n\n1 <= red, blue <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(red = 100,blue = 1) == 2\n assert candidate(red = 3,blue = 7) == 3\n assert candidate(red = 50,blue = 50) == 13\n assert candidate(red = 5,blue = 5) == 3\n assert candidate(red = 1,blue = 1) == 1\n assert candidate(red = 10,blue = 1) == 2\n assert candidate(red = 1,blue = 100) == 2\n assert candidate(red = 2,blue = 1) == 2\n assert candidate(red = 2,blue = 4) == 3\n assert candidate(red = 100,blue = 100) == 19\n assert candidate(red = 15,blue = 10) == 6\n assert candidate(red = 20,blue = 15) == 7\n assert candidate(red = 30,blue = 30) == 10\n assert candidate(red = 25,blue = 25) == 9\n assert candidate(red = 8,blue = 8) == 4\n assert candidate(red = 15,blue = 14) == 6\n assert candidate(red = 30,blue = 10) == 6\n assert candidate(red = 33,blue = 66) == 11\n assert candidate(red = 7,blue = 12) == 5\n assert candidate(red = 40,blue = 40) == 11\n assert candidate(red = 15,blue = 85) == 7\n assert candidate(red = 10,blue = 15) == 6\n assert candidate(red = 70,blue = 30) == 11\n assert candidate(red = 30,blue = 70) == 11\n assert candidate(red = 50,blue = 30) == 11\n assert candidate(red = 40,blue = 39) == 11\n assert candidate(red = 49,blue = 49) == 13\n assert candidate(red = 10,blue = 90) == 6\n assert candidate(red = 3,blue = 5) == 3\n assert candidate(red = 42,blue = 42) == 12\n assert candidate(red = 7,blue = 9) == 5\n assert candidate(red = 7,blue = 3) == 3\n assert candidate(red = 15,blue = 15) == 6\n assert candidate(red = 30,blue = 20) == 9\n assert candidate(red = 55,blue = 45) == 13\n assert candidate(red = 40,blue = 60) == 12\n assert candidate(red = 12,blue = 12) == 6\n assert candidate(red = 50,blue = 60) == 14\n assert candidate(red = 30,blue = 40) == 11\n assert candidate(red = 20,blue = 20) == 8\n assert candidate(red = 10,blue = 20) == 6\n assert candidate(red = 99,blue = 99) == 18\n assert candidate(red = 3,blue = 97) == 3\n assert candidate(red = 99,blue = 100) == 19\n assert candidate(red = 90,blue = 10) == 6\n assert candidate(red = 99,blue = 2) == 3\n assert candidate(red = 45,blue = 55) == 13\n assert candidate(red = 99,blue = 1) == 2\n assert candidate(red = 35,blue = 65) == 11\n assert candidate(red = 60,blue = 40) == 12\n assert candidate(red = 25,blue = 75) == 10\n assert candidate(red = 2,blue = 2) == 2\n assert candidate(red = 50,blue = 100) == 14\n assert candidate(red = 1,blue = 99) == 2\n assert candidate(red = 20,blue = 10) == 6\n assert candidate(red = 100,blue = 50) == 14\n assert candidate(red = 8,blue = 7) == 4\n assert candidate(red = 50,blue = 25) == 10\n assert candidate(red = 10,blue = 10) == 5\n assert candidate(red = 15,blue = 20) == 7\n assert candidate(red = 75,blue = 25) == 10\n assert candidate(red = 5,blue = 95) == 4\n assert candidate(red = 80,blue = 20) == 9\n assert candidate(red = 20,blue = 80) == 9\n assert candidate(red = 30,blue = 50) == 11\n assert candidate(red = 33,blue = 67) == 11\n assert candidate(red = 100,blue = 99) == 19\n"}, "metadata": {"canonical_parameter_names": ["red", "blue"], "leetcode_dataset_entry_point": "Solution().maxHeightOfTriangle", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxHeightOfTriangle(int red, int blue) {", "container": "Solution", "callable": "maxHeightOfTriangle", "parameters": [{"name": "red", "type": "int"}, {"name": "blue", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3201, "task_id": "find-the-maximum-length-of-valid-subsequence-i", "difficulty": "Medium", "problem_description": "You are given an integer array nums.\nA subsequence sub of nums with length x is called valid if it satisfies:\n\n(sub[0] + sub[1]) % 2 == (sub[1] + sub[2]) % 2 == ... == (sub[x - 2] + sub[x - 1]) % 2.\n\nReturn the length of the longest valid subsequence of nums.\nA subsequence is an array that can be derived from another array by deleting some or no elements without changing the order of the remaining elements.\n \nExample 1:\n\nInput: nums = [1,2,3,4]\nOutput: 4\nExplanation:\nThe longest valid subsequence is [1, 2, 3, 4].\n\nExample 2:\n\nInput: nums = [1,2,1,1,2,1,2]\nOutput: 6\nExplanation:\nThe longest valid subsequence is [1, 2, 1, 2, 1, 2].\n\nExample 3:\n\nInput: nums = [1,3]\nOutput: 2\nExplanation:\nThe longest valid subsequence is [1, 3].\n\n \nConstraints:\n\n2 <= nums.length <= 2 * 105\n1 <= nums[i] <= 107\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 10\n assert candidate(nums = [1, 1, 1, 1]) == 4\n assert candidate(nums = [1, 2, 1, 1, 2, 1, 2]) == 6\n assert candidate(nums = [10000000, 10000001, 10000002, 10000003, 10000004]) == 5\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]) == 6\n assert candidate(nums = [1, 2, 3, 4]) == 4\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 6\n assert candidate(nums = [10000000, 5000000, 2500000, 1250000, 625000, 312500, 156250, 78125, 39062, 19531]) == 8\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1]) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 9\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(nums = [1, 3]) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1]) == 8\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == 5\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1]) == 9\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6]) == 6\n assert candidate(nums = [2, 2, 2, 2]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8]) == 8\n assert candidate(nums = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23]) == 9\n assert candidate(nums = [1, 10000000, 2, 10000001, 3, 10000002, 4, 10000003, 5, 10000004]) == 6\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 10\n assert candidate(nums = [10000000, 1, 10000000, 1]) == 4\n assert candidate(nums = [2, 2, 2, 2, 2]) == 5\n assert candidate(nums = [2, 4, 6, 8]) == 4\n assert candidate(nums = [107, 106, 105, 104, 103, 102, 101, 100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 107\n assert candidate(nums = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15]) == 16\n assert candidate(nums = [10000000, 9999999, 10000000, 9999999, 10000000, 9999999, 10000000, 9999999, 10000000, 9999999]) == 10\n assert candidate(nums = [9999999, 1, 9999999, 1, 9999999, 1, 9999999, 1, 9999999, 1, 9999999, 1, 9999999, 1, 9999999, 1, 9999999, 1, 9999999, 1]) == 20\n assert candidate(nums = [10000000, 9999999, 10000000, 9999999, 10000000, 9999999, 10000000, 9999999]) == 8\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 15\n assert candidate(nums = [10000000, 20000000, 30000000, 40000000, 50000000, 60000000, 70000000, 80000000, 90000000, 100000000]) == 10\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 10\n assert candidate(nums = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23]) == 9\n assert candidate(nums = [1, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2]) == 20\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 15\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7]) == 12\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 15\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11]) == 11\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 18\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84]) == 12\n assert candidate(nums = [1, 2, 3, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 12\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 20\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 10\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 16\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2]) == 14\n assert candidate(nums = [2, 1, 3, 4, 3, 5, 2, 4, 3, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11]) == 12\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10, 1, 3, 5, 7, 9]) == 10\n assert candidate(nums = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 10\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 11\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 10\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2]) == 20\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == 14\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 6\n assert candidate(nums = [10000000, 1, 10000001, 2, 10000000, 3, 10000001, 4, 10000000, 5]) == 6\n assert candidate(nums = [9999999, 10000000, 9999999, 10000000, 9999999, 10000000]) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 12\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == 19\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 25\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4]) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 12\n assert candidate(nums = [1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1]) == 11\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 20\n assert candidate(nums = [5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6]) == 12\n assert candidate(nums = [10000000, 10000001, 10000002, 10000003, 10000004, 10000005, 10000006, 10000007, 10000008, 10000009, 10000010, 10000011, 10000012, 10000013, 10000014, 10000015, 10000016, 10000017, 10000018, 10000019]) == 20\n assert candidate(nums = [10000000, 9999999, 9999998, 9999997, 9999996, 9999995, 9999994, 9999993, 9999992, 9999991, 9999990, 9999989, 9999988, 9999987, 9999986, 9999985, 9999984, 9999983, 9999982, 9999981, 9999980, 9999979, 9999978, 9999977, 9999976, 9999975, 9999974, 9999973, 9999972, 9999971, 9999970, 9999969, 9999968, 9999967, 9999966, 9999965, 9999964, 9999963, 9999962, 9999961, 9999960, 9999959, 9999958, 9999957, 9999956, 9999955, 9999954, 9999953, 9999952, 9999951, 9999950, 9999949, 9999948, 9999947, 9999946, 9999945, 9999944, 9999943, 9999942, 9999941, 9999940, 9999939, 9999938, 9999937, 9999936, 9999935, 9999934, 9999933, 9999932, 9999931, 9999930, 9999929, 9999928, 9999927, 9999926, 9999925, 9999924, 9999923, 9999922, 9999921, 9999920]) == 81\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 14\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89]) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 30\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]) == 20\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(nums = [10000000, 9999999, 9999998, 9999997, 9999996, 9999995, 9999994, 9999993, 9999992, 9999991]) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 10\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 9\n assert candidate(nums = [5, 3, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == 15\n assert candidate(nums = [1, 4, 3, 2, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 10\n assert candidate(nums = [1, 2, 3, 2, 1, 4, 5, 4, 3, 2, 1, 6, 7, 6, 5, 4, 3, 2, 1]) == 19\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 9\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 20\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(nums = [2, 1, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 19\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]) == 20\n assert candidate(nums = [9999999, 10000000, 9999999, 10000000, 9999999, 10000000, 9999999, 10000000, 9999999, 10000000]) == 10\n assert candidate(nums = [1000000, 1000001, 1000002, 1000001, 1000000, 1000001, 1000002]) == 7\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946]) == 14\n assert candidate(nums = [2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 17\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 20\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 20\n assert candidate(nums = [10000000, 1, 10000000, 1, 10000000, 1, 10000000, 1, 10000000, 1]) == 10\n assert candidate(nums = [1, 3, 5, 2, 4, 6, 1, 3, 5, 2, 4, 6, 1, 3, 5, 2, 4, 6, 1, 3]) == 11\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12]) == 10\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 20\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n assert candidate(nums = [1, 3, 5, 2, 4, 6, 8, 10, 12, 14]) == 7\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 10\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 20\n assert candidate(nums = [10000000, 10000001, 10000000, 10000001, 10000000, 10000001]) == 6\n assert candidate(nums = [107, 208, 309, 410, 511, 612, 713, 814, 915, 1016]) == 10\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55]) == 11\n assert candidate(nums = [10000000, 10000001, 10000002, 10000003, 10000004, 10000005, 10000006, 10000007, 10000008, 10000009]) == 10\n assert candidate(nums = [1, 3, 2, 4, 1, 3, 2, 4, 1, 3, 2, 4, 1, 3, 2, 4, 1, 3, 2, 4]) == 10\n assert candidate(nums = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11]) == 15\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]) == 15\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2]) == 10\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maximumLength", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maximumLength(vector& nums) {", "container": "Solution", "callable": "maximumLength", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3202, "task_id": "find-the-maximum-length-of-valid-subsequence-ii", "difficulty": "Medium", "problem_description": "You are given an integer array nums and a positive integer k.\nA subsequence sub of nums with length x is called valid if it satisfies:\n\n(sub[0] + sub[1]) % k == (sub[1] + sub[2]) % k == ... == (sub[x - 2] + sub[x - 1]) % k.\n\nReturn the length of the longest valid subsequence of nums.\n \nExample 1:\n\nInput: nums = [1,2,3,4,5], k = 2\nOutput: 5\nExplanation:\nThe longest valid subsequence is [1, 2, 3, 4, 5].\n\nExample 2:\n\nInput: nums = [1,4,2,3,1,4], k = 3\nOutput: 4\nExplanation:\nThe longest valid subsequence is [1, 4, 1, 4].\n\n \nConstraints:\n\n2 <= nums.length <= 103\n1 <= nums[i] <= 107\n1 <= k <= 103\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [2, 6, 8, 10],k = 4) == 3\n assert candidate(nums = [1, 4, 2, 3, 1, 4],k = 3) == 4\n assert candidate(nums = [5, 5, 5, 5, 5],k = 5) == 5\n assert candidate(nums = [3, 1, 3, 1, 3, 1, 3, 1],k = 2) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 2\n assert candidate(nums = [2, 4, 6, 8, 10, 12],k = 4) == 6\n assert candidate(nums = [5, 10, 15, 20, 25],k = 5) == 5\n assert candidate(nums = [2, 4, 6, 8, 10],k = 4) == 5\n assert candidate(nums = [1, 2, 3, 4, 5],k = 2) == 5\n assert candidate(nums = [3, 1, 3, 1, 3, 1, 3],k = 2) == 7\n assert candidate(nums = [1, 3, 5, 7, 9],k = 2) == 5\n assert candidate(nums = [2, 3, 5, 8, 13, 21],k = 2) == 4\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7],k = 2) == 7\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1],k = 3) == 7\n assert candidate(nums = [2, 4, 6, 8, 10],k = 2) == 5\n assert candidate(nums = [1, 1, 1, 1, 1],k = 1) == 5\n assert candidate(nums = [1, 3, 5, 7, 9, 11],k = 2) == 6\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4],k = 3) == 4\n assert candidate(nums = [3, 6, 9, 12, 15],k = 3) == 5\n assert candidate(nums = [10, 20, 30, 40, 50],k = 10) == 5\n assert candidate(nums = [7, 14, 21, 28, 35],k = 7) == 5\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7],k = 7) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 6) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 11) == 4\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 3) == 8\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],k = 5) == 9\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],k = 2) == 10\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],k = 3) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == 7\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],k = 1024) == 10\n assert candidate(nums = [123, 246, 369, 492, 615, 738, 861, 984, 1107, 1230],k = 123) == 10\n assert candidate(nums = [1, 6, 3, 8, 5, 10, 7, 12, 9, 14, 11, 16, 13, 18, 15, 20],k = 5) == 4\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45],k = 12) == 8\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31],k = 3) == 14\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1000],k = 101) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 3) == 10\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],k = 10) == 10\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225],k = 10) == 4\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130],k = 13) == 10\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143],k = 13) == 11\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105],k = 10) == 10\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120],k = 15) == 8\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 5) == 10\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55],k = 5) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 13) == 6\n assert candidate(nums = [10, 21, 32, 43, 54, 65, 76, 87, 98, 109, 120, 131, 142, 153, 164, 175, 186, 197, 208, 219, 230, 241, 252, 263, 274, 285, 296, 307, 318, 329],k = 11) == 30\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768],k = 2) == 15\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == 10\n assert candidate(nums = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19],k = 5) == 4\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55],k = 5) == 4\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97],k = 7) == 10\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 3) == 15\n assert candidate(nums = [12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60],k = 3) == 17\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987],k = 10) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 10\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 2) == 10\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91],k = 7) == 13\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60],k = 3) == 20\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],k = 5) == 15\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90],k = 10) == 9\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == 10\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 2) == 10\n assert candidate(nums = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 3) == 10\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99],k = 9) == 11\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80],k = 8) == 10\n assert candidate(nums = [2, 11, 20, 29, 38, 47, 56, 65, 74, 83, 92],k = 9) == 11\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 10) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 5) == 6\n assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255, 272, 289],k = 17) == 17\n assert candidate(nums = [8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],k = 4) == 11\n assert candidate(nums = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015],k = 14) == 4\n assert candidate(nums = [1, 13, 25, 37, 49, 61, 73, 85, 97, 109, 121, 133, 145, 157, 169, 181, 193],k = 12) == 17\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152],k = 17) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 7) == 5\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120],k = 3) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41],k = 2) == 21\n assert candidate(nums = [2, 5, 9, 14, 20, 27, 35, 44, 54, 65, 77, 90, 104, 119, 135, 152, 170, 189, 209, 230],k = 7) == 7\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98],k = 7) == 14\n assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204],k = 17) == 12\n assert candidate(nums = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43],k = 3) == 15\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 10\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39],k = 3) == 13\n assert candidate(nums = [2, 5, 11, 23, 47, 95, 191, 383, 767, 1535, 3071, 6143, 12287, 24575, 49151],k = 11) == 4\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115],k = 13) == 4\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10],k = 3) == 13\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],k = 3) == 10\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946],k = 15) == 4\n assert candidate(nums = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156, 168, 180],k = 12) == 15\n assert candidate(nums = [10, 15, 20, 25, 30, 35, 40, 45],k = 5) == 8\n assert candidate(nums = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120],k = 12) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 4) == 10\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],k = 9) == 10\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12, 11, 13, 12, 14, 13, 15, 14, 16, 15, 17, 16, 18, 17, 19, 18, 20],k = 5) == 15\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155],k = 15) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 5) == 6\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],k = 10) == 5\n assert candidate(nums = [3, 1, 7, 5, 9, 11, 13, 15, 17, 19],k = 6) == 6\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45],k = 9) == 10\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105],k = 7) == 15\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4],k = 1) == 12\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65],k = 7) == 4\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45],k = 9) == 10\n assert candidate(nums = [456, 912, 1368, 1824, 2280, 2736, 3192, 3648, 4104, 4560],k = 456) == 10\n assert candidate(nums = [1, 3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049],k = 4) == 11\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],k = 2) == 10\n assert candidate(nums = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80],k = 4) == 20\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135],k = 9) == 15\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 7) == 4\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112],k = 8) == 14\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],k = 5) == 12\n assert candidate(nums = [25, 35, 45, 55, 65, 75, 85, 95, 105],k = 10) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == 7\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],k = 7) == 10\n assert candidate(nums = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19],k = 5) == 4\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],k = 7) == 6\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5],k = 5) == 3\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 15) == 7\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 3) == 6\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98],k = 7) == 14\n assert candidate(nums = [2, 3, 5, 8, 13, 21, 34, 55, 89, 144],k = 7) == 3\n assert candidate(nums = [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35],k = 7) == 5\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110],k = 11) == 10\n assert candidate(nums = [10000000, 9999999, 9999998, 9999997, 9999996, 9999995, 9999994],k = 1000) == 2\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],k = 7) == 6\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().maximumLength", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maximumLength(vector& nums, int k) {", "container": "Solution", "callable": "maximumLength", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3203, "task_id": "find-minimum-diameter-after-merging-two-trees", "difficulty": "Hard", "problem_description": "There exist two undirected trees with n and m nodes, numbered from 0 to n - 1 and from 0 to m - 1, respectively. You are given two 2D integer arrays edges1 and edges2 of lengths n - 1 and m - 1, respectively, where edges1[i] = [ai, bi] indicates that there is an edge between nodes ai and bi in the first tree and edges2[i] = [ui, vi] indicates that there is an edge between nodes ui and vi in the second tree.\nYou must connect one node from the first tree with another node from the second tree with an edge.\nReturn the minimum possible diameter of the resulting tree.\nThe diameter of a tree is the length of the longest path between any two nodes in the tree.\n \nExample 1:\n\nInput: edges1 = [[0,1],[0,2],[0,3]], edges2 = [[0,1]]\nOutput: 3\nExplanation:\nWe can obtain a tree of diameter 3 by connecting node 0 from the first tree with any node from the second tree.\n\nExample 2:\n\n\nInput: edges1 = [[0,1],[0,2],[0,3],[2,4],[2,5],[3,6],[2,7]], edges2 = [[0,1],[0,2],[0,3],[2,4],[2,5],[3,6],[2,7]]\nOutput: 5\nExplanation:\nWe can obtain a tree of diameter 5 by connecting node 0 from the first tree with node 0 from the second tree.\n\n \nConstraints:\n\n1 <= n, m <= 105\nedges1.length == n - 1\nedges2.length == m - 1\nedges1[i].length == edges2[i].length == 2\nedges1[i] = [ai, bi]\n0 <= ai, bi < n\nedges2[i] = [ui, vi]\n0 <= ui, vi < m\nThe input is generated such that edges1 and edges2 represent valid trees.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(edges1 = [[0, 1], [1, 2], [2, 3], [3, 4]],edges2 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == 6\n assert candidate(edges1 = [[0, 1], [0, 2], [0, 3]],edges2 = [[0, 1]]) == 3\n assert candidate(edges1 = [[0, 1], [0, 2], [0, 3], [2, 4], [2, 5], [3, 6], [2, 7]],edges2 = [[0, 1], [0, 2], [0, 3], [2, 4], [2, 5], [3, 6], [2, 7]]) == 5\n assert candidate(edges1 = [[0, 1]],edges2 = [[0, 1]]) == 3\n assert candidate(edges1 = [[0, 1], [0, 2], [1, 3], [1, 4]],edges2 = [[0, 1], [0, 2], [1, 3], [2, 4]]) == 5\n assert candidate(edges1 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],edges2 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 11\n assert candidate(edges1 = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19], [9, 20], [9, 21]],edges2 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]]) == 15\n assert candidate(edges1 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],edges2 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == 8\n assert candidate(edges1 = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9]],edges2 = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10]]) == 6\n assert candidate(edges1 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],edges2 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == 9\n assert candidate(edges1 = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10]],edges2 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 10\n assert candidate(edges1 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]],edges2 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 14\n assert candidate(edges1 = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20]],edges2 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22]]) == 22\n assert candidate(edges1 = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26]],edges2 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]]) == 20\n assert candidate(edges1 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]],edges2 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16]]) == 17\n assert candidate(edges1 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29]],edges2 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30]]) == 31\n assert candidate(edges1 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]],edges2 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == 14\n assert candidate(edges1 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],edges2 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]]) == 15\n assert candidate(edges1 = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]],edges2 = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7]]) == 7\n assert candidate(edges1 = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [5, 7], [6, 8]],edges2 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == 11\n assert candidate(edges1 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],edges2 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]]) == 19\n assert candidate(edges1 = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]],edges2 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == 14\n assert candidate(edges1 = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7]],edges2 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 10\n assert candidate(edges1 = [[0, 1], [1, 2], [2, 3], [2, 4], [3, 5], [3, 6], [4, 7], [4, 8], [5, 9], [5, 10], [6, 11], [6, 12], [7, 13], [7, 14], [8, 15], [8, 16]],edges2 = [[0, 1], [1, 2], [2, 3], [2, 4], [3, 5], [3, 6], [4, 7], [4, 8], [5, 9], [5, 10], [6, 11], [6, 12], [7, 13], [7, 14], [8, 15], [8, 16], [9, 17], [10, 18], [11, 19], [12, 20]]) == 8\n assert candidate(edges1 = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8]],edges2 = [[0, 1], [0, 9], [1, 10], [9, 11], [10, 12], [9, 13], [11, 14], [12, 15], [13, 16]]) == 8\n assert candidate(edges1 = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]],edges2 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]]) == 15\n assert candidate(edges1 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],edges2 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == 13\n assert candidate(edges1 = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [7, 8], [8, 9], [9, 10]],edges2 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 11\n assert candidate(edges1 = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]],edges2 = [[0, 1], [1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7]]) == 6\n assert candidate(edges1 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]],edges2 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == 9\n assert candidate(edges1 = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],edges2 = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]]) == 7\n assert candidate(edges1 = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13]],edges2 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == 14\n assert candidate(edges1 = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7]],edges2 = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [7, 8], [8, 9], [9, 10]]) == 10\n assert candidate(edges1 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]],edges2 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17]]) == 17\n assert candidate(edges1 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],edges2 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == 12\n assert candidate(edges1 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],edges2 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == 10\n assert candidate(edges1 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24]],edges2 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25]]) == 26\n assert candidate(edges1 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]],edges2 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25]]) == 25\n assert candidate(edges1 = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19], [9, 20], [9, 21], [10, 22], [11, 23], [12, 24], [13, 25], [14, 26], [15, 27], [16, 28], [17, 29], [18, 30], [19, 31], [20, 32], [21, 33], [22, 34], [23, 35], [24, 36], [25, 37], [26, 38], [27, 39], [28, 40], [29, 41], [30, 42], [31, 43], [32, 44], [33, 45]],edges2 = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19], [9, 20], [9, 21], [10, 22], [11, 23], [12, 24], [13, 25], [14, 26], [15, 27], [16, 28], [17, 29], [18, 30], [19, 31], [20, 32], [21, 33], [22, 34], [23, 35], [24, 36], [25, 37], [26, 38], [27, 39], [28, 40], [29, 41], [30, 42], [31, 43], [32, 44], [33, 45], [34, 46], [35, 47], [36, 48], [37, 49], [38, 50], [39, 51], [40, 52], [41, 53], [42, 54], [43, 55], [44, 56], [45, 57]]) == 12\n assert candidate(edges1 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]],edges2 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]]) == 21\n assert candidate(edges1 = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26], [13, 27], [13, 28], [14, 29], [14, 30]],edges2 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 31]]) == 31\n assert candidate(edges1 = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [5, 7], [6, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30]],edges2 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 31]]) == 31\n assert candidate(edges1 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]],edges2 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24]]) == 24\n assert candidate(edges1 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 31], [31, 32], [32, 33], [33, 34]],edges2 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 31], [31, 32], [32, 33], [33, 34], [34, 35]]) == 36\n assert candidate(edges1 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]],edges2 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13]]) == 15\n assert candidate(edges1 = [[0, 1], [0, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23], [12, 24], [12, 25], [13, 26], [13, 27], [14, 28], [14, 29], [15, 30], [15, 31]],edges2 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 31], [31, 32]]) == 32\n assert candidate(edges1 = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [7, 8], [8, 9], [9, 10]],edges2 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == 14\n assert candidate(edges1 = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],edges2 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 10\n assert candidate(edges1 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],edges2 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13]]) == 13\n assert candidate(edges1 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25]],edges2 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26]]) == 27\n assert candidate(edges1 = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]],edges2 = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8]]) == 6\n assert candidate(edges1 = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],edges2 = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 12]]) == 7\n assert candidate(edges1 = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [5, 7], [6, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]],edges2 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]]) == 20\n assert candidate(edges1 = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26]],edges2 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27]]) == 27\n assert candidate(edges1 = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10]],edges2 = [[0, 1], [0, 2], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10], [8, 11], [9, 12], [10, 13], [11, 14]]) == 11\n assert candidate(edges1 = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19], [9, 20], [9, 21]],edges2 = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19], [9, 20], [9, 21], [10, 22], [11, 23], [12, 24], [13, 25], [14, 26], [15, 27], [16, 28], [17, 29], [18, 30], [19, 31], [20, 32], [21, 33]]) == 8\n assert candidate(edges1 = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]],edges2 = [[0, 1], [0, 2], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7]]) == 6\n assert candidate(edges1 = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [5, 7], [5, 8]],edges2 = [[0, 1], [0, 2], [1, 3], [2, 4], [4, 5], [4, 6], [5, 7]]) == 7\n assert candidate(edges1 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]],edges2 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 8]]) == 9\n assert candidate(edges1 = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [5, 7], [5, 8], [6, 9], [6, 10]],edges2 = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == 8\n"}, "metadata": {"canonical_parameter_names": ["edges1", "edges2"], "leetcode_dataset_entry_point": "Solution().minimumDiameterAfterMerge", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumDiameterAfterMerge(vector>& edges1, vector>& edges2) {", "container": "Solution", "callable": "minimumDiameterAfterMerge", "parameters": [{"name": "edges1", "type": "vector>&"}, {"name": "edges2", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3206, "task_id": "alternating-groups-i", "difficulty": "Easy", "problem_description": "There is a circle of red and blue tiles. You are given an array of integers colors. The color of tile i is represented by colors[i]:\n\ncolors[i] == 0 means that tile i is red.\ncolors[i] == 1 means that tile i is blue.\n\nEvery 3 contiguous tiles in the circle with alternating colors (the middle tile has a different color from its left and right tiles) is called an alternating group.\nReturn the number of alternating groups.\nNote that since colors represents a circle, the first and the last tiles are considered to be next to each other.\n \nExample 1:\n\nInput: colors = [1,1,1]\nOutput: 0\nExplanation:\n\n\nExample 2:\n\nInput: colors = [0,1,0,0,1]\nOutput: 3\nExplanation:\n\nAlternating groups:\n\n\n \nConstraints:\n\n3 <= colors.length <= 100\n0 <= colors[i] <= 1\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(colors = [1, 1, 1, 0, 0, 0, 1, 1, 1]) == 0\n assert candidate(colors = [1, 0, 0, 0, 1, 1, 1, 0]) == 2\n assert candidate(colors = [0, 1, 0, 1, 0, 1, 0, 1, 0]) == 7\n assert candidate(colors = [0, 0, 1, 1, 0, 0, 1]) == 1\n assert candidate(colors = [0, 0, 1, 1, 0, 0, 1, 1, 0]) == 0\n assert candidate(colors = [0, 1, 1, 0, 0, 1]) == 2\n assert candidate(colors = [0, 1, 0, 1, 0]) == 3\n assert candidate(colors = [1, 1, 0, 1, 1, 0, 1]) == 2\n assert candidate(colors = [1, 0, 1, 0, 1, 0, 1]) == 5\n assert candidate(colors = [0, 1, 1, 0, 1, 1, 0, 1]) == 4\n assert candidate(colors = [1, 0, 0, 1, 1, 0]) == 2\n assert candidate(colors = [0, 1, 1, 0, 1, 1, 0, 1, 1]) == 3\n assert candidate(colors = [1, 1, 1]) == 0\n assert candidate(colors = [1, 1, 0, 1, 0, 1]) == 3\n assert candidate(colors = [0, 1, 0, 1, 1, 0, 1, 0, 1]) == 7\n assert candidate(colors = [1, 0, 0, 1, 0, 0, 1, 0, 0]) == 3\n assert candidate(colors = [0, 0, 0, 1, 1, 1, 0]) == 0\n assert candidate(colors = [0, 0, 1, 1, 0, 0]) == 0\n assert candidate(colors = [1, 1, 0, 0, 0, 1, 1, 0, 0]) == 0\n assert candidate(colors = [1, 0, 1, 0, 1]) == 3\n assert candidate(colors = [0, 1, 0, 0, 1]) == 3\n assert candidate(colors = [1, 0, 1, 0, 1, 0]) == 6\n assert candidate(colors = [1, 0, 1, 0, 1, 0, 1, 0, 1]) == 7\n assert candidate(colors = [0, 0, 0, 1, 1, 1, 0, 0, 0]) == 0\n assert candidate(colors = [1, 0, 0, 1, 0, 1, 1, 0, 1]) == 3\n assert candidate(colors = [1, 0, 0, 1, 0, 0, 1, 0]) == 4\n assert candidate(colors = [1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0]) == 6\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0]) == 0\n assert candidate(colors = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == 0\n assert candidate(colors = [0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1]) == 10\n assert candidate(colors = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 20\n assert candidate(colors = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 9\n assert candidate(colors = [1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0]) == 3\n assert candidate(colors = [1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1]) == 0\n assert candidate(colors = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 26\n assert candidate(colors = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == 0\n assert candidate(colors = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 32\n assert candidate(colors = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 15\n assert candidate(colors = [1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 31\n assert candidate(colors = [0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0]) == 6\n assert candidate(colors = [0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1]) == 8\n assert candidate(colors = [1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1]) == 0\n assert candidate(colors = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 14\n assert candidate(colors = [1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0]) == 12\n assert candidate(colors = [1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1]) == 0\n assert candidate(colors = [0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1]) == 15\n assert candidate(colors = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0]) == 11\n assert candidate(colors = [0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 12\n assert candidate(colors = [1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 20\n assert candidate(colors = [0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0]) == 0\n assert candidate(colors = [0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0]) == 9\n assert candidate(colors = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 19\n assert candidate(colors = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 12\n assert candidate(colors = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 13\n assert candidate(colors = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == 0\n assert candidate(colors = [1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1]) == 5\n assert candidate(colors = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 19\n assert candidate(colors = [1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1]) == 1\n assert candidate(colors = [0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0]) == 0\n assert candidate(colors = [1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0]) == 0\n assert candidate(colors = [1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 27\n assert candidate(colors = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1]) == 0\n assert candidate(colors = [1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1]) == 3\n assert candidate(colors = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 16\n assert candidate(colors = [0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0]) == 6\n assert candidate(colors = [1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0]) == 9\n assert candidate(colors = [1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1]) == 7\n assert candidate(colors = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 12\n assert candidate(colors = [1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1]) == 13\n assert candidate(colors = [0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0]) == 5\n assert candidate(colors = [0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1]) == 1\n assert candidate(colors = [1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 20\n assert candidate(colors = [0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == 0\n assert candidate(colors = [0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0]) == 7\n assert candidate(colors = [0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1]) == 3\n assert candidate(colors = [1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1]) == 8\n assert candidate(colors = [0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0]) == 0\n assert candidate(colors = [1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == 1\n assert candidate(colors = [1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1]) == 15\n assert candidate(colors = [1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1]) == 9\n assert candidate(colors = [1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1]) == 6\n assert candidate(colors = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 11\n assert candidate(colors = [1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 15\n assert candidate(colors = [0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1]) == 0\n assert candidate(colors = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0]) == 13\n assert candidate(colors = [0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1]) == 9\n assert candidate(colors = [0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 11\n assert candidate(colors = [1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1]) == 11\n assert candidate(colors = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 11\n assert candidate(colors = [1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0]) == 9\n assert candidate(colors = [1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0]) == 13\n assert candidate(colors = [1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1]) == 1\n assert candidate(colors = [1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1]) == 0\n assert candidate(colors = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 10\n assert candidate(colors = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1]) == 0\n assert candidate(colors = [1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1]) == 0\n assert candidate(colors = [0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0]) == 4\n assert candidate(colors = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 23\n assert candidate(colors = [0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1]) == 9\n assert candidate(colors = [0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1]) == 1\n assert candidate(colors = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 20\n assert candidate(colors = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 12\n assert candidate(colors = [0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0]) == 0\n assert candidate(colors = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 9\n assert candidate(colors = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == 0\n assert candidate(colors = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 24\n assert candidate(colors = [1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0]) == 10\n assert candidate(colors = [1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1]) == 4\n assert candidate(colors = [1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1]) == 12\n assert candidate(colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1]) == 0\n assert candidate(colors = [0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1]) == 4\n assert candidate(colors = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1]) == 0\n assert candidate(colors = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 15\n assert candidate(colors = [0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1]) == 2\n assert candidate(colors = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 18\n assert candidate(colors = [0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1]) == 13\n assert candidate(colors = [0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0]) == 9\n assert candidate(colors = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == 0\n assert candidate(colors = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1]) == 0\n assert candidate(colors = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 32\n assert candidate(colors = [0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0]) == 0\n assert candidate(colors = [0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1]) == 6\n assert candidate(colors = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == 0\n assert candidate(colors = [1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0]) == 7\n assert candidate(colors = [0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1]) == 2\n assert candidate(colors = [1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0]) == 1\n assert candidate(colors = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0]) == 1\n assert candidate(colors = [0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1]) == 1\n assert candidate(colors = [1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1]) == 7\n assert candidate(colors = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == 0\n assert candidate(colors = [0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0]) == 9\n"}, "metadata": {"canonical_parameter_names": ["colors"], "leetcode_dataset_entry_point": "Solution().numberOfAlternatingGroups", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int numberOfAlternatingGroups(vector& colors) {", "container": "Solution", "callable": "numberOfAlternatingGroups", "parameters": [{"name": "colors", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3207, "task_id": "maximum-points-after-enemy-battles", "difficulty": "Medium", "problem_description": "You are given an integer array enemyEnergies denoting the energy values of various enemies.\nYou are also given an integer currentEnergy denoting the amount of energy you have initially.\nYou start with 0 points, and all the enemies are unmarked initially.\nYou can perform either of the following operations zero or multiple times to gain points:\n\nChoose an unmarked enemy, i, such that currentEnergy >= enemyEnergies[i]. By choosing this option:\n\n\t\nYou gain 1 point.\nYour energy is reduced by the enemy's energy, i.e. currentEnergy = currentEnergy - enemyEnergies[i].\n\n\nIf you have at least 1 point, you can choose an unmarked enemy, i. By choosing this option:\n\t\nYour energy increases by the enemy's energy, i.e. currentEnergy = currentEnergy + enemyEnergies[i].\nThe enemy i is marked.\n\n\n\nReturn an integer denoting the maximum points you can get in the end by optimally performing operations.\n \nExample 1:\n\nInput: enemyEnergies = [3,2,2], currentEnergy = 2\nOutput: 3\nExplanation:\nThe following operations can be performed to get 3 points, which is the maximum:\n\nFirst operation on enemy 1: points increases by 1, and currentEnergy decreases by 2. So, points = 1, and currentEnergy = 0.\nSecond operation on enemy 0: currentEnergy increases by 3, and enemy 0 is marked. So, points = 1, currentEnergy = 3, and marked enemies = [0].\nFirst operation on enemy 2: points increases by 1, and currentEnergy decreases by 2. So, points = 2, currentEnergy = 1, and marked enemies = [0].\nSecond operation on enemy 2: currentEnergy increases by 2, and enemy 2 is marked. So, points = 2, currentEnergy = 3, and marked enemies = [0, 2].\nFirst operation on enemy 1: points increases by 1, and currentEnergy decreases by 2. So, points = 3, currentEnergy = 1, and marked enemies = [0, 2].\n\n\nExample 2:\n\nInput: enemyEnergies = [2], currentEnergy = 10\nOutput: 5\nExplanation: \nPerforming the first operation 5 times on enemy 0 results in the maximum number of points.\n\n \nConstraints:\n\n1 <= enemyEnergies.length <= 105\n1 <= enemyEnergies[i] <= 109\n0 <= currentEnergy <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(enemyEnergies = [1, 1, 1, 1, 1],currentEnergy = 1) == 5\n assert candidate(enemyEnergies = [1, 1000000000, 1],currentEnergy = 1000000001) == 2000000002\n assert candidate(enemyEnergies = [5, 5, 5, 5, 5],currentEnergy = 15) == 7\n assert candidate(enemyEnergies = [2],currentEnergy = 10) == 5\n assert candidate(enemyEnergies = [1],currentEnergy = 0) == 0\n assert candidate(enemyEnergies = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],currentEnergy = 25) == 14\n assert candidate(enemyEnergies = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],currentEnergy = 55) == 109\n assert candidate(enemyEnergies = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],currentEnergy = 55) == 109\n assert candidate(enemyEnergies = [1, 2, 3, 4, 5],currentEnergy = 15) == 29\n assert candidate(enemyEnergies = [3, 2, 2],currentEnergy = 2) == 3\n assert candidate(enemyEnergies = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],currentEnergy = 5) == 14\n assert candidate(enemyEnergies = [10, 20, 30],currentEnergy = 5) == 0\n assert candidate(enemyEnergies = [1000000000],currentEnergy = 1000000000) == 1\n assert candidate(enemyEnergies = [10, 10, 10, 10, 10],currentEnergy = 50) == 9\n assert candidate(enemyEnergies = [5, 4, 3, 2, 1],currentEnergy = 15) == 29\n assert candidate(enemyEnergies = [1, 1, 1, 1, 1],currentEnergy = 5) == 9\n assert candidate(enemyEnergies = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],currentEnergy = 5) == 59\n assert candidate(enemyEnergies = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],currentEnergy = 1) == 55\n assert candidate(enemyEnergies = [1, 2, 3, 4, 5],currentEnergy = 10) == 24\n assert candidate(enemyEnergies = [10, 20, 30],currentEnergy = 15) == 6\n assert candidate(enemyEnergies = [10, 20, 30, 40, 50],currentEnergy = 100) == 24\n assert candidate(enemyEnergies = [100, 200, 300, 400, 500],currentEnergy = 150) == 15\n assert candidate(enemyEnergies = [100, 200, 300, 400, 500],currentEnergy = 100) == 15\n assert candidate(enemyEnergies = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],currentEnergy = 10) == 53\n assert candidate(enemyEnergies = [100, 200, 300, 400, 500],currentEnergy = 250) == 16\n assert candidate(enemyEnergies = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],currentEnergy = 100) == 219\n assert candidate(enemyEnergies = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],currentEnergy = 10) == 64\n assert candidate(enemyEnergies = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],currentEnergy = 99) == 18\n assert candidate(enemyEnergies = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],currentEnergy = 10) == 39\n assert candidate(enemyEnergies = [100, 200, 300, 400, 500],currentEnergy = 1000) == 24\n assert candidate(enemyEnergies = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],currentEnergy = 100) == 29\n assert candidate(enemyEnergies = [30, 20, 10, 5, 2, 1],currentEnergy = 20) == 87\n assert candidate(enemyEnergies = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],currentEnergy = 55) == 59\n assert candidate(enemyEnergies = [1, 10, 100, 1000, 10000],currentEnergy = 5000) == 16110\n assert candidate(enemyEnergies = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],currentEnergy = 15) == 29\n assert candidate(enemyEnergies = [9, 8, 7, 6, 5, 4, 3, 2, 1],currentEnergy = 15) == 59\n assert candidate(enemyEnergies = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],currentEnergy = 10) == 17\n assert candidate(enemyEnergies = [1, 10, 100, 1000, 10000],currentEnergy = 10000) == 21110\n assert candidate(enemyEnergies = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],currentEnergy = 1) == 55\n assert candidate(enemyEnergies = [2, 3, 5, 7, 11, 13, 17, 19],currentEnergy = 50) == 62\n assert candidate(enemyEnergies = [1000000000, 500000000, 250000000],currentEnergy = 1000000000) == 10\n assert candidate(enemyEnergies = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],currentEnergy = 15) == 44\n assert candidate(enemyEnergies = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],currentEnergy = 100) == 19\n assert candidate(enemyEnergies = [5, 3, 1, 2, 4, 6],currentEnergy = 3) == 23\n assert candidate(enemyEnergies = [9, 8, 7, 6, 5, 4, 3, 2, 1],currentEnergy = 45) == 89\n assert candidate(enemyEnergies = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],currentEnergy = 5) == 14\n assert candidate(enemyEnergies = [5, 4, 3, 2, 1],currentEnergy = 15) == 29\n assert candidate(enemyEnergies = [5, 3, 8, 2, 10],currentEnergy = 7) == 16\n assert candidate(enemyEnergies = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],currentEnergy = 0) == 0\n assert candidate(enemyEnergies = [5, 3, 7, 2, 8, 1, 4],currentEnergy = 10) == 39\n assert candidate(enemyEnergies = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],currentEnergy = 27) == 18\n assert candidate(enemyEnergies = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],currentEnergy = 15) == 58\n assert candidate(enemyEnergies = [5, 3, 8, 6, 2, 7],currentEnergy = 10) == 19\n assert candidate(enemyEnergies = [1, 3, 5, 7, 9],currentEnergy = 20) == 44\n assert candidate(enemyEnergies = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],currentEnergy = 25) == 66\n assert candidate(enemyEnergies = [10, 5, 15, 20, 25, 30, 35, 40, 45, 50],currentEnergy = 50) == 64\n assert candidate(enemyEnergies = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],currentEnergy = 10) == 10\n assert candidate(enemyEnergies = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],currentEnergy = 50) == 59\n assert candidate(enemyEnergies = [5, 3, 6, 2, 8, 1],currentEnergy = 10) == 34\n assert candidate(enemyEnergies = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],currentEnergy = 10) == 109\n assert candidate(enemyEnergies = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125],currentEnergy = 500000000) == 1278\n assert candidate(enemyEnergies = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],currentEnergy = 2500) == 79\n assert candidate(enemyEnergies = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],currentEnergy = 10) == 55\n assert candidate(enemyEnergies = [100, 200, 300, 400, 500],currentEnergy = 500) == 19\n assert candidate(enemyEnergies = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],currentEnergy = 1024) == 3070\n assert candidate(enemyEnergies = [9, 7, 5, 3, 1],currentEnergy = 15) == 39\n assert candidate(enemyEnergies = [1000000000, 500000000, 250000000, 125000000, 62500000],currentEnergy = 1000000000) == 46\n assert candidate(enemyEnergies = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],currentEnergy = 5) == 0\n assert candidate(enemyEnergies = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],currentEnergy = 50) == 109\n assert candidate(enemyEnergies = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],currentEnergy = 15) == 69\n assert candidate(enemyEnergies = [50, 25, 75, 100, 200, 300, 400],currentEnergy = 100) == 49\n assert candidate(enemyEnergies = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],currentEnergy = 21) == 12\n assert candidate(enemyEnergies = [50, 25, 75, 100, 200, 150],currentEnergy = 125) == 28\n assert candidate(enemyEnergies = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],currentEnergy = 1) == 0\n assert candidate(enemyEnergies = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],currentEnergy = 10) == 14\n assert candidate(enemyEnergies = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],currentEnergy = 1) == 55\n assert candidate(enemyEnergies = [5, 3, 8, 1, 9],currentEnergy = 10) == 35\n assert candidate(enemyEnergies = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],currentEnergy = 100) == 309\n assert candidate(enemyEnergies = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],currentEnergy = 25) == 24\n assert candidate(enemyEnergies = [1, 2, 3, 4, 5],currentEnergy = 15) == 29\n assert candidate(enemyEnergies = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],currentEnergy = 100) == 113\n assert candidate(enemyEnergies = [9, 8, 7, 6, 5, 4, 3, 2, 1],currentEnergy = 20) == 64\n assert candidate(enemyEnergies = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1],currentEnergy = 1000) == 2993\n assert candidate(enemyEnergies = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],currentEnergy = 10) == 64\n assert candidate(enemyEnergies = [20, 20, 20, 20, 20, 20, 20, 20, 20, 20],currentEnergy = 100) == 14\n assert candidate(enemyEnergies = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],currentEnergy = 1023) == 2045\n assert candidate(enemyEnergies = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],currentEnergy = 55) == 109\n assert candidate(enemyEnergies = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],currentEnergy = 1024) == 2046\n assert candidate(enemyEnergies = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],currentEnergy = 100) == 119\n assert candidate(enemyEnergies = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71],currentEnergy = 100) == 368\n assert candidate(enemyEnergies = [5, 5, 5, 5, 5],currentEnergy = 15) == 7\n assert candidate(enemyEnergies = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],currentEnergy = 50) == 79\n assert candidate(enemyEnergies = [10, 20, 30, 40, 50],currentEnergy = 30) == 17\n assert candidate(enemyEnergies = [1, 2, 3, 4, 5],currentEnergy = 10) == 24\n assert candidate(enemyEnergies = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],currentEnergy = 20) == 63\n assert candidate(enemyEnergies = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],currentEnergy = 100) == 64\n assert candidate(enemyEnergies = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],currentEnergy = 10) == 19\n assert candidate(enemyEnergies = [9, 8, 7, 6, 5, 4, 3, 2, 1],currentEnergy = 5) == 49\n assert candidate(enemyEnergies = [1000000000, 1000000000, 1000000000],currentEnergy = 1500000000) == 3\n assert candidate(enemyEnergies = [100, 200, 300],currentEnergy = 1000) == 15\n assert candidate(enemyEnergies = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],currentEnergy = 500) == 104\n assert candidate(enemyEnergies = [3, 2, 2, 4, 1, 5],currentEnergy = 6) == 22\n assert candidate(enemyEnergies = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],currentEnergy = 100) == 199\n assert candidate(enemyEnergies = [10, 15, 20, 25, 30, 35, 40, 45, 50],currentEnergy = 100) == 36\n"}, "metadata": {"canonical_parameter_names": ["enemyEnergies", "currentEnergy"], "leetcode_dataset_entry_point": "Solution().maximumPoints", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "long long maximumPoints(vector& enemyEnergies, int currentEnergy) {", "container": "Solution", "callable": "maximumPoints", "parameters": [{"name": "enemyEnergies", "type": "vector&"}, {"name": "currentEnergy", "type": "int"}], "return_type": "long long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3208, "task_id": "alternating-groups-ii", "difficulty": "Medium", "problem_description": "There is a circle of red and blue tiles. You are given an array of integers colors and an integer k. The color of tile i is represented by colors[i]:\n\ncolors[i] == 0 means that tile i is red.\ncolors[i] == 1 means that tile i is blue.\n\nAn alternating group is every k contiguous tiles in the circle with alternating colors (each tile in the group except the first and last one has a different color from its left and right tiles).\nReturn the number of alternating groups.\nNote that since colors represents a circle, the first and the last tiles are considered to be next to each other.\n \nExample 1:\n\nInput: colors = [0,1,0,1,0], k = 3\nOutput: 3\nExplanation:\n\nAlternating groups:\n\n\nExample 2:\n\nInput: colors = [0,1,0,0,1,0,1], k = 6\nOutput: 2\nExplanation:\n\nAlternating groups:\n\n\nExample 3:\n\nInput: colors = [1,1,0,1], k = 4\nOutput: 0\nExplanation:\n\n\n \nConstraints:\n\n3 <= colors.length <= 105\n0 <= colors[i] <= 1\n3 <= k <= colors.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(colors = [1, 1, 0, 1],k = 4) == 0\n assert candidate(colors = [1, 0, 1, 0, 1, 0, 1, 0],k = 3) == 8\n assert candidate(colors = [0, 1, 0, 0, 1, 0, 1],k = 6) == 2\n assert candidate(colors = [1, 0, 1, 0, 1, 0, 1, 0, 1],k = 3) == 7\n assert candidate(colors = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0],k = 4) == 0\n assert candidate(colors = [0, 0, 1, 1, 0, 0, 1, 1],k = 4) == 0\n assert candidate(colors = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 6) == 12\n assert candidate(colors = [1, 0, 1, 0, 1, 0, 1, 0],k = 4) == 8\n assert candidate(colors = [0, 0, 1, 1, 0, 0, 1, 1],k = 5) == 0\n assert candidate(colors = [0, 1, 0, 1, 0],k = 3) == 3\n assert candidate(colors = [1, 0, 1, 0, 1, 0, 1, 0, 1],k = 5) == 5\n assert candidate(colors = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 7) == 5\n assert candidate(colors = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 10) == 22\n assert candidate(colors = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 13) == 24\n assert candidate(colors = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 5) == 26\n assert candidate(colors = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 7) == 12\n assert candidate(colors = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 9) == 22\n assert candidate(colors = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 10) == 18\n assert candidate(colors = [1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0],k = 6) == 0\n assert candidate(colors = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1],k = 6) == 0\n assert candidate(colors = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 9) == 20\n assert candidate(colors = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 5) == 20\n assert candidate(colors = [0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0],k = 6) == 2\n assert candidate(colors = [1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0],k = 6) == 0\n assert candidate(colors = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1],k = 4) == 0\n assert candidate(colors = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 12) == 34\n assert candidate(colors = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 7) == 16\n assert candidate(colors = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0],k = 8) == 0\n assert candidate(colors = [0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1],k = 4) == 0\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 0\n assert candidate(colors = [0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0],k = 4) == 3\n assert candidate(colors = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 20) == 46\n assert candidate(colors = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 15) == 28\n assert candidate(colors = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0],k = 6) == 0\n assert candidate(colors = [1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1],k = 5) == 0\n assert candidate(colors = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0],k = 6) == 0\n assert candidate(colors = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0],k = 12) == 0\n assert candidate(colors = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0],k = 5) == 0\n assert candidate(colors = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 8) == 16\n assert candidate(colors = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 3) == 16\n assert candidate(colors = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 7) == 21\n assert candidate(colors = [0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0],k = 6) == 0\n assert candidate(colors = [0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0],k = 12) == 0\n assert candidate(colors = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 15) == 59\n assert candidate(colors = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 11) == 32\n assert candidate(colors = [0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 8) == 14\n assert candidate(colors = [0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 8) == 4\n assert candidate(colors = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 11) == 25\n assert candidate(colors = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1],k = 10) == 0\n assert candidate(colors = [1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1],k = 5) == 3\n assert candidate(colors = [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0],k = 7) == 0\n assert candidate(colors = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 10) == 30\n assert candidate(colors = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 9) == 30\n assert candidate(colors = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 20) == 70\n assert candidate(colors = [0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1],k = 9) == 0\n assert candidate(colors = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 5) == 12\n assert candidate(colors = [0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1],k = 4) == 0\n assert candidate(colors = [1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1],k = 5) == 0\n assert candidate(colors = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 4) == 8\n assert candidate(colors = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0],k = 8) == 0\n assert candidate(colors = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 5) == 10\n assert candidate(colors = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 11) == 26\n assert candidate(colors = [0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0],k = 9) == 0\n assert candidate(colors = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 25) == 138\n assert candidate(colors = [0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 6) == 14\n assert candidate(colors = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1],k = 5) == 0\n assert candidate(colors = [0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 10) == 22\n assert candidate(colors = [0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0],k = 9) == 0\n assert candidate(colors = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1],k = 8) == 0\n assert candidate(colors = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 10) == 18\n assert candidate(colors = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1],k = 14) == 0\n assert candidate(colors = [0, 1, 1, 0, 1, 0, 1, 0, 1, 0],k = 5) == 4\n assert candidate(colors = [0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1],k = 8) == 0\n assert candidate(colors = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 20) == 20\n assert candidate(colors = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 5) == 11\n assert candidate(colors = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 10) == 14\n assert candidate(colors = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 9) == 9\n assert candidate(colors = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 7) == 7\n assert candidate(colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 5) == 0\n assert candidate(colors = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 11) == 20\n assert candidate(colors = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 11) == 17\n assert candidate(colors = [0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0],k = 4) == 5\n assert candidate(colors = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 6) == 20\n assert candidate(colors = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 7) == 12\n assert candidate(colors = [1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1],k = 5) == 0\n assert candidate(colors = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 8) == 52\n assert candidate(colors = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 15) == 19\n assert candidate(colors = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 7) == 17\n assert candidate(colors = [1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 9) == 5\n assert candidate(colors = [0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0],k = 5) == 4\n assert candidate(colors = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 9) == 16\n assert candidate(colors = [0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1],k = 13) == 0\n assert candidate(colors = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 8) == 32\n assert candidate(colors = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 5) == 10\n assert candidate(colors = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 12) == 26\n assert candidate(colors = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 6) == 6\n assert candidate(colors = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 11) == 20\n assert candidate(colors = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1],k = 4) == 0\n assert candidate(colors = [0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 6) == 44\n assert candidate(colors = [0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0],k = 6) == 0\n assert candidate(colors = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0],k = 6) == 0\n assert candidate(colors = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 7) == 20\n assert candidate(colors = [0, 1, 1, 0, 1, 0, 0, 1, 0, 1],k = 4) == 4\n"}, "metadata": {"canonical_parameter_names": ["colors", "k"], "leetcode_dataset_entry_point": "Solution().numberOfAlternatingGroups", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int numberOfAlternatingGroups(vector& colors, int k) {", "container": "Solution", "callable": "numberOfAlternatingGroups", "parameters": [{"name": "colors", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3209, "task_id": "number-of-subarrays-with-and-value-of-k", "difficulty": "Hard", "problem_description": "Given an array of integers nums and an integer k, return the number of subarrays of nums where the bitwise AND of the elements of the subarray equals k.\n \nExample 1:\n\nInput: nums = [1,1,1], k = 1\nOutput: 6\nExplanation:\nAll subarrays contain only 1's.\n\nExample 2:\n\nInput: nums = [1,1,2], k = 1\nOutput: 3\nExplanation:\nSubarrays having an AND value of 1 are: [1,1,2], [1,1,2], [1,1,2].\n\nExample 3:\n\nInput: nums = [1,2,3], k = 2\nOutput: 2\nExplanation:\nSubarrays having an AND value of 2 are: [1,2,3], [1,2,3].\n\n \nConstraints:\n\n1 <= nums.length <= 105\n0 <= nums[i], k <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 5, 5, 5, 5],k = 5) == 15\n assert candidate(nums = [10, 9, 8, 7, 6],k = 10) == 1\n assert candidate(nums = [5, 5, 5, 5],k = 5) == 10\n assert candidate(nums = [3, 3, 3, 3, 3, 3],k = 3) == 21\n assert candidate(nums = [8, 8, 8, 8, 8],k = 8) == 15\n assert candidate(nums = [4, 6, 3, 7, 1],k = 3) == 2\n assert candidate(nums = [1, 2, 3],k = 2) == 2\n assert candidate(nums = [1000000000, 1000000000, 1000000000],k = 1000000000) == 6\n assert candidate(nums = [0, 0, 0, 0, 0],k = 0) == 15\n assert candidate(nums = [10, 5, 3, 1],k = 1) == 4\n assert candidate(nums = [7, 7, 7, 7],k = 7) == 10\n assert candidate(nums = [1, 3, 5, 7, 9],k = 3) == 1\n assert candidate(nums = [8, 4, 2, 1],k = 8) == 1\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 1) == 1\n assert candidate(nums = [1, 1, 1],k = 1) == 6\n assert candidate(nums = [1, 3, 5, 7, 9],k = 1) == 10\n assert candidate(nums = [5, 3, 1, 4, 2],k = 0) == 7\n assert candidate(nums = [3, 3, 3, 3, 3],k = 3) == 15\n assert candidate(nums = [5, 3, 2, 1, 4],k = 1) == 2\n assert candidate(nums = [1, 1, 2],k = 1) == 3\n assert candidate(nums = [10, 20, 30, 40, 50],k = 10) == 1\n assert candidate(nums = [7, 14, 28, 56, 112],k = 7) == 1\n assert candidate(nums = [2, 4, 6, 8],k = 2) == 1\n assert candidate(nums = [4, 6, 7, 8],k = 6) == 2\n assert candidate(nums = [0, 0, 0],k = 0) == 6\n assert candidate(nums = [1, 2, 4, 8, 16],k = 8) == 1\n assert candidate(nums = [4, 6, 5, 3, 3, 2],k = 3) == 3\n assert candidate(nums = [0, 0, 0, 0],k = 0) == 10\n assert candidate(nums = [1000000000, 1000000000, 1000000000],k = 1000000000) == 6\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1],k = 1) == 1\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 4, 4, 4, 8, 8, 8],k = 2) == 6\n assert candidate(nums = [1023, 1023, 1023, 1022, 1023, 1022, 1022],k = 1022) == 21\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 0) == 55\n assert candidate(nums = [255, 255, 255, 255, 255, 255],k = 255) == 21\n assert candidate(nums = [7, 3, 15, 8, 8],k = 8) == 5\n assert candidate(nums = [31, 31, 31, 31, 31, 31, 31, 31],k = 31) == 36\n assert candidate(nums = [7, 7, 3, 7, 7, 7, 7],k = 7) == 13\n assert candidate(nums = [31, 31, 31, 31, 30, 31],k = 30) == 10\n assert candidate(nums = [8, 4, 2, 1, 0],k = 0) == 11\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096],k = 1) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 210\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 0) == 512\n assert candidate(nums = [15, 30, 30, 60, 60, 120],k = 30) == 3\n assert candidate(nums = [8, 8, 12, 8, 8, 8],k = 8) == 20\n assert candidate(nums = [2147483647, 2147483647, 2147483647],k = 2147483647) == 6\n assert candidate(nums = [1, 2, 4, 8, 16, 32],k = 4) == 1\n assert candidate(nums = [1023, 1023, 1023, 1023, 1023],k = 1023) == 15\n assert candidate(nums = [1023, 1023, 1023, 1022, 1023, 1023],k = 1022) == 12\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4],k = 1) == 6\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 5) == 1\n assert candidate(nums = [15, 15, 15, 15, 15, 15],k = 15) == 21\n assert candidate(nums = [15, 15, 15, 15, 15, 0, 15, 15],k = 15) == 18\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0, 0, 0, 0, 0],k = 0) == 65\n assert candidate(nums = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15],k = 15) == 496\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 210\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 100) == 1\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8],k = 8) == 55\n assert candidate(nums = [255, 255, 255, 255, 255, 255, 255, 255, 255, 255],k = 255) == 55\n assert candidate(nums = [31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 0, 31],k = 31) == 56\n assert candidate(nums = [7, 6, 7, 6, 7],k = 6) == 12\n assert candidate(nums = [3, 6, 12, 24, 48, 96, 192, 384, 768, 1536],k = 3) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 1\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127],k = 1) == 7\n assert candidate(nums = [7, 7, 3, 7, 3, 3, 7],k = 3) == 23\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == 1\n assert candidate(nums = [15, 15, 15, 15, 15, 15, 15, 15],k = 15) == 36\n assert candidate(nums = [15, 14, 13, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 15) == 2\n assert candidate(nums = [8, 12, 8, 12, 8, 12, 8, 12, 8, 12],k = 8) == 50\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 0) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 1) == 1\n assert candidate(nums = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128, 256, 256, 512, 512, 1024, 1024],k = 1) == 3\n assert candidate(nums = [255, 255, 255, 255, 255, 255, 255, 255, 255, 255],k = 255) == 55\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],k = 1) == 1\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15],k = 1) == 22\n assert candidate(nums = [3, 7, 5, 3, 7, 5, 3, 7, 5],k = 5) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 1) == 1\n assert candidate(nums = [7, 7, 7, 0, 7, 7],k = 7) == 9\n assert candidate(nums = [15, 15, 15, 15, 14, 14, 15],k = 14) == 17\n assert candidate(nums = [31, 31, 31, 31, 31, 31, 31],k = 31) == 28\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 10) == 210\n assert candidate(nums = [31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31],k = 31) == 210\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 1225\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023],k = 1) == 10\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575],k = 1) == 20\n assert candidate(nums = [63, 63, 63, 62, 63, 63, 63],k = 62) == 16\n assert candidate(nums = [31, 15, 7, 3, 1, 1, 3, 7, 15, 31],k = 3) == 8\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 7) == 465\n assert candidate(nums = [64, 32, 16, 8, 4, 2, 1, 2, 4, 8, 16, 32, 64],k = 1) == 1\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023],k = 1) == 120\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8],k = 8) == 210\n assert candidate(nums = [31, 31, 31, 31, 31, 31, 31],k = 31) == 28\n assert candidate(nums = [1073741824, 1073741824, 1073741824, 1073741824, 1073741824],k = 1073741824) == 15\n assert candidate(nums = [123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123],k = 123) == 496\n assert candidate(nums = [7, 14, 28, 28, 56],k = 28) == 3\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16],k = 2) == 1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 0) == 1128\n assert candidate(nums = [4, 8, 8, 16, 32, 32, 64],k = 32) == 3\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],k = 4) == 1\n assert candidate(nums = [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255],k = 255) == 79\n assert candidate(nums = [1023, 1023, 1023, 1023, 1023, 1023, 1023],k = 1023) == 28\n assert candidate(nums = [255, 255, 255, 254, 255, 255, 255],k = 254) == 16\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 3) == 1128\n assert candidate(nums = [7, 14, 28, 14, 7],k = 7) == 2\n assert candidate(nums = [15, 15, 15, 14, 15, 15, 14, 15],k = 14) == 26\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256],k = 2) == 1\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 2) == 210\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 0) == 0\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],k = 1024) == 1\n assert candidate(nums = [255, 255, 255, 254, 255, 254, 255, 254, 255, 254],k = 254) == 46\n assert candidate(nums = [8, 4, 2, 1, 2, 4, 8],k = 4) == 2\n assert candidate(nums = [2, 6, 2, 2, 6, 2, 2, 6, 2, 2],k = 2) == 52\n assert candidate(nums = [3, 5, 7, 9, 11, 13, 15],k = 3) == 1\n assert candidate(nums = [255, 127, 63, 31, 15, 7, 3, 1],k = 1) == 8\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],k = 1) == 10\n assert candidate(nums = [7, 7, 11, 7, 7, 7, 11, 11, 7],k = 7) == 10\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128],k = 2) == 1\n assert candidate(nums = [255, 255, 255, 255, 255],k = 255) == 15\n assert candidate(nums = [2, 3, 1, 2, 1, 1, 2, 3],k = 1) == 5\n assert candidate(nums = [2, 6, 10, 14, 18, 22, 26, 30, 34, 38],k = 2) == 38\n assert candidate(nums = [6, 6, 6, 6, 6, 7, 6, 6, 6, 6],k = 6) == 54\n assert candidate(nums = [1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 0, 1023],k = 1023) == 56\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 1) == 38\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8],k = 8) == 1326\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023],k = 1) == 10\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000],k = 1000000000) == 10\n assert candidate(nums = [2, 6, 2, 6, 2, 6, 2, 6, 2, 6, 2, 6],k = 2) == 72\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().countSubarrays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "long long countSubarrays(vector& nums, int k) {", "container": "Solution", "callable": "countSubarrays", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "long long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3210, "task_id": "find-the-encrypted-string", "difficulty": "Easy", "problem_description": "You are given a string s and an integer k. Encrypt the string using the following algorithm:\n\nFor each character c in s, replace c with the kth character after c in the string (in a cyclic manner).\n\nReturn the encrypted string.\n \nExample 1:\n\nInput: s = \"dart\", k = 3\nOutput: \"tdar\"\nExplanation:\n\nFor i = 0, the 3rd character after 'd' is 't'.\nFor i = 1, the 3rd character after 'a' is 'd'.\nFor i = 2, the 3rd character after 'r' is 'a'.\nFor i = 3, the 3rd character after 't' is 'r'.\n\n\nExample 2:\n\nInput: s = \"aaa\", k = 1\nOutput: \"aaa\"\nExplanation:\nAs all the characters are the same, the encrypted string will also be the same.\n\n \nConstraints:\n\n1 <= s.length <= 100\n1 <= k <= 104\ns consists only of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"hello\",k = 10) == \"hello\"\n assert candidate(s = \"abc\",k = 2) == \"cab\"\n assert candidate(s = \"hello\",k = 7) == \"llohe\"\n assert candidate(s = \"abcdef\",k = 2) == \"cdefab\"\n assert candidate(s = \"world\",k = 5) == \"world\"\n assert candidate(s = \"dart\",k = 3) == \"tdar\"\n assert candidate(s = \"aaa\",k = 1) == \"aaa\"\n assert candidate(s = \"abcxyz\",k = 10) == \"yzabcx\"\n assert candidate(s = \"xyz\",k = 5) == \"zxy\"\n assert candidate(s = \"hello\",k = 2) == \"llohe\"\n assert candidate(s = \"z\",k = 10000) == \"z\"\n assert candidate(s = \"wraparound\",k = 15) == \"roundwrapa\"\n assert candidate(s = \"jumps\",k = 30) == \"jumps\"\n assert candidate(s = \"cryptography\",k = 20) == \"aphycryptogr\"\n assert candidate(s = \"securedata\",k = 1234) == \"redatasecu\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 1) == \"abbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzza\"\n assert candidate(s = \"abcdefg\",k = 1000) == \"gabcdef\"\n assert candidate(s = \"cryptography\",k = 11) == \"ycryptograph\"\n assert candidate(s = \"mfvnhg\",k = 9999) == \"nhgmfv\"\n assert candidate(s = \"alibabacloud\",k = 15) == \"babacloudali\"\n assert candidate(s = \"abacaxi\",k = 1) == \"bacaxia\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",k = 13) == \"mlkjihgfedcbazyxwvutsrqpon\"\n assert candidate(s = \"cryptography\",k = 7) == \"raphycryptog\"\n assert candidate(s = \"programming\",k = 15) == \"rammingprog\"\n assert candidate(s = \"zebra\",k = 3) == \"razeb\"\n assert candidate(s = \"quickbrownfox\",k = 12) == \"xquickbrownfo\"\n assert candidate(s = \"programming\",k = 10) == \"gprogrammin\"\n assert candidate(s = \"cryptography\",k = 8) == \"aphycryptogr\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 20) == \"kkllmmnnooppqqrrssttuuvvwwxxyyzzaabbccddeeffgghhiijj\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 25) == \"zabcdefghijklmnopqrstuvwxy\"\n assert candidate(s = \"quickbrownfox\",k = 8) == \"wnfoxquickbro\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 50) == \"zzaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyy\"\n assert candidate(s = \"abcdabcd\",k = 4) == \"abcdabcd\"\n assert candidate(s = \"overthelazydog\",k = 28) == \"overthelazydog\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 1000) == \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(s = \"thequickbrownfoxjumpsoverthelazydog\",k = 13) == \"foxjumpsoverthelazydogthequickbrown\"\n assert candidate(s = \"python\",k = 1) == \"ythonp\"\n assert candidate(s = \"cryptography\",k = 15) == \"ptographycry\"\n assert candidate(s = \"pythonprogramming\",k = 25) == \"ogrammingpythonpr\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 27) == \"bcdefghijklmnopqrstuvwxyza\"\n assert candidate(s = \"thesecretcode\",k = 20) == \"etcodethesecr\"\n assert candidate(s = \"mississippi\",k = 9) == \"pimississip\"\n assert candidate(s = \"abcabcabc\",k = 9) == \"abcabcabc\"\n assert candidate(s = \"programming\",k = 97) == \"ngprogrammi\"\n assert candidate(s = \"programming\",k = 7) == \"mingprogram\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",k = 27) == \"yxwvutsrqponmlkjihgfedcbaz\"\n assert candidate(s = \"thisisatest\",k = 13) == \"isisatestth\"\n assert candidate(s = \"hello world\",k = 10) == \"dhello worl\"\n assert candidate(s = \"alibabacloud\",k = 100) == \"abacloudalib\"\n assert candidate(s = \"zebra\",k = 10) == \"zebra\"\n assert candidate(s = \"thequickbrownfoxjumpsoverthelazydog\",k = 10) == \"ownfoxjumpsoverthelazydogthequickbr\"\n assert candidate(s = \"repeatedcharactersssssss\",k = 7) == \"dcharactersssssssrepeate\"\n assert candidate(s = \"zabcdefghijklmnopqrstuvwxyz\",k = 26) == \"zzabcdefghijklmnopqrstuvwxy\"\n assert candidate(s = \"abracadabra\",k = 7) == \"abraabracad\"\n assert candidate(s = \"quickbrownfox\",k = 50) == \"oxquickbrownf\"\n assert candidate(s = \"mississippi\",k = 26) == \"issippimiss\"\n assert candidate(s = \"aabbccddeeff\",k = 5) == \"cddeeffaabbc\"\n assert candidate(s = \"world\",k = 500) == \"world\"\n assert candidate(s = \"hello\",k = 100) == \"hello\"\n assert candidate(s = \"hello_world\",k = 4) == \"o_worldhell\"\n assert candidate(s = \"pneumonoultramicroscopicsilicovolcanoconiosis\",k = 26) == \"licovolcanoconiosispneumonoultramicroscopicsi\"\n assert candidate(s = \"abcdefg\",k = 10000) == \"efgabcd\"\n assert candidate(s = \"hello\",k = 1000) == \"hello\"\n assert candidate(s = \"programmingisfun\",k = 10) == \"gisfunprogrammin\"\n assert candidate(s = \"algorithms\",k = 50) == \"algorithms\"\n assert candidate(s = \"mississippi\",k = 3) == \"sissippimis\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 1) == \"bcdefghijklmnopqrstuvwxyza\"\n assert candidate(s = \"programming\",k = 5) == \"ammingprogr\"\n assert candidate(s = \"qwen\",k = 50) == \"enqw\"\n assert candidate(s = \"thisisateststring\",k = 50) == \"gthisisateststrin\"\n assert candidate(s = \"cryptography\",k = 4) == \"tographycryp\"\n assert candidate(s = \"cycliccycliccycliccyclic\",k = 50) == \"cliccycliccycliccycliccy\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 3) == \"bccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzaab\"\n assert candidate(s = \"abcdefg\",k = 105) == \"abcdefg\"\n assert candidate(s = \"abacaxi\",k = 7) == \"abacaxi\"\n assert candidate(s = \"aabbccddeeff\",k = 123) == \"bccddeeffaab\"\n assert candidate(s = \"supercalifragilisticexpialidocious\",k = 9) == \"fragilisticexpialidocioussupercali\"\n assert candidate(s = \"quickbrownfoxjumpsoverthelazydog\",k = 13) == \"jumpsoverthelazydogquickbrownfox\"\n assert candidate(s = \"hello world\",k = 15) == \"o worldhell\"\n assert candidate(s = \"thisisaverylongstringthatweneedtocrypt\",k = 15) == \"stringthatweneedtocryptthisisaverylong\"\n assert candidate(s = \"repeatedcharacters\",k = 50) == \"tersrepeatedcharac\"\n assert candidate(s = \"hello\",k = 10000) == \"hello\"\n assert candidate(s = \"abcdefghij\",k = 30) == \"abcdefghij\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",k = 3) == \"wvutsrqponmlkjihgfedcbazyx\"\n assert candidate(s = \"abcdefg\",k = 10) == \"defgabc\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 26) == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"qwen\",k = 12) == \"qwen\"\n assert candidate(s = \"ab\",k = 9999) == \"ba\"\n"}, "metadata": {"canonical_parameter_names": ["s", "k"], "leetcode_dataset_entry_point": "Solution().getEncryptedString", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string getEncryptedString(string s, int k) {", "container": "Solution", "callable": "getEncryptedString", "parameters": [{"name": "s", "type": "string"}, {"name": "k", "type": "int"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3211, "task_id": "generate-binary-strings-without-adjacent-zeros", "difficulty": "Medium", "problem_description": "You are given a positive integer n.\nA binary string x is valid if all substrings of x of length 2 contain at least one \"1\".\nReturn all valid strings with length n, in any order.\n \nExample 1:\n\nInput: n = 3\nOutput: [\"010\",\"011\",\"101\",\"110\",\"111\"]\nExplanation:\nThe valid strings of length 3 are: \"010\", \"011\", \"101\", \"110\", and \"111\".\n\nExample 2:\n\nInput: n = 1\nOutput: [\"0\",\"1\"]\nExplanation:\nThe valid strings of length 1 are: \"0\" and \"1\".\n\n \nConstraints:\n\n1 <= n <= 18\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == ['010', '011', '101', '110', '111']\n assert candidate(n = 15) == ['010101010101010', '010101010101011', '010101010101101', '010101010101110', '010101010101111', '010101010110101', '010101010110110', '010101010110111', '010101010111010', '010101010111011', '010101010111101', '010101010111110', '010101010111111', '010101011010101', '010101011010110', '010101011010111', '010101011011010', '010101011011011', '010101011011101', '010101011011110', '010101011011111', '010101011101010', '010101011101011', '010101011101101', '010101011101110', '010101011101111', '010101011110101', '010101011110110', '010101011110111', '010101011111010', '010101011111011', '010101011111101', '010101011111110', '010101011111111', '010101101010101', '010101101010110', '010101101010111', '010101101011010', '010101101011011', '010101101011101', '010101101011110', '010101101011111', '010101101101010', '010101101101011', '010101101101101', '010101101101110', '010101101101111', '010101101110101', '010101101110110', '010101101110111', '010101101111010', '010101101111011', '010101101111101', '010101101111110', '010101101111111', '010101110101010', '010101110101011', '010101110101101', '010101110101110', '010101110101111', '010101110110101', '010101110110110', '010101110110111', '010101110111010', '010101110111011', '010101110111101', '010101110111110', '010101110111111', '010101111010101', '010101111010110', '010101111010111', '010101111011010', '010101111011011', '010101111011101', '010101111011110', '010101111011111', '010101111101010', '010101111101011', '010101111101101', '010101111101110', '010101111101111', '010101111110101', '010101111110110', '010101111110111', '010101111111010', '010101111111011', '010101111111101', '010101111111110', '010101111111111', '010110101010101', '010110101010110', '010110101010111', '010110101011010', '010110101011011', '010110101011101', '010110101011110', '010110101011111', '010110101101010', '010110101101011', '010110101101101', '010110101101110', '010110101101111', '010110101110101', '010110101110110', '010110101110111', '010110101111010', '010110101111011', '010110101111101', '010110101111110', '010110101111111', '010110110101010', '010110110101011', '010110110101101', '010110110101110', '010110110101111', '010110110110101', '010110110110110', '010110110110111', '010110110111010', '010110110111011', '010110110111101', '010110110111110', '010110110111111', '010110111010101', '010110111010110', '010110111010111', '010110111011010', '010110111011011', '010110111011101', '010110111011110', '010110111011111', '010110111101010', '010110111101011', '010110111101101', '010110111101110', '010110111101111', '010110111110101', '010110111110110', '010110111110111', '010110111111010', '010110111111011', '010110111111101', '010110111111110', '010110111111111', '010111010101010', '010111010101011', '010111010101101', '010111010101110', '010111010101111', '010111010110101', '010111010110110', '010111010110111', '010111010111010', '010111010111011', '010111010111101', '010111010111110', '010111010111111', '010111011010101', '010111011010110', '010111011010111', '010111011011010', '010111011011011', '010111011011101', '010111011011110', '010111011011111', '010111011101010', '010111011101011', '010111011101101', '010111011101110', '010111011101111', '010111011110101', '010111011110110', '010111011110111', '010111011111010', '010111011111011', '010111011111101', '010111011111110', '010111011111111', '010111101010101', '010111101010110', '010111101010111', '010111101011010', '010111101011011', '010111101011101', '010111101011110', '010111101011111', '010111101101010', '010111101101011', '010111101101101', '010111101101110', '010111101101111', '010111101110101', '010111101110110', '010111101110111', '010111101111010', '010111101111011', '010111101111101', '010111101111110', '010111101111111', '010111110101010', '010111110101011', '010111110101101', '010111110101110', '010111110101111', '010111110110101', '010111110110110', '010111110110111', '010111110111010', '010111110111011', '010111110111101', '010111110111110', '010111110111111', '010111111010101', '010111111010110', '010111111010111', '010111111011010', '010111111011011', '010111111011101', '010111111011110', '010111111011111', '010111111101010', '010111111101011', '010111111101101', '010111111101110', '010111111101111', '010111111110101', '010111111110110', '010111111110111', '010111111111010', '010111111111011', '010111111111101', '010111111111110', '010111111111111', '011010101010101', '011010101010110', '011010101010111', '011010101011010', '011010101011011', '011010101011101', '011010101011110', '011010101011111', '011010101101010', '011010101101011', '011010101101101', '011010101101110', '011010101101111', '011010101110101', '011010101110110', '011010101110111', '011010101111010', '011010101111011', '011010101111101', '011010101111110', '011010101111111', '011010110101010', '011010110101011', '011010110101101', '011010110101110', '011010110101111', '011010110110101', '011010110110110', '011010110110111', '011010110111010', '011010110111011', '011010110111101', '011010110111110', '011010110111111', '011010111010101', '011010111010110', '011010111010111', '011010111011010', '011010111011011', '011010111011101', '011010111011110', '011010111011111', '011010111101010', '011010111101011', '011010111101101', '011010111101110', '011010111101111', '011010111110101', '011010111110110', '011010111110111', '011010111111010', '011010111111011', '011010111111101', '011010111111110', '011010111111111', '011011010101010', '011011010101011', '011011010101101', '011011010101110', '011011010101111', '011011010110101', '011011010110110', '011011010110111', '011011010111010', '011011010111011', '011011010111101', '011011010111110', '011011010111111', '011011011010101', '011011011010110', '011011011010111', '011011011011010', '011011011011011', '011011011011101', '011011011011110', '011011011011111', '011011011101010', '011011011101011', '011011011101101', '011011011101110', '011011011101111', '011011011110101', '011011011110110', '011011011110111', '011011011111010', '011011011111011', '011011011111101', '011011011111110', '011011011111111', '011011101010101', '011011101010110', '011011101010111', '011011101011010', '011011101011011', '011011101011101', '011011101011110', '011011101011111', '011011101101010', '011011101101011', '011011101101101', '011011101101110', '011011101101111', '011011101110101', '011011101110110', '011011101110111', '011011101111010', '011011101111011', '011011101111101', '011011101111110', '011011101111111', '011011110101010', '011011110101011', '011011110101101', '011011110101110', '011011110101111', '011011110110101', '011011110110110', '011011110110111', '011011110111010', '011011110111011', '011011110111101', '011011110111110', '011011110111111', '011011111010101', '011011111010110', '011011111010111', '011011111011010', '011011111011011', '011011111011101', '011011111011110', '011011111011111', '011011111101010', '011011111101011', '011011111101101', '011011111101110', '011011111101111', '011011111110101', '011011111110110', '011011111110111', '011011111111010', '011011111111011', '011011111111101', '011011111111110', '011011111111111', '011101010101010', '011101010101011', '011101010101101', '011101010101110', '011101010101111', '011101010110101', '011101010110110', '011101010110111', '011101010111010', '011101010111011', '011101010111101', '011101010111110', '011101010111111', '011101011010101', '011101011010110', '011101011010111', '011101011011010', '011101011011011', '011101011011101', '011101011011110', '011101011011111', '011101011101010', '011101011101011', '011101011101101', '011101011101110', '011101011101111', '011101011110101', '011101011110110', '011101011110111', '011101011111010', '011101011111011', '011101011111101', '011101011111110', '011101011111111', '011101101010101', '011101101010110', '011101101010111', '011101101011010', '011101101011011', '011101101011101', '011101101011110', '011101101011111', '011101101101010', '011101101101011', '011101101101101', '011101101101110', '011101101101111', '011101101110101', '011101101110110', '011101101110111', '011101101111010', '011101101111011', '011101101111101', '011101101111110', '011101101111111', '011101110101010', '011101110101011', '011101110101101', '011101110101110', '011101110101111', '011101110110101', '011101110110110', '011101110110111', '011101110111010', '011101110111011', '011101110111101', '011101110111110', '011101110111111', '011101111010101', '011101111010110', '011101111010111', '011101111011010', '011101111011011', '011101111011101', '011101111011110', '011101111011111', '011101111101010', '011101111101011', '011101111101101', '011101111101110', '011101111101111', '011101111110101', '011101111110110', '011101111110111', '011101111111010', '011101111111011', '011101111111101', '011101111111110', '011101111111111', '011110101010101', '011110101010110', '011110101010111', '011110101011010', '011110101011011', '011110101011101', '011110101011110', '011110101011111', '011110101101010', '011110101101011', '011110101101101', '011110101101110', '011110101101111', '011110101110101', '011110101110110', '011110101110111', '011110101111010', '011110101111011', '011110101111101', '011110101111110', '011110101111111', '011110110101010', '011110110101011', '011110110101101', '011110110101110', '011110110101111', '011110110110101', '011110110110110', '011110110110111', '011110110111010', '011110110111011', '011110110111101', '011110110111110', '011110110111111', '011110111010101', '011110111010110', '011110111010111', '011110111011010', '011110111011011', '011110111011101', '011110111011110', '011110111011111', '011110111101010', '011110111101011', '011110111101101', '011110111101110', '011110111101111', '011110111110101', '011110111110110', '011110111110111', '011110111111010', '011110111111011', '011110111111101', '011110111111110', '011110111111111', '011111010101010', '011111010101011', '011111010101101', '011111010101110', '011111010101111', '011111010110101', '011111010110110', '011111010110111', '011111010111010', '011111010111011', '011111010111101', '011111010111110', '011111010111111', '011111011010101', '011111011010110', '011111011010111', '011111011011010', '011111011011011', '011111011011101', '011111011011110', '011111011011111', '011111011101010', '011111011101011', '011111011101101', '011111011101110', '011111011101111', '011111011110101', '011111011110110', '011111011110111', '011111011111010', '011111011111011', '011111011111101', '011111011111110', '011111011111111', '011111101010101', '011111101010110', '011111101010111', '011111101011010', '011111101011011', '011111101011101', '011111101011110', '011111101011111', '011111101101010', '011111101101011', '011111101101101', '011111101101110', '011111101101111', '011111101110101', '011111101110110', '011111101110111', '011111101111010', '011111101111011', '011111101111101', '011111101111110', '011111101111111', '011111110101010', '011111110101011', '011111110101101', '011111110101110', '011111110101111', '011111110110101', '011111110110110', '011111110110111', '011111110111010', '011111110111011', '011111110111101', '011111110111110', '011111110111111', '011111111010101', '011111111010110', '011111111010111', '011111111011010', '011111111011011', '011111111011101', '011111111011110', '011111111011111', '011111111101010', '011111111101011', '011111111101101', '011111111101110', '011111111101111', '011111111110101', '011111111110110', '011111111110111', '011111111111010', '011111111111011', '011111111111101', '011111111111110', '011111111111111', '101010101010101', '101010101010110', '101010101010111', '101010101011010', '101010101011011', '101010101011101', '101010101011110', '101010101011111', '101010101101010', '101010101101011', '101010101101101', '101010101101110', '101010101101111', '101010101110101', '101010101110110', '101010101110111', '101010101111010', '101010101111011', '101010101111101', '101010101111110', '101010101111111', '101010110101010', '101010110101011', '101010110101101', '101010110101110', '101010110101111', '101010110110101', '101010110110110', '101010110110111', '101010110111010', '101010110111011', '101010110111101', '101010110111110', '101010110111111', '101010111010101', '101010111010110', '101010111010111', '101010111011010', '101010111011011', '101010111011101', '101010111011110', '101010111011111', '101010111101010', '101010111101011', '101010111101101', '101010111101110', '101010111101111', '101010111110101', '101010111110110', '101010111110111', '101010111111010', '101010111111011', '101010111111101', '101010111111110', '101010111111111', '101011010101010', '101011010101011', '101011010101101', '101011010101110', '101011010101111', '101011010110101', '101011010110110', '101011010110111', '101011010111010', '101011010111011', '101011010111101', '101011010111110', '101011010111111', '101011011010101', '101011011010110', '101011011010111', '101011011011010', '101011011011011', '101011011011101', '101011011011110', '101011011011111', '101011011101010', '101011011101011', '101011011101101', '101011011101110', '101011011101111', '101011011110101', '101011011110110', '101011011110111', '101011011111010', '101011011111011', '101011011111101', '101011011111110', '101011011111111', '101011101010101', '101011101010110', '101011101010111', '101011101011010', '101011101011011', '101011101011101', '101011101011110', '101011101011111', '101011101101010', '101011101101011', '101011101101101', '101011101101110', '101011101101111', '101011101110101', '101011101110110', '101011101110111', '101011101111010', '101011101111011', '101011101111101', '101011101111110', '101011101111111', '101011110101010', '101011110101011', '101011110101101', '101011110101110', '101011110101111', '101011110110101', '101011110110110', '101011110110111', '101011110111010', '101011110111011', '101011110111101', '101011110111110', '101011110111111', '101011111010101', '101011111010110', '101011111010111', '101011111011010', '101011111011011', '101011111011101', '101011111011110', '101011111011111', '101011111101010', '101011111101011', '101011111101101', '101011111101110', '101011111101111', '101011111110101', '101011111110110', '101011111110111', '101011111111010', '101011111111011', '101011111111101', '101011111111110', '101011111111111', '101101010101010', '101101010101011', '101101010101101', '101101010101110', '101101010101111', '101101010110101', '101101010110110', '101101010110111', '101101010111010', '101101010111011', '101101010111101', '101101010111110', '101101010111111', '101101011010101', '101101011010110', '101101011010111', '101101011011010', '101101011011011', '101101011011101', '101101011011110', '101101011011111', '101101011101010', '101101011101011', '101101011101101', '101101011101110', '101101011101111', '101101011110101', '101101011110110', '101101011110111', '101101011111010', '101101011111011', '101101011111101', '101101011111110', '101101011111111', '101101101010101', '101101101010110', '101101101010111', '101101101011010', '101101101011011', '101101101011101', '101101101011110', '101101101011111', '101101101101010', '101101101101011', '101101101101101', '101101101101110', '101101101101111', '101101101110101', '101101101110110', '101101101110111', '101101101111010', '101101101111011', '101101101111101', '101101101111110', '101101101111111', '101101110101010', '101101110101011', '101101110101101', '101101110101110', '101101110101111', '101101110110101', '101101110110110', '101101110110111', '101101110111010', '101101110111011', '101101110111101', '101101110111110', '101101110111111', '101101111010101', '101101111010110', '101101111010111', '101101111011010', '101101111011011', '101101111011101', '101101111011110', '101101111011111', '101101111101010', '101101111101011', '101101111101101', '101101111101110', '101101111101111', '101101111110101', '101101111110110', '101101111110111', '101101111111010', '101101111111011', '101101111111101', '101101111111110', '101101111111111', '101110101010101', '101110101010110', '101110101010111', '101110101011010', '101110101011011', '101110101011101', '101110101011110', '101110101011111', '101110101101010', '101110101101011', '101110101101101', '101110101101110', '101110101101111', '101110101110101', '101110101110110', '101110101110111', '101110101111010', '101110101111011', '101110101111101', '101110101111110', '101110101111111', '101110110101010', '101110110101011', '101110110101101', '101110110101110', '101110110101111', '101110110110101', '101110110110110', '101110110110111', '101110110111010', '101110110111011', '101110110111101', '101110110111110', '101110110111111', '101110111010101', '101110111010110', '101110111010111', '101110111011010', '101110111011011', '101110111011101', '101110111011110', '101110111011111', '101110111101010', '101110111101011', '101110111101101', '101110111101110', '101110111101111', '101110111110101', '101110111110110', '101110111110111', '101110111111010', '101110111111011', '101110111111101', '101110111111110', '101110111111111', '101111010101010', '101111010101011', '101111010101101', '101111010101110', '101111010101111', '101111010110101', '101111010110110', '101111010110111', '101111010111010', '101111010111011', '101111010111101', '101111010111110', '101111010111111', '101111011010101', '101111011010110', '101111011010111', '101111011011010', '101111011011011', '101111011011101', '101111011011110', '101111011011111', '101111011101010', '101111011101011', '101111011101101', '101111011101110', '101111011101111', '101111011110101', '101111011110110', '101111011110111', '101111011111010', '101111011111011', '101111011111101', '101111011111110', '101111011111111', '101111101010101', '101111101010110', '101111101010111', '101111101011010', '101111101011011', '101111101011101', '101111101011110', '101111101011111', '101111101101010', '101111101101011', '101111101101101', '101111101101110', '101111101101111', '101111101110101', '101111101110110', '101111101110111', '101111101111010', '101111101111011', '101111101111101', '101111101111110', '101111101111111', '101111110101010', '101111110101011', '101111110101101', '101111110101110', '101111110101111', '101111110110101', '101111110110110', '101111110110111', '101111110111010', '101111110111011', '101111110111101', '101111110111110', '101111110111111', '101111111010101', '101111111010110', '101111111010111', '101111111011010', '101111111011011', '101111111011101', '101111111011110', '101111111011111', '101111111101010', '101111111101011', '101111111101101', '101111111101110', '101111111101111', '101111111110101', '101111111110110', '101111111110111', '101111111111010', '101111111111011', '101111111111101', '101111111111110', '101111111111111', '110101010101010', '110101010101011', '110101010101101', '110101010101110', '110101010101111', '110101010110101', '110101010110110', '110101010110111', '110101010111010', '110101010111011', '110101010111101', '110101010111110', '110101010111111', '110101011010101', '110101011010110', '110101011010111', '110101011011010', '110101011011011', '110101011011101', '110101011011110', '110101011011111', '110101011101010', '110101011101011', '110101011101101', '110101011101110', '110101011101111', '110101011110101', '110101011110110', '110101011110111', '110101011111010', '110101011111011', '110101011111101', '110101011111110', '110101011111111', '110101101010101', '110101101010110', '110101101010111', '110101101011010', '110101101011011', '110101101011101', '110101101011110', '110101101011111', '110101101101010', '110101101101011', '110101101101101', '110101101101110', '110101101101111', '110101101110101', '110101101110110', '110101101110111', '110101101111010', '110101101111011', '110101101111101', '110101101111110', '110101101111111', '110101110101010', '110101110101011', '110101110101101', '110101110101110', '110101110101111', '110101110110101', '110101110110110', '110101110110111', '110101110111010', '110101110111011', '110101110111101', '110101110111110', '110101110111111', '110101111010101', '110101111010110', '110101111010111', '110101111011010', '110101111011011', '110101111011101', '110101111011110', '110101111011111', '110101111101010', '110101111101011', '110101111101101', '110101111101110', '110101111101111', '110101111110101', '110101111110110', '110101111110111', '110101111111010', '110101111111011', '110101111111101', '110101111111110', '110101111111111', '110110101010101', '110110101010110', '110110101010111', '110110101011010', '110110101011011', '110110101011101', '110110101011110', '110110101011111', '110110101101010', '110110101101011', '110110101101101', '110110101101110', '110110101101111', '110110101110101', '110110101110110', '110110101110111', '110110101111010', '110110101111011', '110110101111101', '110110101111110', '110110101111111', '110110110101010', '110110110101011', '110110110101101', '110110110101110', '110110110101111', '110110110110101', '110110110110110', '110110110110111', '110110110111010', '110110110111011', '110110110111101', '110110110111110', '110110110111111', '110110111010101', '110110111010110', '110110111010111', '110110111011010', '110110111011011', '110110111011101', '110110111011110', '110110111011111', '110110111101010', '110110111101011', '110110111101101', '110110111101110', '110110111101111', '110110111110101', '110110111110110', '110110111110111', '110110111111010', '110110111111011', '110110111111101', '110110111111110', '110110111111111', '110111010101010', '110111010101011', '110111010101101', '110111010101110', '110111010101111', '110111010110101', '110111010110110', '110111010110111', '110111010111010', '110111010111011', '110111010111101', '110111010111110', '110111010111111', '110111011010101', '110111011010110', '110111011010111', '110111011011010', '110111011011011', '110111011011101', '110111011011110', '110111011011111', '110111011101010', '110111011101011', '110111011101101', '110111011101110', '110111011101111', '110111011110101', '110111011110110', '110111011110111', '110111011111010', '110111011111011', '110111011111101', '110111011111110', '110111011111111', '110111101010101', '110111101010110', '110111101010111', '110111101011010', '110111101011011', '110111101011101', '110111101011110', '110111101011111', '110111101101010', '110111101101011', '110111101101101', '110111101101110', '110111101101111', '110111101110101', '110111101110110', '110111101110111', '110111101111010', '110111101111011', '110111101111101', '110111101111110', '110111101111111', '110111110101010', '110111110101011', '110111110101101', '110111110101110', '110111110101111', '110111110110101', '110111110110110', '110111110110111', '110111110111010', '110111110111011', '110111110111101', '110111110111110', '110111110111111', '110111111010101', '110111111010110', '110111111010111', '110111111011010', '110111111011011', '110111111011101', '110111111011110', '110111111011111', '110111111101010', '110111111101011', '110111111101101', '110111111101110', '110111111101111', '110111111110101', '110111111110110', '110111111110111', '110111111111010', '110111111111011', '110111111111101', '110111111111110', '110111111111111', '111010101010101', '111010101010110', '111010101010111', '111010101011010', '111010101011011', '111010101011101', '111010101011110', '111010101011111', '111010101101010', '111010101101011', '111010101101101', '111010101101110', '111010101101111', '111010101110101', '111010101110110', '111010101110111', '111010101111010', '111010101111011', '111010101111101', '111010101111110', '111010101111111', '111010110101010', '111010110101011', '111010110101101', '111010110101110', '111010110101111', '111010110110101', '111010110110110', '111010110110111', '111010110111010', '111010110111011', '111010110111101', '111010110111110', '111010110111111', '111010111010101', '111010111010110', '111010111010111', '111010111011010', '111010111011011', '111010111011101', '111010111011110', '111010111011111', '111010111101010', '111010111101011', '111010111101101', '111010111101110', '111010111101111', '111010111110101', '111010111110110', '111010111110111', '111010111111010', '111010111111011', '111010111111101', '111010111111110', '111010111111111', '111011010101010', '111011010101011', '111011010101101', '111011010101110', '111011010101111', '111011010110101', '111011010110110', '111011010110111', '111011010111010', '111011010111011', '111011010111101', '111011010111110', '111011010111111', '111011011010101', '111011011010110', '111011011010111', '111011011011010', '111011011011011', '111011011011101', '111011011011110', '111011011011111', '111011011101010', '111011011101011', '111011011101101', '111011011101110', '111011011101111', '111011011110101', '111011011110110', '111011011110111', '111011011111010', '111011011111011', '111011011111101', '111011011111110', '111011011111111', '111011101010101', '111011101010110', '111011101010111', '111011101011010', '111011101011011', '111011101011101', '111011101011110', '111011101011111', '111011101101010', '111011101101011', '111011101101101', '111011101101110', '111011101101111', '111011101110101', '111011101110110', '111011101110111', '111011101111010', '111011101111011', '111011101111101', '111011101111110', '111011101111111', '111011110101010', '111011110101011', '111011110101101', '111011110101110', '111011110101111', '111011110110101', '111011110110110', '111011110110111', '111011110111010', '111011110111011', '111011110111101', '111011110111110', '111011110111111', '111011111010101', '111011111010110', '111011111010111', '111011111011010', '111011111011011', '111011111011101', '111011111011110', '111011111011111', '111011111101010', '111011111101011', '111011111101101', '111011111101110', '111011111101111', '111011111110101', '111011111110110', '111011111110111', '111011111111010', '111011111111011', '111011111111101', '111011111111110', '111011111111111', '111101010101010', '111101010101011', '111101010101101', '111101010101110', '111101010101111', '111101010110101', '111101010110110', '111101010110111', '111101010111010', '111101010111011', '111101010111101', '111101010111110', '111101010111111', '111101011010101', '111101011010110', '111101011010111', '111101011011010', '111101011011011', '111101011011101', '111101011011110', '111101011011111', '111101011101010', '111101011101011', '111101011101101', '111101011101110', '111101011101111', '111101011110101', '111101011110110', '111101011110111', '111101011111010', '111101011111011', '111101011111101', '111101011111110', '111101011111111', '111101101010101', '111101101010110', '111101101010111', '111101101011010', '111101101011011', '111101101011101', '111101101011110', '111101101011111', '111101101101010', '111101101101011', '111101101101101', '111101101101110', '111101101101111', '111101101110101', '111101101110110', '111101101110111', '111101101111010', '111101101111011', '111101101111101', '111101101111110', '111101101111111', '111101110101010', '111101110101011', '111101110101101', '111101110101110', '111101110101111', '111101110110101', '111101110110110', '111101110110111', '111101110111010', '111101110111011', '111101110111101', '111101110111110', '111101110111111', '111101111010101', '111101111010110', '111101111010111', '111101111011010', '111101111011011', '111101111011101', '111101111011110', '111101111011111', '111101111101010', '111101111101011', '111101111101101', '111101111101110', '111101111101111', '111101111110101', '111101111110110', '111101111110111', '111101111111010', '111101111111011', '111101111111101', '111101111111110', '111101111111111', '111110101010101', '111110101010110', '111110101010111', '111110101011010', '111110101011011', '111110101011101', '111110101011110', '111110101011111', '111110101101010', '111110101101011', '111110101101101', '111110101101110', '111110101101111', '111110101110101', '111110101110110', '111110101110111', '111110101111010', '111110101111011', '111110101111101', '111110101111110', '111110101111111', '111110110101010', '111110110101011', '111110110101101', '111110110101110', '111110110101111', '111110110110101', '111110110110110', '111110110110111', '111110110111010', '111110110111011', '111110110111101', '111110110111110', '111110110111111', '111110111010101', '111110111010110', '111110111010111', '111110111011010', '111110111011011', '111110111011101', '111110111011110', '111110111011111', '111110111101010', '111110111101011', '111110111101101', '111110111101110', '111110111101111', '111110111110101', '111110111110110', '111110111110111', '111110111111010', '111110111111011', '111110111111101', '111110111111110', '111110111111111', '111111010101010', '111111010101011', '111111010101101', '111111010101110', '111111010101111', '111111010110101', '111111010110110', '111111010110111', '111111010111010', '111111010111011', '111111010111101', '111111010111110', '111111010111111', '111111011010101', '111111011010110', '111111011010111', '111111011011010', '111111011011011', '111111011011101', '111111011011110', '111111011011111', '111111011101010', '111111011101011', '111111011101101', '111111011101110', '111111011101111', '111111011110101', '111111011110110', '111111011110111', '111111011111010', '111111011111011', '111111011111101', '111111011111110', '111111011111111', '111111101010101', '111111101010110', '111111101010111', '111111101011010', '111111101011011', '111111101011101', '111111101011110', '111111101011111', '111111101101010', '111111101101011', '111111101101101', '111111101101110', '111111101101111', '111111101110101', '111111101110110', '111111101110111', '111111101111010', '111111101111011', '111111101111101', '111111101111110', '111111101111111', '111111110101010', '111111110101011', '111111110101101', '111111110101110', '111111110101111', '111111110110101', '111111110110110', '111111110110111', '111111110111010', '111111110111011', '111111110111101', '111111110111110', '111111110111111', '111111111010101', '111111111010110', '111111111010111', '111111111011010', '111111111011011', '111111111011101', '111111111011110', '111111111011111', '111111111101010', '111111111101011', '111111111101101', '111111111101110', '111111111101111', '111111111110101', '111111111110110', '111111111110111', '111111111111010', '111111111111011', '111111111111101', '111111111111110', '111111111111111']\n assert candidate(n = 4) == ['0101', '0110', '0111', '1010', '1011', '1101', '1110', '1111']\n assert candidate(n = 2) == ['01', '10', '11']\n assert candidate(n = 1) == ['0', '1']\n assert candidate(n = 10) == ['0101010101', '0101010110', '0101010111', '0101011010', '0101011011', '0101011101', '0101011110', '0101011111', '0101101010', '0101101011', '0101101101', '0101101110', '0101101111', '0101110101', '0101110110', '0101110111', '0101111010', '0101111011', '0101111101', '0101111110', '0101111111', '0110101010', '0110101011', '0110101101', '0110101110', '0110101111', '0110110101', '0110110110', '0110110111', '0110111010', '0110111011', '0110111101', '0110111110', '0110111111', '0111010101', '0111010110', '0111010111', '0111011010', '0111011011', '0111011101', '0111011110', '0111011111', '0111101010', '0111101011', '0111101101', '0111101110', '0111101111', '0111110101', '0111110110', '0111110111', '0111111010', '0111111011', '0111111101', '0111111110', '0111111111', '1010101010', '1010101011', '1010101101', '1010101110', '1010101111', '1010110101', '1010110110', '1010110111', '1010111010', '1010111011', '1010111101', '1010111110', '1010111111', '1011010101', '1011010110', '1011010111', '1011011010', '1011011011', '1011011101', '1011011110', '1011011111', '1011101010', '1011101011', '1011101101', '1011101110', '1011101111', '1011110101', '1011110110', '1011110111', '1011111010', '1011111011', '1011111101', '1011111110', '1011111111', '1101010101', '1101010110', '1101010111', '1101011010', '1101011011', '1101011101', '1101011110', '1101011111', '1101101010', '1101101011', '1101101101', '1101101110', '1101101111', '1101110101', '1101110110', '1101110111', '1101111010', '1101111011', '1101111101', '1101111110', '1101111111', '1110101010', '1110101011', '1110101101', '1110101110', '1110101111', '1110110101', '1110110110', '1110110111', '1110111010', '1110111011', '1110111101', '1110111110', '1110111111', '1111010101', '1111010110', '1111010111', '1111011010', '1111011011', '1111011101', '1111011110', '1111011111', '1111101010', '1111101011', '1111101101', '1111101110', '1111101111', '1111110101', '1111110110', '1111110111', '1111111010', '1111111011', '1111111101', '1111111110', '1111111111']\n assert candidate(n = 5) == ['01010', '01011', '01101', '01110', '01111', '10101', '10110', '10111', '11010', '11011', '11101', '11110', '11111']\n assert candidate(n = 8) == ['01010101', '01010110', '01010111', '01011010', '01011011', '01011101', '01011110', '01011111', '01101010', '01101011', '01101101', '01101110', '01101111', '01110101', '01110110', '01110111', '01111010', '01111011', '01111101', '01111110', '01111111', '10101010', '10101011', '10101101', '10101110', '10101111', '10110101', '10110110', '10110111', '10111010', '10111011', '10111101', '10111110', '10111111', '11010101', '11010110', '11010111', '11011010', '11011011', '11011101', '11011110', '11011111', '11101010', '11101011', '11101101', '11101110', '11101111', '11110101', '11110110', '11110111', '11111010', '11111011', '11111101', '11111110', '11111111']\n assert candidate(n = 12) == ['010101010101', '010101010110', '010101010111', '010101011010', '010101011011', '010101011101', '010101011110', '010101011111', '010101101010', '010101101011', '010101101101', '010101101110', '010101101111', '010101110101', '010101110110', '010101110111', '010101111010', '010101111011', '010101111101', '010101111110', '010101111111', '010110101010', '010110101011', '010110101101', '010110101110', '010110101111', '010110110101', '010110110110', '010110110111', '010110111010', '010110111011', '010110111101', '010110111110', '010110111111', '010111010101', '010111010110', '010111010111', '010111011010', '010111011011', '010111011101', '010111011110', '010111011111', '010111101010', '010111101011', '010111101101', '010111101110', '010111101111', '010111110101', '010111110110', '010111110111', '010111111010', '010111111011', '010111111101', '010111111110', '010111111111', '011010101010', '011010101011', '011010101101', '011010101110', '011010101111', '011010110101', '011010110110', '011010110111', '011010111010', '011010111011', '011010111101', '011010111110', '011010111111', '011011010101', '011011010110', '011011010111', '011011011010', '011011011011', '011011011101', '011011011110', '011011011111', '011011101010', '011011101011', '011011101101', '011011101110', '011011101111', '011011110101', '011011110110', '011011110111', '011011111010', '011011111011', '011011111101', '011011111110', '011011111111', '011101010101', '011101010110', '011101010111', '011101011010', '011101011011', '011101011101', '011101011110', '011101011111', '011101101010', '011101101011', '011101101101', '011101101110', '011101101111', '011101110101', '011101110110', '011101110111', '011101111010', '011101111011', '011101111101', '011101111110', '011101111111', '011110101010', '011110101011', '011110101101', '011110101110', '011110101111', '011110110101', '011110110110', '011110110111', '011110111010', '011110111011', '011110111101', '011110111110', '011110111111', '011111010101', '011111010110', '011111010111', '011111011010', '011111011011', '011111011101', '011111011110', '011111011111', '011111101010', '011111101011', '011111101101', '011111101110', '011111101111', '011111110101', '011111110110', '011111110111', '011111111010', '011111111011', '011111111101', '011111111110', '011111111111', '101010101010', '101010101011', '101010101101', '101010101110', '101010101111', '101010110101', '101010110110', '101010110111', '101010111010', '101010111011', '101010111101', '101010111110', '101010111111', '101011010101', '101011010110', '101011010111', '101011011010', '101011011011', '101011011101', '101011011110', '101011011111', '101011101010', '101011101011', '101011101101', '101011101110', '101011101111', '101011110101', '101011110110', '101011110111', '101011111010', '101011111011', '101011111101', '101011111110', '101011111111', '101101010101', '101101010110', '101101010111', '101101011010', '101101011011', '101101011101', '101101011110', '101101011111', '101101101010', '101101101011', '101101101101', '101101101110', '101101101111', '101101110101', '101101110110', '101101110111', '101101111010', '101101111011', '101101111101', '101101111110', '101101111111', '101110101010', '101110101011', '101110101101', '101110101110', '101110101111', '101110110101', '101110110110', '101110110111', '101110111010', '101110111011', '101110111101', '101110111110', '101110111111', '101111010101', '101111010110', '101111010111', '101111011010', '101111011011', '101111011101', '101111011110', '101111011111', '101111101010', '101111101011', '101111101101', '101111101110', '101111101111', '101111110101', '101111110110', '101111110111', '101111111010', '101111111011', '101111111101', '101111111110', '101111111111', '110101010101', '110101010110', '110101010111', '110101011010', '110101011011', '110101011101', '110101011110', '110101011111', '110101101010', '110101101011', '110101101101', '110101101110', '110101101111', '110101110101', '110101110110', '110101110111', '110101111010', '110101111011', '110101111101', '110101111110', '110101111111', '110110101010', '110110101011', '110110101101', '110110101110', '110110101111', '110110110101', '110110110110', '110110110111', '110110111010', '110110111011', '110110111101', '110110111110', '110110111111', '110111010101', '110111010110', '110111010111', '110111011010', '110111011011', '110111011101', '110111011110', '110111011111', '110111101010', '110111101011', '110111101101', '110111101110', '110111101111', '110111110101', '110111110110', '110111110111', '110111111010', '110111111011', '110111111101', '110111111110', '110111111111', '111010101010', '111010101011', '111010101101', '111010101110', '111010101111', '111010110101', '111010110110', '111010110111', '111010111010', '111010111011', '111010111101', '111010111110', '111010111111', '111011010101', '111011010110', '111011010111', '111011011010', '111011011011', '111011011101', '111011011110', '111011011111', '111011101010', '111011101011', '111011101101', '111011101110', '111011101111', '111011110101', '111011110110', '111011110111', '111011111010', '111011111011', '111011111101', '111011111110', '111011111111', '111101010101', '111101010110', '111101010111', '111101011010', '111101011011', '111101011101', '111101011110', '111101011111', '111101101010', '111101101011', '111101101101', '111101101110', '111101101111', '111101110101', '111101110110', '111101110111', '111101111010', '111101111011', '111101111101', '111101111110', '111101111111', '111110101010', '111110101011', '111110101101', '111110101110', '111110101111', '111110110101', '111110110110', '111110110111', '111110111010', '111110111011', '111110111101', '111110111110', '111110111111', '111111010101', '111111010110', '111111010111', '111111011010', '111111011011', '111111011101', '111111011110', '111111011111', '111111101010', '111111101011', '111111101101', '111111101110', '111111101111', '111111110101', '111111110110', '111111110111', '111111111010', '111111111011', '111111111101', '111111111110', '111111111111']\n assert candidate(n = 9) == ['010101010', '010101011', '010101101', '010101110', '010101111', '010110101', '010110110', '010110111', '010111010', '010111011', '010111101', '010111110', '010111111', '011010101', '011010110', '011010111', '011011010', '011011011', '011011101', '011011110', '011011111', '011101010', '011101011', '011101101', '011101110', '011101111', '011110101', '011110110', '011110111', '011111010', '011111011', '011111101', '011111110', '011111111', '101010101', '101010110', '101010111', '101011010', '101011011', '101011101', '101011110', '101011111', '101101010', '101101011', '101101101', '101101110', '101101111', '101110101', '101110110', '101110111', '101111010', '101111011', '101111101', '101111110', '101111111', '110101010', '110101011', '110101101', '110101110', '110101111', '110110101', '110110110', '110110111', '110111010', '110111011', '110111101', '110111110', '110111111', '111010101', '111010110', '111010111', '111011010', '111011011', '111011101', '111011110', '111011111', '111101010', '111101011', '111101101', '111101110', '111101111', '111110101', '111110110', '111110111', '111111010', '111111011', '111111101', '111111110', '111111111']\n assert candidate(n = 6) == ['010101', '010110', '010111', '011010', '011011', '011101', '011110', '011111', '101010', '101011', '101101', '101110', '101111', '110101', '110110', '110111', '111010', '111011', '111101', '111110', '111111']\n assert candidate(n = 7) == ['0101010', '0101011', '0101101', '0101110', '0101111', '0110101', '0110110', '0110111', '0111010', '0111011', '0111101', '0111110', '0111111', '1010101', '1010110', '1010111', '1011010', '1011011', '1011101', '1011110', '1011111', '1101010', '1101011', '1101101', '1101110', '1101111', '1110101', '1110110', '1110111', '1111010', '1111011', '1111101', '1111110', '1111111']\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().validStrings", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector validStrings(int n) {", "container": "Solution", "callable": "validStrings", "parameters": [{"name": "n", "type": "int"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3212, "task_id": "count-submatrices-with-equal-frequency-of-x-and-y", "difficulty": "Medium", "problem_description": "Given a 2D character matrix grid, where grid[i][j] is either 'X', 'Y', or '.', return the number of submatrices that contain:\n\ngrid[0][0]\nan equal frequency of 'X' and 'Y'.\nat least one 'X'.\n\n \nExample 1:\n\nInput: grid = [[\"X\",\"Y\",\".\"],[\"Y\",\".\",\".\"]]\nOutput: 3\nExplanation:\n\n\nExample 2:\n\nInput: grid = [[\"X\",\"X\"],[\"X\",\"Y\"]]\nOutput: 0\nExplanation:\nNo submatrix has an equal frequency of 'X' and 'Y'.\n\nExample 3:\n\nInput: grid = [[\".\",\".\"],[\".\",\".\"]]\nOutput: 0\nExplanation:\nNo submatrix has at least one 'X'.\n\n \nConstraints:\n\n1 <= grid.length, grid[i].length <= 1000\ngrid[i][j] is either 'X', 'Y', or '.'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [['X', 'Y', 'X'], ['Y', 'X', 'Y'], ['X', 'Y', 'X']]) == 5\n assert candidate(grid = [['.', '.'], ['.', '.']]) == 0\n assert candidate(grid = [['X', 'X'], ['X', 'Y']]) == 0\n assert candidate(grid = [['X', 'X', 'Y', 'Y'], ['Y', 'Y', 'X', 'X']]) == 5\n assert candidate(grid = [['X', 'X', 'X', 'X'], ['X', 'Y', 'Y', 'X'], ['X', 'Y', 'Y', 'X'], ['X', 'X', 'X', 'X']]) == 0\n assert candidate(grid = [['X', 'Y', 'X', 'Y'], ['Y', 'X', 'Y', 'X'], ['X', 'Y', 'X', 'Y']]) == 8\n assert candidate(grid = [['X', '.', 'Y'], ['.', 'X', 'Y'], ['Y', '.', 'X']]) == 4\n assert candidate(grid = [['X'], ['Y'], ['X']]) == 1\n assert candidate(grid = [['X', 'Y', '.'], ['Y', '.', '.']]) == 3\n assert candidate(grid = [['X', 'Y'], ['X', 'Y'], ['X', 'Y']]) == 3\n assert candidate(grid = [['X', 'X', 'Y'], ['Y', 'Y', 'X'], ['X', 'Y', 'X']]) == 4\n assert candidate(grid = [['X', 'X', 'Y', 'Y'], ['Y', 'Y', 'X', 'X'], ['X', 'X', 'Y', 'Y']]) == 6\n assert candidate(grid = [['X', 'X', 'X'], ['X', 'X', 'X'], ['X', 'X', 'X']]) == 0\n assert candidate(grid = [['X', 'Y'], ['Y', 'X']]) == 3\n assert candidate(grid = [['X', 'X', 'X'], ['Y', 'Y', 'Y'], ['.', '.', '.']]) == 6\n assert candidate(grid = [['X', '.', 'Y'], ['.', 'X', '.'], ['Y', '.', 'X']]) == 2\n assert candidate(grid = [['X', 'Y', '.'], ['.', 'X', 'Y'], ['Y', 'X', '.']]) == 5\n assert candidate(grid = [['X', 'Y', 'X'], ['X', 'Y', 'X'], ['X', 'Y', 'X']]) == 3\n assert candidate(grid = [['X', 'Y', 'X', 'X', 'Y', 'Y'], ['Y', 'Y', 'X', 'Y', 'X', 'X'], ['X', 'X', 'Y', 'Y', 'X', 'Y'], ['X', 'Y', 'X', 'Y', 'X', 'Y'], ['Y', 'X', 'Y', 'X', 'Y', 'X'], ['X', 'Y', 'X', 'Y', 'X', 'Y']]) == 19\n assert candidate(grid = [['Y', 'Y', 'Y', 'Y', 'Y'], ['Y', 'Y', 'Y', 'Y', 'Y'], ['Y', 'Y', 'Y', 'Y', 'Y'], ['Y', 'Y', 'Y', 'Y', 'Y'], ['Y', 'Y', 'Y', 'Y', 'Y']]) == 0\n assert candidate(grid = [['X', 'Y', 'X'], ['Y', '.', 'X'], ['X', 'Y', '.']]) == 2\n assert candidate(grid = [['.', '.', '.', 'X', 'Y'], ['.', 'X', 'Y', '.', '.'], ['.', 'Y', 'X', '.', '.'], ['X', '.', '.', 'Y', '.'], ['Y', '.', '.', '.', 'X']]) == 12\n assert candidate(grid = [['X', 'Y', 'X', 'Y', 'X', 'Y', 'X', 'Y', 'X', 'Y'], ['Y', 'X', 'Y', 'X', 'Y', 'X', 'Y', 'X', 'Y', 'X']]) == 15\n assert candidate(grid = [['X', 'X', 'X'], ['Y', 'Y', 'Y'], ['X', 'Y', 'X'], ['Y', 'X', 'Y']]) == 7\n assert candidate(grid = [['X', 'Y', 'X', 'X', 'Y'], ['Y', 'X', 'Y', 'X', 'Y'], ['X', 'Y', 'X', 'X', 'Y'], ['X', 'X', 'Y', 'Y', 'X'], ['Y', 'X', 'Y', 'X', 'Y']]) == 6\n assert candidate(grid = [['X', 'Y', 'Y', 'X'], ['Y', 'X', 'X', 'Y'], ['X', 'Y', 'X', 'Y'], ['Y', 'X', 'Y', 'X']]) == 12\n assert candidate(grid = [['X', '.', 'X', 'Y'], ['Y', 'X', 'Y', '.'], ['.', 'Y', 'X', 'X'], ['X', 'Y', '.', 'Y']]) == 6\n assert candidate(grid = [['X', 'X', 'X', 'X', 'X'], ['X', 'X', 'X', 'X', 'X'], ['X', 'X', 'X', 'X', 'X'], ['X', 'X', 'X', 'X', 'X'], ['X', 'X', 'X', 'X', 'X']]) == 0\n assert candidate(grid = [['.', '.', 'X', 'Y', '.'], ['X', 'Y', '.', 'X', 'Y'], ['Y', 'X', 'X', 'Y', 'X'], ['.', 'Y', 'X', '.', 'Y'], ['X', '.', 'Y', 'X', '.']]) == 9\n assert candidate(grid = [['X', 'X', 'X', 'Y'], ['Y', 'Y', 'X', 'X'], ['X', 'Y', 'X', 'X'], ['Y', 'X', 'Y', 'Y']]) == 5\n assert candidate(grid = [['X', 'X', 'Y', 'X'], ['Y', 'Y', 'X', 'Y'], ['X', 'X', 'Y', 'X'], ['Y', 'Y', 'X', 'Y']]) == 8\n assert candidate(grid = [['X', 'Y', 'X', 'Y'], ['Y', 'X', 'Y', 'X'], ['X', 'Y', 'X', 'Y'], ['Y', 'X', 'Y', 'X']]) == 12\n assert candidate(grid = [['X', 'Y', 'X', 'Y', 'X', 'Y', 'X', 'Y', 'X'], ['Y', 'X', 'Y', 'X', 'Y', 'X', 'Y', 'X', 'Y']]) == 13\n assert candidate(grid = [['X', 'X', 'X', 'X', 'X', 'X'], ['X', 'X', 'X', 'X', 'X', 'X'], ['Y', 'Y', 'Y', 'Y', 'Y', 'Y'], ['Y', 'Y', 'Y', 'Y', 'Y', 'Y'], ['X', 'X', 'X', 'X', 'X', 'X'], ['X', 'X', 'X', 'X', 'X', 'X']]) == 6\n assert candidate(grid = [['X', '.', '.', 'Y', '.', '.', 'X', '.', 'Y', '.'], ['.', 'X', '.', '.', 'Y', '.', '.', 'X', '.', 'Y'], ['.', '.', 'X', '.', '.', 'Y', '.', '.', 'X', '.'], ['Y', '.', '.', 'X', '.', '.', 'Y', '.', '.', 'X']]) == 12\n assert candidate(grid = [['X', 'X', 'Y', 'Y', 'X', 'X', 'Y', 'Y'], ['Y', 'Y', 'X', 'X', 'Y', 'Y', 'X', 'X'], ['X', 'X', 'Y', 'Y', 'X', 'X', 'Y', 'Y']]) == 12\n assert candidate(grid = [['X', 'Y', 'X', 'Y', 'X'], ['Y', 'X', 'Y', 'X', 'Y'], ['X', 'Y', 'X', 'Y', 'X'], ['Y', 'X', 'Y', 'X', 'Y'], ['X', 'Y', 'X', 'Y', 'X']]) == 16\n assert candidate(grid = [['X', 'Y', 'X', 'Y', 'X', 'Y', 'X', 'Y'], ['Y', 'X', 'Y', 'X', 'Y', 'X', 'Y', 'X'], ['X', 'Y', 'X', 'Y', 'X', 'Y', 'X', 'Y']]) == 16\n assert candidate(grid = [['X', 'Y', '.', 'X'], ['Y', 'X', '.', 'Y'], ['.', '.', '.', '.'], ['X', 'Y', 'X', 'Y']]) == 12\n assert candidate(grid = [['X', 'Y', 'Y', 'Y'], ['X', 'Y', 'X', 'X'], ['X', 'X', 'Y', 'Y'], ['X', 'X', 'X', 'X']]) == 5\n assert candidate(grid = [['.', '.', 'X'], ['Y', 'X', 'Y'], ['X', 'Y', 'X'], ['Y', '.', 'Y']]) == 4\n assert candidate(grid = [['X', '.', 'Y', 'X'], ['Y', 'X', 'Y', 'X'], ['X', 'Y', 'X', '.'], ['.', 'X', 'Y', 'X']]) == 4\n assert candidate(grid = [['.', '.', '.', '.'], ['.', 'X', 'Y', '.'], ['.', 'Y', 'X', '.'], ['.', '.', '.', '.']]) == 8\n assert candidate(grid = [['.', '.', 'X', 'Y', '.'], ['X', 'Y', 'X', 'Y', 'X'], ['Y', 'X', 'Y', 'X', 'Y'], ['.', 'X', 'Y', 'X', 'Y']]) == 10\n assert candidate(grid = [['X', 'Y', 'X', 'Y', 'X', 'Y', 'X', 'Y', 'X', 'Y', 'X', 'Y', 'X', 'Y', 'X', 'Y', 'X', 'Y', 'X', 'Y']]) == 10\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().numberOfSubmatrices", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int numberOfSubmatrices(vector>& grid) {", "container": "Solution", "callable": "numberOfSubmatrices", "parameters": [{"name": "grid", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3213, "task_id": "construct-string-with-minimum-cost", "difficulty": "Hard", "problem_description": "You are given a string target, an array of strings words, and an integer array costs, both arrays of the same length.\nImagine an empty string s.\nYou can perform the following operation any number of times (including zero):\n\nChoose an index i in the range [0, words.length - 1].\nAppend words[i] to s.\nThe cost of operation is costs[i].\n\nReturn the minimum cost to make s equal to target. If it's not possible, return -1.\n \nExample 1:\n\nInput: target = \"abcdef\", words = [\"abdef\",\"abc\",\"d\",\"def\",\"ef\"], costs = [100,1,1,10,5]\nOutput: 7\nExplanation:\nThe minimum cost can be achieved by performing the following operations:\n\nSelect index 1 and append \"abc\" to s at a cost of 1, resulting in s = \"abc\".\nSelect index 2 and append \"d\" to s at a cost of 1, resulting in s = \"abcd\".\nSelect index 4 and append \"ef\" to s at a cost of 5, resulting in s = \"abcdef\".\n\n\nExample 2:\n\nInput: target = \"aaaa\", words = [\"z\",\"zz\",\"zzz\"], costs = [1,10,100]\nOutput: -1\nExplanation:\nIt is impossible to make s equal to target, so we return -1.\n\n \nConstraints:\n\n1 <= target.length <= 5 * 104\n1 <= words.length == costs.length <= 5 * 104\n1 <= words[i].length <= target.length\nThe total sum of words[i].length is less than or equal to 5 * 104.\ntarget and words[i] consist only of lowercase English letters.\n1 <= costs[i] <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(target = \"xyz\",words = ['x', 'y', 'z'],costs = [1, 2, 3]) == 6\n assert candidate(target = \"abcd\",words = ['a', 'b', 'c', 'd'],costs = [1, 1, 1, 1]) == 4\n assert candidate(target = \"zzzz\",words = ['zz', 'zzzz'],costs = [2, 1]) == 1\n assert candidate(target = \"programming\",words = ['pro', 'gram', 'ming'],costs = [10, 20, 30]) == 60\n assert candidate(target = \"python\",words = ['py', 'th', 'on'],costs = [5, 7, 8]) == 20\n assert candidate(target = \"abacaba\",words = ['a', 'b', 'c'],costs = [1, 2, 3]) == 11\n assert candidate(target = \"hello\",words = ['he', 'll', 'o'],costs = [3, 5, 2]) == 10\n assert candidate(target = \"abcabc\",words = ['abc', 'ab', 'c'],costs = [5, 3, 2]) == 10\n assert candidate(target = \"abc\",words = ['a', 'b', 'c'],costs = [1, 2, 3]) == 6\n assert candidate(target = \"hello\",words = ['h', 'he', 'hel', 'hell', 'hello'],costs = [5, 4, 3, 2, 1]) == 1\n assert candidate(target = \"xyz\",words = ['xy', 'y', 'z'],costs = [5, 3, 2]) == 7\n assert candidate(target = \"aabbcc\",words = ['aa', 'bb', 'cc'],costs = [1, 1, 1]) == 3\n assert candidate(target = \"abcabcabc\",words = ['abc', 'bc', 'c'],costs = [3, 2, 1]) == 9\n assert candidate(target = \"abcde\",words = ['a', 'bc', 'de'],costs = [2, 3, 4]) == 9\n assert candidate(target = \"abcabc\",words = ['abc', 'ab', 'c'],costs = [3, 2, 1]) == 6\n assert candidate(target = \"zzzzz\",words = ['z', 'zz', 'zzz'],costs = [1, 1, 1]) == 2\n assert candidate(target = \"xyz\",words = ['xy', 'yz', 'x'],costs = [2, 3, 1]) == 4\n assert candidate(target = \"aaaa\",words = ['z', 'zz', 'zzz'],costs = [1, 10, 100]) == -1\n assert candidate(target = \"world\",words = ['w', 'o', 'r', 'l', 'd'],costs = [2, 3, 4, 5, 6]) == 20\n assert candidate(target = \"aabbcc\",words = ['aa', 'bb', 'cc'],costs = [3, 4, 5]) == 12\n assert candidate(target = \"abcdef\",words = ['abdef', 'abc', 'd', 'def', 'ef'],costs = [100, 1, 1, 10, 5]) == 7\n assert candidate(target = \"ababab\",words = ['ab', 'aba', 'bab'],costs = [3, 4, 5]) == 9\n assert candidate(target = \"testcase\",words = ['tes', 't', 'case'],costs = [10, 2, 5]) == 17\n assert candidate(target = \"abcde\",words = ['a', 'bc', 'de'],costs = [1, 2, 3]) == 6\n assert candidate(target = \"abcdefgabcdefg\",words = ['abc', 'def', 'g', 'abcde', 'fg'],costs = [6, 7, 1, 5, 3]) == 16\n assert candidate(target = \"aaaabbbbcccc\",words = ['a', 'aa', 'aaa', 'aaaa', 'b', 'bb', 'bbb', 'bbbb', 'c', 'cc', 'ccc', 'cccc'],costs = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]) == 12\n assert candidate(target = \"xyxxyxyxyx\",words = ['xy', 'yx', 'xxy', 'xyx'],costs = [1, 2, 3, 4]) == 9\n assert candidate(target = \"zzzzzzzzzz\",words = ['z', 'zz', 'zzz', 'zzzz', 'zzzzz'],costs = [1, 3, 5, 7, 9]) == 10\n assert candidate(target = \"mnopqr\",words = ['mno', 'pqr', 'mnop', 'qr', 'qrs'],costs = [5, 6, 3, 8, 2]) == 11\n assert candidate(target = \"xyzxyzxyz\",words = ['xyz', 'xy', 'xz', 'yz'],costs = [10, 5, 6, 7]) == 30\n assert candidate(target = \"aaaabbbbccccdddd\",words = ['aaa', 'bbb', 'ccc', 'ddd', 'abcd'],costs = [10, 15, 20, 25, 30]) == -1\n assert candidate(target = \"zzzzzzzzzzzzzzzzzzzz\",words = ['zz', 'zzz', 'zzzz', 'zzzzz', 'zzzzzz'],costs = [1, 2, 3, 4, 5]) == 10\n assert candidate(target = \"hellohello\",words = ['he', 'll', 'o', 'hello'],costs = [3, 2, 1, 5]) == 10\n assert candidate(target = \"zzzzzzzzzz\",words = ['z', 'zz', 'zzz', 'zzzz'],costs = [1, 3, 6, 10]) == 10\n assert candidate(target = \"helloworld\",words = ['he', 'll', 'lo', 'wor', 'orl', 'ld'],costs = [1, 2, 3, 4, 5, 6]) == -1\n assert candidate(target = \"zzzzzzzzzzzz\",words = ['zz', 'zzz', 'z'],costs = [4, 2, 7]) == 8\n assert candidate(target = \"abcabcabcabc\",words = ['abc', 'cab', 'bca'],costs = [10, 20, 30]) == 40\n assert candidate(target = \"abcdabcdabcd\",words = ['abcd', 'ab', 'cd', 'abc'],costs = [10, 5, 3, 8]) == 24\n assert candidate(target = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",words = ['aabb', 'ccdd', 'eef', 'gghh', 'iijj', 'kkl', 'mnoon', 'popp', 'qqr', 'rss', 'ttu', 'vvww', 'xxy', 'yzz'],costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == -1\n assert candidate(target = \"abcdefghi\",words = ['abc', 'def', 'ghi', 'abcd', 'efgh', 'hij', 'abcd'],costs = [10, 20, 30, 15, 25, 35, 5]) == 60\n assert candidate(target = \"aabbaabbccddcc\",words = ['aa', 'bb', 'cc', 'dd'],costs = [1, 2, 3, 4]) == 16\n assert candidate(target = \"xyxyxyxyxyxy\",words = ['xy', 'yx', 'xxyy'],costs = [10, 5, 20]) == 60\n assert candidate(target = \"zzzzzzzzzzzz\",words = ['zzz', 'zzzz', 'zz', 'z'],costs = [15, 10, 8, 5]) == 30\n assert candidate(target = \"mississippi\",words = ['mis', 'issi', 'ppi', 'ippi', 'pi'],costs = [10, 12, 5, 8, 3]) == -1\n assert candidate(target = \"abcdefghijklmnop\",words = ['abcdefghijklmno', 'p', 'abcdefghijk', 'lmnop'],costs = [100, 1, 50, 50]) == 100\n assert candidate(target = \"aaaaaaaaaa\",words = ['a', 'aa', 'aaa', 'aaaa', 'aaaaa'],costs = [1, 2, 3, 4, 5]) == 10\n assert candidate(target = \"xyzxyzxyz\",words = ['xy', 'z', 'xyz'],costs = [5, 1, 3]) == 9\n assert candidate(target = \"alibaba\",words = ['ali', 'ba', 'ba', 'b', 'a'],costs = [5, 10, 20, 1, 2]) == 11\n assert candidate(target = \"abracadabra\",words = ['a', 'b', 'r', 'ac', 'ad', 'abra'],costs = [1, 2, 3, 4, 5, 6]) == 21\n assert candidate(target = \"bbaaccdd\",words = ['bb', 'aa', 'cc', 'dd', 'abcd'],costs = [5, 6, 7, 8, 9]) == 26\n assert candidate(target = \"xylophone\",words = ['xy', 'lo', 'phone', 'pho', 'ne', 'on'],costs = [3, 1, 2, 5, 4, 6]) == 6\n assert candidate(target = \"abcabcabcabc\",words = ['abc', 'ab', 'bc', 'a', 'b', 'c'],costs = [5, 2, 3, 1, 1, 1]) == 12\n assert candidate(target = \"abcdabcdabcd\",words = ['ab', 'bc', 'cd', 'abcd'],costs = [1, 2, 3, 4]) == 12\n assert candidate(target = \"aaaaaaaaaa\",words = ['a', 'aa', 'aaa', 'aaaa'],costs = [5, 3, 2, 1]) == 5\n assert candidate(target = \"abcdefghijk\",words = ['abc', 'def', 'gh', 'ijk'],costs = [10, 20, 30, 40]) == 100\n assert candidate(target = \"abracadabra\",words = ['abr', 'aca', 'dab', 'ra'],costs = [10, 20, 30, 5]) == 65\n assert candidate(target = \"abcdefghij\",words = ['ab', 'cde', 'fgh', 'ij'],costs = [2, 3, 4, 1]) == 10\n assert candidate(target = \"abcdefghijklmnopqrstuvwxyz\",words = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz'],costs = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 450\n assert candidate(target = \"xyzabc\",words = ['xy', 'zabc', 'xyz', 'ab', 'c'],costs = [5, 10, 3, 7, 2]) == 12\n assert candidate(target = \"aabbccddeeff\",words = ['aabb', 'ccdd', 'eeff', 'abcd'],costs = [10, 15, 20, 25]) == 45\n assert candidate(target = \"zzzzzzzzzzz\",words = ['zz', 'zzz', 'zzzz'],costs = [2, 5, 7]) == 13\n assert candidate(target = \"zzzzzzzzzzzzzzzzzzzz\",words = ['z', 'zz', 'zzz', 'zzzz'],costs = [1, 2, 3, 4]) == 20\n assert candidate(target = \"xyxzyzyxzyzyxzyx\",words = ['xyx', 'zyz', 'yx', 'xyz'],costs = [7, 6, 5, 4]) == -1\n assert candidate(target = \"aaaaabbbbb\",words = ['a', 'b', 'ab', 'ba'],costs = [1, 2, 3, 4]) == 15\n assert candidate(target = \"mississippi\",words = ['mis', 'issi', 'ppi', 'ss', 'ippi', 's', 'i', 'm'],costs = [1, 3, 5, 1, 2, 2, 1, 1]) == 7\n assert candidate(target = \"hellohello\",words = ['he', 'llo', 'ell', 'o'],costs = [2, 3, 1, 4]) == 10\n assert candidate(target = \"pppppppppp\",words = ['p', 'pp', 'ppp'],costs = [10, 5, 3]) == 16\n assert candidate(target = \"zzzzzzzzzzzzzzzzzzzz\",words = ['zzz', 'zz', 'z'],costs = [10, 5, 1]) == 20\n assert candidate(target = \"abcdefghij\",words = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],costs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 550\n assert candidate(target = \"zzzzzzzzzz\",words = ['zz', 'zzz', 'z'],costs = [1, 2, 10]) == 5\n assert candidate(target = \"aabbccddeeff\",words = ['aa', 'bb', 'cc', 'dd', 'ee', 'ff'],costs = [1, 2, 1, 2, 1, 2]) == 9\n assert candidate(target = \"abcdefghi\",words = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'],costs = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 45\n assert candidate(target = \"aabbccddeeff\",words = ['aa', 'bb', 'cc', 'dd', 'ee', 'ff', 'abcd', 'ef', 'fedc'],costs = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 21\n assert candidate(target = \"zzzzzzzzzzzzzzzzzzzz\",words = ['z', 'zz', 'zzz'],costs = [1, 10, 100]) == 20\n assert candidate(target = \"mnopqr\",words = ['m', 'no', 'pqr', 'op', 'qr', 'mnop', 'nopqr'],costs = [1, 2, 3, 4, 5, 6, 7]) == 6\n assert candidate(target = \"hellohellos\",words = ['he', 'llo', 'hel', 'los', 'o', 's'],costs = [1, 2, 3, 4, 5, 6]) == 10\n assert candidate(target = \"mamamamama\",words = ['ma', 'am'],costs = [2, 1]) == 10\n assert candidate(target = \"abcdabcdabcd\",words = ['abcd', 'abc', 'bca', 'cab', 'dab'],costs = [10, 7, 8, 9, 6]) == 30\n assert candidate(target = \"abcdabcdabcd\",words = ['abcd', 'abc', 'cd', 'd', 'a', 'bc'],costs = [10, 20, 30, 40, 50, 60]) == 30\n assert candidate(target = \"aaaabbbb\",words = ['a', 'aa', 'aaa', 'aaaa'],costs = [4, 3, 2, 1]) == -1\n assert candidate(target = \"abcdefghijklmnop\",words = ['a', 'bc', 'def', 'ghij', 'klmno', 'p'],costs = [1, 2, 3, 4, 5, 6]) == 21\n assert candidate(target = \"banana\",words = ['ba', 'an', 'na', 'ana', 'nana', 'banana'],costs = [1, 2, 3, 4, 5, 6]) == 6\n assert candidate(target = \"abcdefghijklmnopqrstuvwxyz\",words = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz'],costs = [3, 5, 4, 7, 6, 8, 9, 2, 1]) == 45\n assert candidate(target = \"mnopqr\",words = ['mno', 'pq', 'r', 'mnopq', 'qrs'],costs = [10, 7, 5, 20, 8]) == 22\n assert candidate(target = \"aaabbbcccddd\",words = ['aaa', 'bbb', 'ccc', 'ddd', 'ab', 'bc', 'cd'],costs = [5, 6, 7, 8, 3, 4, 5]) == 26\n assert candidate(target = \"mississippi\",words = ['mis', 'is', 'sip', 'i', 'p'],costs = [1, 2, 3, 4, 5]) == -1\n assert candidate(target = \"abcdefg\",words = ['abc', 'def', 'g', 'abcd', 'efg'],costs = [10, 20, 5, 15, 25]) == 35\n assert candidate(target = \"aabbccddeeff\",words = ['aab', 'bcc', 'dde', 'eff'],costs = [6, 7, 8, 9]) == 30\n assert candidate(target = \"aaabbbcccddd\",words = ['aaa', 'bbb', 'ccc', 'ddd', 'aab', 'bcc', 'dde'],costs = [10, 11, 12, 13, 9, 8, 7]) == 46\n assert candidate(target = \"abababababab\",words = ['aba', 'bab', 'ab'],costs = [3, 4, 1]) == 6\n assert candidate(target = \"optimization\",words = ['opt', 'im', 'iza', 'tion'],costs = [10, 20, 30, 40]) == 100\n assert candidate(target = \"xyzxyzxyzxyz\",words = ['xyz', 'xy', 'zxyz', 'zxy'],costs = [7, 5, 10, 8]) == 28\n assert candidate(target = \"ababababab\",words = ['aba', 'bab', 'ab', 'ba'],costs = [7, 8, 2, 3]) == 10\n assert candidate(target = \"qwertyuiop\",words = ['qwe', 'rty', 'ui', 'op'],costs = [7, 8, 5, 6]) == 26\n assert candidate(target = \"aaaabbbbccccdddd\",words = ['aaaa', 'bbbb', 'cccc', 'dddd', 'abc', 'bcd', 'cde', 'def'],costs = [4, 5, 6, 7, 8, 9, 10, 11]) == 22\n assert candidate(target = \"abcabcabcabc\",words = ['abc', 'bc', 'ca'],costs = [1, 2, 3]) == 4\n assert candidate(target = \"abcdefghijklmnopqrstuvwxyz\",words = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz'],costs = [10, 15, 20, 25, 30, 35, 40, 45, 50]) == 270\n assert candidate(target = \"abcdefghijklmnopqrstuvwxyz\",words = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz'],costs = [5, 5, 5, 5, 5, 5, 5, 5, 5]) == 45\n assert candidate(target = \"xyxyxyxyxy\",words = ['xy', 'yx', 'x', 'y'],costs = [4, 5, 1, 2]) == 15\n assert candidate(target = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",words = ['aa', 'bb', 'cc', 'dd', 'ee', 'ff', 'gg', 'hh', 'ii', 'jj', 'kk', 'll', 'mm', 'nn', 'oo', 'pp', 'qq', 'rr', 'ss', 'tt', 'uu', 'vv', 'ww', 'xx', 'yy', 'zz'],costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]) == 351\n assert candidate(target = \"abcdefghij\",words = ['abc', 'def', 'ghi', 'j', 'abcdefgh'],costs = [12, 15, 20, 5, 100]) == 52\n assert candidate(target = \"abcdefghijklmnopqrstuvwxyz\",words = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz'],costs = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 45\n assert candidate(target = \"ababababab\",words = ['ab', 'aba', 'bab', 'aab'],costs = [100, 200, 300, 400]) == 500\n assert candidate(target = \"mississippi\",words = ['i', 's', 'p', 'is', 'pi', 'sis', 'issi'],costs = [1, 2, 3, 4, 5, 6, 7]) == -1\n assert candidate(target = \"ababababab\",words = ['ab', 'aba', 'bab', 'ba'],costs = [1, 3, 2, 4]) == 5\n assert candidate(target = \"aabbccddeeff\",words = ['ab', 'bc', 'cd', 'de', 'ef', 'fe', 'dc', 'cb', 'ba', 'aa', 'bb', 'cc', 'dd', 'ee', 'ff'],costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 75\n assert candidate(target = \"lmnopqrstu\",words = ['lmn', 'opq', 'rst', 'u'],costs = [1, 2, 3, 4]) == 10\n assert candidate(target = \"aabbccddeeffgghhiijj\",words = ['aa', 'bb', 'cc', 'dd', 'ee', 'ff', 'gg', 'hh', 'ii', 'jj'],costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(target = \"ababababab\",words = ['aba', 'bab', 'ab', 'ba'],costs = [4, 5, 2, 3]) == 10\n assert candidate(target = \"xyxxyxyxyx\",words = ['xy', 'xxy', 'xyx', 'yxy'],costs = [5, 7, 6, 8]) == 22\n assert candidate(target = \"mississippi\",words = ['mis', 'issi', 'ppi', 'i', 'pi', 'miss', 'ippi'],costs = [3, 4, 2, 1, 5, 6, 7]) == 12\n assert candidate(target = \"aaaaaaaabaaaaaaa\",words = ['a', 'aa', 'aaa', 'aaaa', 'aaaaa'],costs = [1, 3, 5, 7, 9]) == -1\n assert candidate(target = \"abcdefghijklmnop\",words = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz'],costs = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == -1\n assert candidate(target = \"ababababab\",words = ['ab', 'aba', 'bab', 'ba', 'a', 'b'],costs = [2, 3, 4, 1, 5, 6]) == 9\n assert candidate(target = \"abcdefgabcdefg\",words = ['abc', 'def', 'gh', 'abcdef', 'gh', 'abcdefg'],costs = [10, 20, 30, 5, 50, 60]) == 120\n assert candidate(target = \"abcdefghijklmnopqrstuvwxyz\",words = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'],costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == -1\n assert candidate(target = \"abcabcabcabcabcabc\",words = ['abc', 'abca', 'bcab', 'cabc', 'bca'],costs = [1, 2, 3, 4, 5]) == 6\n assert candidate(target = \"abacabadabacaba\",words = ['aba', 'cab', 'abc', 'bac'],costs = [3, 5, 2, 4]) == -1\n assert candidate(target = \"qwertyqwerty\",words = ['qw', 'er', 'ty', 'rt', 'yt'],costs = [1, 2, 3, 4, 5]) == 12\n assert candidate(target = \"abcabcabcabcabc\",words = ['ab', 'bc', 'ca', 'abc'],costs = [2, 1, 5, 3]) == 15\n assert candidate(target = \"abcabcabcabcabcabc\",words = ['abc', 'abcabc', 'abcabcabc', 'a', 'b', 'c'],costs = [10, 20, 30, 1, 2, 3]) == 36\n assert candidate(target = \"qwertyuiopasdfghjklzxcvbnm\",words = ['qwerty', 'uiop', 'asdf', 'ghjk', 'lzx', 'cvbn', 'm', 'qwer', 'tyui', 'opas', 'dfgh', 'jklz', 'xcvb', 'bnm'],costs = [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 105\n assert candidate(target = \"abacabadabacaba\",words = ['aba', 'abac', 'abacaba', 'abacabad', 'abacabadaba'],costs = [5, 10, 15, 20, 25]) == 35\n"}, "metadata": {"canonical_parameter_names": ["target", "words", "costs"], "leetcode_dataset_entry_point": "Solution().minimumCost", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumCost(string target, vector& words, vector& costs) {", "container": "Solution", "callable": "minimumCost", "parameters": [{"name": "target", "type": "string"}, {"name": "words", "type": "vector&"}, {"name": "costs", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3216, "task_id": "lexicographically-smallest-string-after-a-swap", "difficulty": "Easy", "problem_description": "Given a string s containing only digits, return the lexicographically smallest string that can be obtained after swapping adjacent digits in s with the same parity at most once.\nDigits have the same parity if both are odd or both are even. For example, 5 and 9, as well as 2 and 4, have the same parity, while 6 and 9 do not.\n \nExample 1:\n\nInput: s = \"45320\"\nOutput: \"43520\"\nExplanation: \ns[1] == '5' and s[2] == '3' both have the same parity, and swapping them results in the lexicographically smallest string.\n\nExample 2:\n\nInput: s = \"001\"\nOutput: \"001\"\nExplanation:\nThere is no need to perform a swap because s is already the lexicographically smallest.\n\n \nConstraints:\n\n2 <= s.length <= 100\ns consists only of digits.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"9876543210\") == \"9876543210\"\n assert candidate(s = \"1324\") == \"1324\"\n assert candidate(s = \"111222333\") == \"111222333\"\n assert candidate(s = \"1352468709\") == \"1352468709\"\n assert candidate(s = \"2121212121\") == \"2121212121\"\n assert candidate(s = \"1234567890\") == \"1234567890\"\n assert candidate(s = \"9753186420\") == \"7953186420\"\n assert candidate(s = \"22222\") == \"22222\"\n assert candidate(s = \"97531\") == \"79531\"\n assert candidate(s = \"111222\") == \"111222\"\n assert candidate(s = \"001\") == \"001\"\n assert candidate(s = \"87654\") == \"87654\"\n assert candidate(s = \"1111111111\") == \"1111111111\"\n assert candidate(s = \"13579\") == \"13579\"\n assert candidate(s = \"99887766554433221100\") == \"99887766554433221100\"\n assert candidate(s = \"11111\") == \"11111\"\n assert candidate(s = \"34521\") == \"34521\"\n assert candidate(s = \"224466\") == \"224466\"\n assert candidate(s = \"24680\") == \"24608\"\n assert candidate(s = \"45320\") == \"43520\"\n assert candidate(s = \"1212121212\") == \"1212121212\"\n assert candidate(s = \"2222222222\") == \"2222222222\"\n assert candidate(s = \"86420\") == \"68420\"\n assert candidate(s = \"2204466880\") == \"2024466880\"\n assert candidate(s = \"555444333222111000\") == \"555444333222111000\"\n assert candidate(s = \"5937197531\") == \"5397197531\"\n assert candidate(s = \"8642086420\") == \"6842086420\"\n assert candidate(s = \"5432109876543210\") == \"5432109876543210\"\n assert candidate(s = \"9090909090\") == \"9090909090\"\n assert candidate(s = \"3214680975\") == \"3214608975\"\n assert candidate(s = \"555444333\") == \"555444333\"\n assert candidate(s = \"2046813579\") == \"0246813579\"\n assert candidate(s = \"999988887777\") == \"999988887777\"\n assert candidate(s = \"1232123212\") == \"1232123212\"\n assert candidate(s = \"0022446688\") == \"0022446688\"\n assert candidate(s = \"2143658709\") == \"2143658709\"\n assert candidate(s = \"4206813579\") == \"2406813579\"\n assert candidate(s = \"1222333344\") == \"1222333344\"\n assert candidate(s = \"122133445566778899\") == \"122133445566778899\"\n assert candidate(s = \"5937124680\") == \"5397124680\"\n assert candidate(s = \"1010101010\") == \"1010101010\"\n assert candidate(s = \"2718281828\") == \"2178281828\"\n assert candidate(s = \"1098765432\") == \"1098765432\"\n assert candidate(s = \"908070605040302010\") == \"900870605040302010\"\n assert candidate(s = \"98765432100987654321\") == \"98765432100987654321\"\n assert candidate(s = \"02468135791357\") == \"02468135719357\"\n assert candidate(s = \"9080706050\") == \"9008706050\"\n assert candidate(s = \"8642013579\") == \"6842013579\"\n assert candidate(s = \"9753124680\") == \"7953124680\"\n assert candidate(s = \"5973186420\") == \"5793186420\"\n assert candidate(s = \"8888888888\") == \"8888888888\"\n assert candidate(s = \"1122334455\") == \"1122334455\"\n assert candidate(s = \"4444444444\") == \"4444444444\"\n assert candidate(s = \"5432013579\") == \"5430213579\"\n assert candidate(s = \"8642097531\") == \"6842097531\"\n assert candidate(s = \"01234567890123456789\") == \"01234567890123456789\"\n assert candidate(s = \"2020202020\") == \"0220202020\"\n assert candidate(s = \"000011112222\") == \"000011112222\"\n assert candidate(s = \"1020304050\") == \"1002304050\"\n assert candidate(s = \"1357924680\") == \"1357924608\"\n assert candidate(s = \"4206842068\") == \"2406842068\"\n assert candidate(s = \"5555555555\") == \"5555555555\"\n assert candidate(s = \"6284095713\") == \"2684095713\"\n assert candidate(s = \"135792468097531\") == \"135792460897531\"\n assert candidate(s = \"5959595959\") == \"5599595959\"\n assert candidate(s = \"1357902468\") == \"1357902468\"\n assert candidate(s = \"0246813579\") == \"0246813579\"\n assert candidate(s = \"0426813579\") == \"0246813579\"\n assert candidate(s = \"5173924680\") == \"1573924680\"\n assert candidate(s = \"8886664442\") == \"8868664442\"\n assert candidate(s = \"98765432109876543210\") == \"98765432109876543210\"\n assert candidate(s = \"9988776655\") == \"9988776655\"\n assert candidate(s = \"2468024680\") == \"2460824680\"\n assert candidate(s = \"7931524860\") == \"7391524860\"\n assert candidate(s = \"6283185307\") == \"2683185307\"\n assert candidate(s = \"111222333444555666777888999\") == \"111222333444555666777888999\"\n assert candidate(s = \"3141592653\") == \"1341592653\"\n assert candidate(s = \"3852764190\") == \"3852746190\"\n assert candidate(s = \"22446688001133557799\") == \"22446680801133557799\"\n assert candidate(s = \"3658742910\") == \"3658724910\"\n assert candidate(s = \"9876543211\") == \"9876543211\"\n assert candidate(s = \"222221111\") == \"222221111\"\n assert candidate(s = \"6868686868\") == \"6688686868\"\n assert candidate(s = \"4826035791\") == \"4286035791\"\n assert candidate(s = \"4443332221\") == \"4443332221\"\n assert candidate(s = \"9182736450\") == \"1982736450\"\n assert candidate(s = \"24680246802468024680\") == \"24608246802468024680\"\n assert candidate(s = \"8064213579\") == \"0864213579\"\n assert candidate(s = \"5678904321\") == \"5678904321\"\n assert candidate(s = \"0123456789\") == \"0123456789\"\n assert candidate(s = \"2200446688\") == \"2020446688\"\n assert candidate(s = \"3322110099\") == \"3322110099\"\n assert candidate(s = \"8976543210\") == \"8796543210\"\n assert candidate(s = \"1133557799\") == \"1133557799\"\n assert candidate(s = \"1357913579\") == \"1357193579\"\n assert candidate(s = \"9864213579\") == \"9684213579\"\n assert candidate(s = \"999888777666555444333222111\") == \"999888777666555444333222111\"\n assert candidate(s = \"9999999999\") == \"9999999999\"\n assert candidate(s = \"5432109876\") == \"5432109876\"\n assert candidate(s = \"4321056789\") == \"4321056789\"\n assert candidate(s = \"1235467890\") == \"1235467890\"\n assert candidate(s = \"35791\") == \"35719\"\n assert candidate(s = \"0246802468\") == \"0246082468\"\n assert candidate(s = \"3131313131\") == \"1331313131\"\n assert candidate(s = \"0987654321\") == \"0987654321\"\n assert candidate(s = \"5024019292\") == \"5020419292\"\n assert candidate(s = \"999888777\") == \"999888777\"\n assert candidate(s = \"0909090909\") == \"0909090909\"\n assert candidate(s = \"4442220006\") == \"4424220006\"\n assert candidate(s = \"2468013579\") == \"2460813579\"\n assert candidate(s = \"123456789987654321\") == \"123456789987654321\"\n assert candidate(s = \"01010101010101010101\") == \"01010101010101010101\"\n assert candidate(s = \"8192837465\") == \"8192837465\"\n assert candidate(s = \"102030405060708090\") == \"100230405060708090\"\n assert candidate(s = \"5432101234\") == \"5432101234\"\n assert candidate(s = \"000999888\") == \"000999888\"\n assert candidate(s = \"1246835790\") == \"1246835790\"\n assert candidate(s = \"10101010101010101010\") == \"10101010101010101010\"\n assert candidate(s = \"4040404040\") == \"0440404040\"\n assert candidate(s = \"5937186420\") == \"5397186420\"\n assert candidate(s = \"7777777777\") == \"7777777777\"\n assert candidate(s = \"6789012345\") == \"6789012345\"\n assert candidate(s = \"2468097531\") == \"2460897531\"\n assert candidate(s = \"2132132132\") == \"2132132132\"\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().getSmallestString", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string getSmallestString(string s) {", "container": "Solution", "callable": "getSmallestString", "parameters": [{"name": "s", "type": "string"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3217, "task_id": "delete-nodes-from-linked-list-present-in-array", "difficulty": "Medium", "problem_description": "You are given an array of integers nums and the head of a linked list. Return the head of the modified linked list after removing all nodes from the linked list that have a value that exists in nums.\n \nExample 1:\n\nInput: nums = [1,2,3], head = [1,2,3,4,5]\nOutput: [4,5]\nExplanation:\n\nRemove the nodes with values 1, 2, and 3.\n\nExample 2:\n\nInput: nums = [1], head = [1,2,1,2,1,2]\nOutput: [2,2,2]\nExplanation:\n\nRemove the nodes with value 1.\n\nExample 3:\n\nInput: nums = [5], head = [1,2,3,4]\nOutput: [1,2,3,4]\nExplanation:\n\nNo node has value 5.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 105\nAll elements in nums are unique.\nThe number of nodes in the given list is in the range [1, 105].\n1 <= Node.val <= 105\nThe input is generated such that there is at least one node in the linked list that has a value not present in nums.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert is_same_list(candidate(nums = [3, 4, 5],head = list_node([1, 2, 3, 4, 5])), list_node([1, 2]))\n assert is_same_list(candidate(nums = [10],head = list_node([1, 10, 100, 1000])), list_node([1, 100, 1000]))\n assert is_same_list(candidate(nums = [1],head = list_node([1, 2, 1, 2, 1, 2])), list_node([2, 2, 2]))\n assert is_same_list(candidate(nums = [1, 2, 3],head = list_node([1, 2, 3, 4, 5])), list_node([4, 5]))\n assert is_same_list(candidate(nums = [2, 4, 6, 8, 10],head = list_node([1, 3, 5, 7, 9])), list_node([1, 3, 5, 7, 9]))\n assert is_same_list(candidate(nums = [100000],head = list_node([1, 2, 3, 4, 100000])), list_node([1, 2, 3, 4]))\n assert is_same_list(candidate(nums = [1, 3, 5, 7, 9],head = list_node([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])), list_node([0, 2, 4, 6, 8, 10]))\n assert is_same_list(candidate(nums = [2, 4],head = list_node([1, 2, 3, 4, 5])), list_node([1, 3, 5]))\n assert is_same_list(candidate(nums = [5],head = list_node([1, 2, 3, 4])), list_node([1, 2, 3, 4]))\n assert is_same_list(candidate(nums = [10, 20, 30],head = list_node([5, 10, 15, 20, 25, 30, 35])), list_node([5, 15, 25, 35]))\n assert is_same_list(candidate(nums = [10, 20, 30],head = list_node([5, 10, 15, 20, 25, 30])), list_node([5, 15, 25]))\n assert is_same_list(candidate(nums = [100000],head = list_node([99999, 100000, 100001])), list_node([99999, 100001]))\n assert is_same_list(candidate(nums = [1, 3, 5, 7, 9],head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])), list_node([2, 4, 6, 8, 10]))\n assert is_same_list(candidate(nums = [7, 8, 9],head = list_node([7, 8, 9, 10, 11, 12])), list_node([10, 11, 12]))\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],head = list_node([10, 9, 8, 7, 6, 5, 4, 3, 2, 1])) == None\n assert is_same_list(candidate(nums = [5, 10, 15, 20, 25, 30],head = list_node([5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60])), list_node([35, 40, 45, 50, 55, 60]))\n assert is_same_list(candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20])), list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19]))\n assert is_same_list(candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100])), list_node([1, 2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 16, 17, 18, 19, 21, 22, 23, 24, 26, 27, 28, 29, 31, 32, 33, 34, 36, 37, 38, 39, 41, 42, 43, 44, 46, 47, 48, 49, 51, 52, 53, 54, 56, 57, 58, 59, 61, 62, 63, 64, 66, 67, 68, 69, 71, 72, 73, 74, 76, 77, 78, 79, 81, 82, 83, 84, 86, 87, 88, 89, 91, 92, 93, 94, 96, 97, 98, 99]))\n assert is_same_list(candidate(nums = [100000],head = list_node([50000, 100000, 150000, 200000])), list_node([50000, 150000, 200000]))\n assert is_same_list(candidate(nums = [1, 3, 5, 7, 9],head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])), list_node([2, 4, 6, 8, 10]))\n assert is_same_list(candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20])), list_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 20]))\n assert is_same_list(candidate(nums = [1, 3, 5, 7, 9],head = list_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 20])), list_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 20]))\n assert is_same_list(candidate(nums = [1000, 2000, 3000, 4000, 5000],head = list_node([5000, 4000, 3000, 2000, 1000, 500, 400, 300, 200, 100])), list_node([500, 400, 300, 200, 100]))\n assert is_same_list(candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20])), list_node([16, 17, 18, 19, 20]))\n assert is_same_list(candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200])), list_node([110, 120, 130, 140, 150, 160, 170, 180, 190, 200]))\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])) == None\n assert is_same_list(candidate(nums = [1, 3, 5, 7, 9],head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])), list_node([2, 4, 6, 8, 10]))\n assert is_same_list(candidate(nums = [5, 10, 15, 20, 25],head = list_node([1, 5, 10, 15, 20, 25, 30, 35])), list_node([1, 30, 35]))\n assert is_same_list(candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],head = list_node([1, 10, 2, 20, 3, 30, 4, 40, 5, 50, 6, 60, 7, 70, 8, 80, 9, 90, 10, 100, 11])), list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 11]))\n assert is_same_list(candidate(nums = [7, 8, 9],head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13])), list_node([1, 2, 3, 4, 5, 6, 10, 11, 12, 13]))\n assert is_same_list(candidate(nums = [5, 15, 25, 35, 45, 55],head = list_node([5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60])), list_node([10, 20, 30, 40, 50, 60]))\n assert is_same_list(candidate(nums = [2],head = list_node([1, 2, 3, 2, 4, 2, 5, 2, 6, 2, 7, 2, 8, 2, 9, 2, 10, 2])), list_node([1, 3, 4, 5, 6, 7, 8, 9, 10]))\n assert is_same_list(candidate(nums = [1, 5, 10, 15, 20],head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20])), list_node([2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 16, 17, 18, 19]))\n assert is_same_list(candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],head = list_node([1, 90, 2, 91, 3, 92, 4, 93, 5, 94, 6, 95, 7, 96, 8, 97, 9, 98, 10, 99])), list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]))\n assert is_same_list(candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40])), list_node([31, 32, 33, 34, 35, 36, 37, 38, 39, 40]))\n assert is_same_list(candidate(nums = [1, 4, 9, 16, 25],head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16])), list_node([2, 3, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15]))\n assert is_same_list(candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150])), list_node([110, 120, 130, 140, 150]))\n assert is_same_list(candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])), list_node([11, 12, 13, 14, 15]))\n assert is_same_list(candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],head = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31])), list_node([1, 5, 7, 11, 13, 17, 19, 23, 25, 29, 31]))\n assert is_same_list(candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],head = list_node([10, 100, 20, 200, 30, 300, 40, 400, 50, 500, 60, 600, 70, 700, 80, 800, 90, 900, 100, 1000])), list_node([200, 300, 400, 500, 600, 700, 800, 900, 1000]))\n assert is_same_list(candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],head = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39])), list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]))\n assert is_same_list(candidate(nums = [1, 11, 21, 31, 41, 51, 61, 71, 81, 91],head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 21, 31, 41, 51, 61, 71, 81, 91, 101])), list_node([2, 3, 4, 5, 6, 7, 8, 9, 10, 101]))\n assert is_same_list(candidate(nums = [3, 5, 7, 9, 11],head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])), list_node([1, 2, 4, 6, 8, 10, 12]))\n assert is_same_list(candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25])), list_node([21, 22, 23, 24, 25]))\n assert is_same_list(candidate(nums = [1, 11, 21, 31, 41, 51],head = list_node([1, 11, 21, 31, 41, 51, 61, 71, 81, 91, 101, 111, 121, 131, 141, 151])), list_node([61, 71, 81, 91, 101, 111, 121, 131, 141, 151]))\n assert is_same_list(candidate(nums = [100, 200, 300, 400, 500],head = list_node([100, 150, 200, 250, 300, 350, 400, 450, 500, 550])), list_node([150, 250, 350, 450, 550]))\n assert is_same_list(candidate(nums = [100000],head = list_node([1, 50000, 100000, 150000, 200000])), list_node([1, 50000, 150000, 200000]))\n assert is_same_list(candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70])), list_node([1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 15, 16, 17, 18, 19, 20, 22, 23, 24, 25, 26, 27, 29, 30, 31, 32, 33, 34, 36, 37, 38, 39, 40, 41, 43, 44, 45, 46, 47, 48, 50, 51, 52, 53, 54, 55, 57, 58, 59, 60, 61, 62, 64, 65, 66, 67, 68, 69]))\n assert is_same_list(candidate(nums = [100, 200, 300, 400, 500],head = list_node([50, 100, 150, 200, 250, 300, 350, 400, 450, 500])), list_node([50, 150, 250, 350, 450]))\n assert is_same_list(candidate(nums = [5, 10, 15],head = list_node([1, 5, 10, 15, 20, 25, 30])), list_node([1, 20, 25, 30]))\n assert candidate(nums = [5],head = list_node([5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5])) == None\n assert is_same_list(candidate(nums = [15, 16, 17, 18, 19],head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20])), list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 20]))\n assert is_same_list(candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],head = list_node([10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20])), list_node([11, 12, 13, 14, 15, 16, 17, 18, 19, 20]))\n assert is_same_list(candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20])), list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19]))\n assert is_same_list(candidate(nums = [2, 4, 6, 8],head = list_node([2, 4, 6, 8, 10, 12, 14, 16])), list_node([10, 12, 14, 16]))\n assert is_same_list(candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30])), list_node([1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20, 22, 23, 25, 26, 28, 29]))\n assert is_same_list(candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15],head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16])), list_node([2, 4, 6, 8, 10, 12, 14, 16]))\n assert is_same_list(candidate(nums = [2, 5, 7, 10],head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])), list_node([1, 3, 4, 6, 8, 9, 11]))\n assert is_same_list(candidate(nums = [100000],head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 100000])), list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]))\n assert is_same_list(candidate(nums = [1, 100, 1000, 10000, 100000],head = list_node([1, 10, 100, 1000, 10000, 100000])), list_node([10]))\n assert candidate(nums = [1, 2, 3],head = list_node([3, 2, 1, 3, 2, 1, 3, 2, 1])) == None\n assert is_same_list(candidate(nums = [1, 5, 10, 15, 20, 25, 30],head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20])), list_node([2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 16, 17, 18, 19]))\n assert is_same_list(candidate(nums = [1, 10, 100, 1000, 10000],head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 100, 1000, 10000])), list_node([2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]))\n assert is_same_list(candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])), list_node([11, 12, 13, 14, 15]))\n assert is_same_list(candidate(nums = [1, 100, 10000, 100000],head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 100, 200, 300, 400, 500, 10000, 20000, 30000, 40000, 50000, 100000])), list_node([2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 200, 300, 400, 500, 20000, 30000, 40000, 50000]))\n assert is_same_list(candidate(nums = [10, 20, 30, 40, 50],head = list_node([5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55])), list_node([5, 15, 25, 35, 45, 55]))\n assert is_same_list(candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],head = list_node([5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100])), list_node([55, 60, 65, 70, 75, 80, 85, 90, 95, 100]))\n assert candidate(nums = [1, 2, 3],head = list_node([3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1])) == None\n assert is_same_list(candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],head = list_node([1, 11, 21, 31, 41, 51, 61, 71, 81, 91, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200])), list_node([1, 11, 21, 31, 41, 51, 61, 71, 81, 91, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]))\n assert is_same_list(candidate(nums = [5, 10, 15, 20, 25],head = list_node([5, 10, 15, 20, 25, 30, 35, 40])), list_node([30, 35, 40]))\n assert is_same_list(candidate(nums = [10, 20, 30, 40, 50],head = list_node([50, 40, 30, 20, 10, 0, -10, -20, -30])), list_node([0, -10, -20, -30]))\n assert is_same_list(candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],head = list_node([5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100])), list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100]))\n assert is_same_list(candidate(nums = [1, 100, 1000, 10000, 100000],head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 100, 101, 102, 103, 104, 105, 1000, 1001, 1002, 10000, 10001])), list_node([2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 101, 102, 103, 104, 105, 1001, 1002, 10001]))\n assert is_same_list(candidate(nums = [5],head = list_node([1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5])), list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150])), list_node([110, 120, 130, 140, 150]))\n assert is_same_list(candidate(nums = [15, 16, 17, 18, 19, 20],head = list_node([10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25])), list_node([10, 11, 12, 13, 14, 21, 22, 23, 24, 25]))\n assert is_same_list(candidate(nums = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000],head = list_node([10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000, 110000, 120000, 130000, 140000, 150000])), list_node([110000, 120000, 130000, 140000, 150000]))\n assert is_same_list(candidate(nums = [2, 5, 7, 11, 13],head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])), list_node([1, 3, 4, 6, 8, 9, 10, 12, 14, 15]))\n assert is_same_list(candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19],head = list_node([2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31])), list_node([23, 29, 31]))\n assert is_same_list(candidate(nums = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50],head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50])), list_node([2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 16, 17, 18, 19, 21, 22, 23, 24, 26, 27, 28, 29, 31, 32, 33, 34, 36, 37, 38, 39, 41, 42, 43, 44, 46, 47, 48, 49]))\n assert is_same_list(candidate(nums = [100, 200, 300, 400, 500],head = list_node([100, 200, 300, 400, 500, 600, 700, 800, 900])), list_node([600, 700, 800, 900]))\n assert candidate(nums = [5],head = list_node([5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5])) == None\n assert is_same_list(candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],head = list_node([1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10])), list_node([6, 6, 7, 7, 8, 8, 9, 9, 10, 10]))\n assert is_same_list(candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25])), list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 22, 23, 24, 25]))\n assert is_same_list(candidate(nums = [50000, 50001, 50002, 50003, 50004, 50005],head = list_node([49999, 50000, 50001, 50002, 50003, 50004, 50005, 50006])), list_node([49999, 50006]))\n assert is_same_list(candidate(nums = [5, 25, 45, 65, 85, 105],head = list_node([5, 20, 25, 40, 45, 60, 65, 80, 85, 100, 105, 120, 130, 140, 150])), list_node([20, 40, 60, 80, 100, 120, 130, 140, 150]))\n assert is_same_list(candidate(nums = [100000],head = list_node([100000, 99999, 99998, 99997, 99996])), list_node([99999, 99998, 99997, 99996]))\n assert is_same_list(candidate(nums = [5, 10, 15, 20, 25],head = list_node([1, 5, 9, 10, 14, 19, 20, 24, 25])), list_node([1, 9, 14, 19, 24]))\n assert is_same_list(candidate(nums = [20, 40, 60, 80, 100],head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110])), list_node([10, 30, 50, 70, 90, 110]))\n assert is_same_list(candidate(nums = [1, 10, 100, 1000, 10000, 100000],head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000, 200000])), list_node([2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 200, 300, 400, 500, 600, 700, 800, 900, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 200000]))\n assert is_same_list(candidate(nums = [1, 3, 5, 7, 9, 11],head = list_node([2, 4, 6, 8, 10, 12, 14])), list_node([2, 4, 6, 8, 10, 12, 14]))\n assert is_same_list(candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49],head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50])), list_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50]))\n"}, "metadata": {"canonical_parameter_names": ["nums", "head"], "leetcode_dataset_entry_point": "Solution().modifiedList", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "ListNode* modifiedList(vector& nums, ListNode* head) {", "container": "Solution", "callable": "modifiedList", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "head", "type": "ListNode*"}], "return_type": "ListNode*", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3218, "task_id": "minimum-cost-for-cutting-cake-i", "difficulty": "Medium", "problem_description": "There is an m x n cake that needs to be cut into 1 x 1 pieces.\nYou are given integers m, n, and two arrays:\n\nhorizontalCut of size m - 1, where horizontalCut[i] represents the cost to cut along the horizontal line i.\nverticalCut of size n - 1, where verticalCut[j] represents the cost to cut along the vertical line j.\n\nIn one operation, you can choose any piece of cake that is not yet a 1 x 1 square and perform one of the following cuts:\n\nCut along a horizontal line i at a cost of horizontalCut[i].\nCut along a vertical line j at a cost of verticalCut[j].\n\nAfter the cut, the piece of cake is divided into two distinct pieces.\nThe cost of a cut depends only on the initial cost of the line and does not change.\nReturn the minimum total cost to cut the entire cake into 1 x 1 pieces.\n \nExample 1:\n\nInput: m = 3, n = 2, horizontalCut = [1,3], verticalCut = [5]\nOutput: 13\nExplanation:\n\n\nPerform a cut on the vertical line 0 with cost 5, current total cost is 5.\nPerform a cut on the horizontal line 0 on 3 x 1 subgrid with cost 1.\nPerform a cut on the horizontal line 0 on 3 x 1 subgrid with cost 1.\nPerform a cut on the horizontal line 1 on 2 x 1 subgrid with cost 3.\nPerform a cut on the horizontal line 1 on 2 x 1 subgrid with cost 3.\n\nThe total cost is 5 + 1 + 1 + 3 + 3 = 13.\n\nExample 2:\n\nInput: m = 2, n = 2, horizontalCut = [7], verticalCut = [4]\nOutput: 15\nExplanation:\n\nPerform a cut on the horizontal line 0 with cost 7.\nPerform a cut on the vertical line 0 on 1 x 2 subgrid with cost 4.\nPerform a cut on the vertical line 0 on 1 x 2 subgrid with cost 4.\n\nThe total cost is 7 + 4 + 4 = 15.\n\n \nConstraints:\n\n1 <= m, n <= 20\nhorizontalCut.length == m - 1\nverticalCut.length == n - 1\n1 <= horizontalCut[i], verticalCut[i] <= 103\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(m = 5,n = 4,horizontalCut = [1, 2, 3, 4],verticalCut = [2, 4, 6]) == 49\n assert candidate(m = 4,n = 3,horizontalCut = [2, 5, 7],verticalCut = [3, 8]) == 47\n assert candidate(m = 2,n = 2,horizontalCut = [7],verticalCut = [4]) == 15\n assert candidate(m = 4,n = 3,horizontalCut = [1, 2, 3],verticalCut = [1, 2]) == 17\n assert candidate(m = 5,n = 4,horizontalCut = [1, 4, 6, 8],verticalCut = [2, 3, 5]) == 61\n assert candidate(m = 6,n = 5,horizontalCut = [1, 3, 5, 7, 9],verticalCut = [2, 4, 6, 8]) == 115\n assert candidate(m = 3,n = 3,horizontalCut = [1, 2],verticalCut = [1, 2]) == 11\n assert candidate(m = 5,n = 4,horizontalCut = [1, 2, 3, 4],verticalCut = [1, 2, 3]) == 36\n assert candidate(m = 5,n = 4,horizontalCut = [1, 3, 6, 9],verticalCut = [2, 4, 7]) == 68\n assert candidate(m = 3,n = 2,horizontalCut = [1, 3],verticalCut = [5]) == 13\n assert candidate(m = 4,n = 3,horizontalCut = [2, 5, 7],verticalCut = [1, 6]) == 37\n assert candidate(m = 4,n = 3,horizontalCut = [2, 4, 6],verticalCut = [1, 3]) == 27\n assert candidate(m = 18,n = 16,horizontalCut = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54],verticalCut = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 2598\n assert candidate(m = 15,n = 12,horizontalCut = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],verticalCut = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36]) == 3763\n assert candidate(m = 10,n = 10,horizontalCut = [3, 6, 9, 12, 15, 18, 21, 24, 27],verticalCut = [2, 5, 8, 11, 14, 17, 20, 23, 26]) == 1071\n assert candidate(m = 7,n = 6,horizontalCut = [1, 3, 5, 7, 9, 11],verticalCut = [2, 4, 6, 8, 10]) == 191\n assert candidate(m = 10,n = 8,horizontalCut = [3, 6, 9, 12, 15, 18, 21, 24, 27],verticalCut = [2, 5, 8, 11, 14, 17, 20, 23]) == 891\n assert candidate(m = 8,n = 8,horizontalCut = [1, 3, 5, 7, 9, 11, 13, 15],verticalCut = [1, 3, 5, 7, 9, 11, 13, 15]) == 455\n assert candidate(m = 10,n = 5,horizontalCut = [10, 20, 30, 40, 50, 60, 70, 80, 90],verticalCut = [5, 15, 25, 35, 45]) == 1500\n assert candidate(m = 18,n = 16,horizontalCut = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50, 53],verticalCut = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48]) == 5983\n assert candidate(m = 12,n = 8,horizontalCut = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72],verticalCut = [4, 8, 12, 16, 20, 24, 28, 32]) == 2036\n assert candidate(m = 12,n = 10,horizontalCut = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48],verticalCut = [2, 6, 10, 14, 18, 20, 24, 28, 32, 36]) == 2216\n assert candidate(m = 18,n = 12,horizontalCut = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54],verticalCut = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]) == 3045\n assert candidate(m = 12,n = 10,horizontalCut = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55],verticalCut = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 1523\n assert candidate(m = 12,n = 12,horizontalCut = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],verticalCut = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22]) == 1199\n assert candidate(m = 15,n = 10,horizontalCut = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],verticalCut = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == 2874\n assert candidate(m = 16,n = 20,horizontalCut = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],verticalCut = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38]) == 4240\n assert candidate(m = 20,n = 20,horizontalCut = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],verticalCut = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 6289\n assert candidate(m = 10,n = 8,horizontalCut = [10, 20, 30, 40, 50, 60, 70, 80, 90],verticalCut = [5, 15, 25, 35, 45, 55, 65, 75]) == 2900\n assert candidate(m = 6,n = 6,horizontalCut = [2, 4, 6, 8, 10, 12],verticalCut = [1, 3, 5, 7, 9, 11]) == 220\n assert candidate(m = 8,n = 7,horizontalCut = [2, 4, 6, 8, 10, 12, 14],verticalCut = [1, 3, 5, 7, 9, 11]) == 289\n assert candidate(m = 10,n = 8,horizontalCut = [3, 6, 9, 12, 15, 18, 21, 24, 27],verticalCut = [2, 4, 6, 8, 10, 12, 14, 16]) == 733\n assert candidate(m = 19,n = 14,horizontalCut = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18],verticalCut = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) == 1536\n assert candidate(m = 11,n = 12,horizontalCut = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33],verticalCut = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]) == 1652\n assert candidate(m = 9,n = 7,horizontalCut = [2, 4, 6, 8, 10, 12, 14, 16],verticalCut = [1, 3, 5, 7, 9, 11, 13]) == 413\n assert candidate(m = 10,n = 10,horizontalCut = [2, 4, 6, 8, 10, 12, 14, 16, 18],verticalCut = [3, 6, 9, 12, 15, 18, 21, 24, 27]) == 888\n assert candidate(m = 8,n = 7,horizontalCut = [7, 14, 21, 28, 35, 42, 49, 56],verticalCut = [5, 10, 15, 20, 25, 30, 35]) == 1234\n assert candidate(m = 20,n = 20,horizontalCut = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],verticalCut = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 2850\n assert candidate(m = 15,n = 10,horizontalCut = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],verticalCut = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 865\n assert candidate(m = 18,n = 15,horizontalCut = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90],verticalCut = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45]) == 6621\n assert candidate(m = 15,n = 15,horizontalCut = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],verticalCut = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 2674\n assert candidate(m = 16,n = 14,horizontalCut = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],verticalCut = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65]) == 7675\n assert candidate(m = 20,n = 20,horizontalCut = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],verticalCut = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 6099\n assert candidate(m = 7,n = 10,horizontalCut = [3, 6, 9, 12, 15, 18, 21],verticalCut = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 714\n assert candidate(m = 20,n = 15,horizontalCut = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190],verticalCut = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95]) == 16810\n assert candidate(m = 16,n = 14,horizontalCut = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],verticalCut = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) == 1212\n assert candidate(m = 20,n = 15,horizontalCut = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],verticalCut = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 1835\n assert candidate(m = 15,n = 15,horizontalCut = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70],verticalCut = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70]) == 6125\n assert candidate(m = 15,n = 10,horizontalCut = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145],verticalCut = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 6850\n assert candidate(m = 15,n = 12,horizontalCut = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42],verticalCut = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]) == 2267\n assert candidate(m = 6,n = 5,horizontalCut = [7, 14, 21, 28, 35],verticalCut = [4, 8, 12, 16, 20]) == 405\n assert candidate(m = 15,n = 12,horizontalCut = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135],verticalCut = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39]) == 4578\n assert candidate(m = 12,n = 9,horizontalCut = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],verticalCut = [1, 2, 3, 4, 5, 6, 7, 8]) == 414\n assert candidate(m = 7,n = 9,horizontalCut = [3, 6, 9, 12, 15, 18],verticalCut = [2, 4, 6, 8, 10, 12, 14, 16]) == 465\n assert candidate(m = 16,n = 16,horizontalCut = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48],verticalCut = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47]) == 5070\n"}, "metadata": {"canonical_parameter_names": ["m", "n", "horizontalCut", "verticalCut"], "leetcode_dataset_entry_point": "Solution().minimumCost", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumCost(int m, int n, vector& horizontalCut, vector& verticalCut) {", "container": "Solution", "callable": "minimumCost", "parameters": [{"name": "m", "type": "int"}, {"name": "n", "type": "int"}, {"name": "horizontalCut", "type": "vector&"}, {"name": "verticalCut", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3219, "task_id": "minimum-cost-for-cutting-cake-ii", "difficulty": "Hard", "problem_description": "There is an m x n cake that needs to be cut into 1 x 1 pieces.\nYou are given integers m, n, and two arrays:\n\nhorizontalCut of size m - 1, where horizontalCut[i] represents the cost to cut along the horizontal line i.\nverticalCut of size n - 1, where verticalCut[j] represents the cost to cut along the vertical line j.\n\nIn one operation, you can choose any piece of cake that is not yet a 1 x 1 square and perform one of the following cuts:\n\nCut along a horizontal line i at a cost of horizontalCut[i].\nCut along a vertical line j at a cost of verticalCut[j].\n\nAfter the cut, the piece of cake is divided into two distinct pieces.\nThe cost of a cut depends only on the initial cost of the line and does not change.\nReturn the minimum total cost to cut the entire cake into 1 x 1 pieces.\n \nExample 1:\n\nInput: m = 3, n = 2, horizontalCut = [1,3], verticalCut = [5]\nOutput: 13\nExplanation:\n\n\nPerform a cut on the vertical line 0 with cost 5, current total cost is 5.\nPerform a cut on the horizontal line 0 on 3 x 1 subgrid with cost 1.\nPerform a cut on the horizontal line 0 on 3 x 1 subgrid with cost 1.\nPerform a cut on the horizontal line 1 on 2 x 1 subgrid with cost 3.\nPerform a cut on the horizontal line 1 on 2 x 1 subgrid with cost 3.\n\nThe total cost is 5 + 1 + 1 + 3 + 3 = 13.\n\nExample 2:\n\nInput: m = 2, n = 2, horizontalCut = [7], verticalCut = [4]\nOutput: 15\nExplanation:\n\nPerform a cut on the horizontal line 0 with cost 7.\nPerform a cut on the vertical line 0 on 1 x 2 subgrid with cost 4.\nPerform a cut on the vertical line 0 on 1 x 2 subgrid with cost 4.\n\nThe total cost is 7 + 4 + 4 = 15.\n\n \nConstraints:\n\n1 <= m, n <= 105\nhorizontalCut.length == m - 1\nverticalCut.length == n - 1\n1 <= horizontalCut[i], verticalCut[i] <= 103\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(m = 2,n = 2,horizontalCut = [7],verticalCut = [4]) == 15\n assert candidate(m = 4,n = 3,horizontalCut = [1, 2, 3],verticalCut = [1, 2]) == 17\n assert candidate(m = 3,n = 3,horizontalCut = [1, 2],verticalCut = [1, 2]) == 11\n assert candidate(m = 5,n = 4,horizontalCut = [1, 2, 3, 4],verticalCut = [1, 2, 3]) == 36\n assert candidate(m = 6,n = 3,horizontalCut = [1, 2, 3, 4, 5],verticalCut = [1, 2]) == 32\n assert candidate(m = 4,n = 3,horizontalCut = [2, 4, 6],verticalCut = [1, 3, 5]) == 39\n assert candidate(m = 3,n = 2,horizontalCut = [1, 3],verticalCut = [5]) == 13\n assert candidate(m = 15,n = 10,horizontalCut = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],verticalCut = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 660\n assert candidate(m = 8,n = 12,horizontalCut = [1, 2, 3, 4, 5, 6, 7],verticalCut = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 346\n assert candidate(m = 8,n = 12,horizontalCut = [1, 2, 3, 4, 5, 6, 7],verticalCut = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 346\n assert candidate(m = 15,n = 15,horizontalCut = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],verticalCut = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 1225\n assert candidate(m = 10,n = 10,horizontalCut = [1, 3, 5, 7, 9, 11, 13, 15, 17],verticalCut = [2, 4, 6, 8, 10, 12, 14, 16, 18]) == 696\n assert candidate(m = 8,n = 7,horizontalCut = [1, 3, 5, 7, 9, 11, 13],verticalCut = [2, 4, 6, 8, 10, 12]) == 294\n assert candidate(m = 7,n = 8,horizontalCut = [10, 20, 30, 40, 50, 60],verticalCut = [5, 10, 15, 20, 25, 30, 35]) == 1080\n assert candidate(m = 9,n = 11,horizontalCut = [1, 2, 3, 4, 5, 6, 7, 8],verticalCut = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 367\n assert candidate(m = 12,n = 8,horizontalCut = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],verticalCut = [1, 2, 3, 4, 5, 6, 7]) == 346\n assert candidate(m = 10,n = 10,horizontalCut = [1, 2, 3, 4, 5, 6, 7, 8, 9],verticalCut = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 375\n assert candidate(m = 9,n = 9,horizontalCut = [5, 10, 15, 20, 25, 30, 35, 40],verticalCut = [5, 10, 15, 20, 25, 30, 35, 40]) == 1380\n assert candidate(m = 8,n = 6,horizontalCut = [1, 2, 3, 4, 5, 6, 7],verticalCut = [1, 2, 3, 4, 5]) == 128\n assert candidate(m = 12,n = 11,horizontalCut = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],verticalCut = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 561\n assert candidate(m = 100,n = 100,horizontalCut = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99],verticalCut = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99]) == 338250\n assert candidate(m = 99,n = 100,horizontalCut = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98],verticalCut = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99]) == 333201\n assert candidate(m = 8,n = 8,horizontalCut = [1, 2, 3, 4, 5, 6, 7],verticalCut = [1, 2, 3, 4, 5, 6, 7]) == 196\n assert candidate(m = 10,n = 10,horizontalCut = [10, 20, 30, 40, 50, 60, 70, 80, 90],verticalCut = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 3750\n assert candidate(m = 10,n = 10,horizontalCut = [1, 9, 2, 8, 3, 7, 4, 6, 5],verticalCut = [1, 9, 2, 8, 3, 7, 4, 6, 5]) == 375\n assert candidate(m = 10,n = 10,horizontalCut = [1, 2, 3, 4, 5, 6, 7, 8, 9],verticalCut = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 375\n assert candidate(m = 15,n = 10,horizontalCut = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],verticalCut = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 660\n"}, "metadata": {"canonical_parameter_names": ["m", "n", "horizontalCut", "verticalCut"], "leetcode_dataset_entry_point": "Solution().minimumCost", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "long long minimumCost(int m, int n, vector& horizontalCut, vector& verticalCut) {", "container": "Solution", "callable": "minimumCost", "parameters": [{"name": "m", "type": "int"}, {"name": "n", "type": "int"}, {"name": "horizontalCut", "type": "vector&"}, {"name": "verticalCut", "type": "vector&"}], "return_type": "long long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3222, "task_id": "find-the-winning-player-in-coin-game", "difficulty": "Easy", "problem_description": "You are given two positive integers x and y, denoting the number of coins with values 75 and 10 respectively.\nAlice and Bob are playing a game. Each turn, starting with Alice, the player must pick up coins with a total value 115. If the player is unable to do so, they lose the game.\nReturn the name of the player who wins the game if both players play optimally.\n \nExample 1:\n\nInput: x = 2, y = 7\nOutput: \"Alice\"\nExplanation:\nThe game ends in a single turn:\n\nAlice picks 1 coin with a value of 75 and 4 coins with a value of 10.\n\n\nExample 2:\n\nInput: x = 4, y = 11\nOutput: \"Bob\"\nExplanation:\nThe game ends in 2 turns:\n\nAlice picks 1 coin with a value of 75 and 4 coins with a value of 10.\nBob picks 1 coin with a value of 75 and 4 coins with a value of 10.\n\n\n \nConstraints:\n\n1 <= x, y <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(x = 100,y = 1) == \"Bob\"\n assert candidate(x = 1,y = 100) == \"Alice\"\n assert candidate(x = 1,y = 10) == \"Alice\"\n assert candidate(x = 4,y = 11) == \"Bob\"\n assert candidate(x = 2,y = 7) == \"Alice\"\n assert candidate(x = 5,y = 5) == \"Alice\"\n assert candidate(x = 10,y = 1) == \"Bob\"\n assert candidate(x = 100,y = 100) == \"Alice\"\n assert candidate(x = 1,y = 1) == \"Bob\"\n assert candidate(x = 3,y = 5) == \"Alice\"\n assert candidate(x = 50,y = 50) == \"Bob\"\n assert candidate(x = 30,y = 50) == \"Bob\"\n assert candidate(x = 65,y = 48) == \"Bob\"\n assert candidate(x = 10,y = 30) == \"Alice\"\n assert candidate(x = 20,y = 5) == \"Alice\"\n assert candidate(x = 90,y = 5) == \"Alice\"\n assert candidate(x = 15,y = 20) == \"Alice\"\n assert candidate(x = 30,y = 30) == \"Alice\"\n assert candidate(x = 1,y = 99) == \"Alice\"\n assert candidate(x = 75,y = 75) == \"Bob\"\n assert candidate(x = 22,y = 33) == \"Bob\"\n assert candidate(x = 27,y = 8) == \"Bob\"\n assert candidate(x = 20,y = 80) == \"Bob\"\n assert candidate(x = 75,y = 5) == \"Alice\"\n assert candidate(x = 5,y = 50) == \"Alice\"\n assert candidate(x = 30,y = 60) == \"Alice\"\n assert candidate(x = 33,y = 27) == \"Bob\"\n assert candidate(x = 10,y = 100) == \"Bob\"\n assert candidate(x = 25,y = 25) == \"Bob\"\n assert candidate(x = 80,y = 20) == \"Alice\"\n assert candidate(x = 25,y = 30) == \"Alice\"\n assert candidate(x = 8,y = 17) == \"Bob\"\n assert candidate(x = 30,y = 25) == \"Bob\"\n assert candidate(x = 99,y = 1) == \"Bob\"\n assert candidate(x = 5,y = 2) == \"Bob\"\n assert candidate(x = 33,y = 66) == \"Bob\"\n assert candidate(x = 5,y = 60) == \"Alice\"\n assert candidate(x = 5,y = 95) == \"Alice\"\n assert candidate(x = 15,y = 25) == \"Bob\"\n assert candidate(x = 15,y = 70) == \"Alice\"\n assert candidate(x = 55,y = 55) == \"Alice\"\n assert candidate(x = 10,y = 15) == \"Alice\"\n assert candidate(x = 25,y = 50) == \"Bob\"\n assert candidate(x = 20,y = 25) == \"Bob\"\n assert candidate(x = 33,y = 50) == \"Bob\"\n assert candidate(x = 20,y = 30) == \"Alice\"\n assert candidate(x = 45,y = 55) == \"Alice\"\n assert candidate(x = 10,y = 10) == \"Bob\"\n assert candidate(x = 5,y = 10) == \"Bob\"\n assert candidate(x = 5,y = 20) == \"Alice\"\n assert candidate(x = 20,y = 15) == \"Alice\"\n assert candidate(x = 30,y = 70) == \"Alice\"\n assert candidate(x = 7,y = 3) == \"Bob\"\n assert candidate(x = 25,y = 75) == \"Bob\"\n assert candidate(x = 99,y = 99) == \"Bob\"\n assert candidate(x = 7,y = 14) == \"Alice\"\n assert candidate(x = 99,y = 100) == \"Alice\"\n assert candidate(x = 60,y = 40) == \"Bob\"\n assert candidate(x = 25,y = 100) == \"Alice\"\n assert candidate(x = 5,y = 90) == \"Alice\"\n assert candidate(x = 100,y = 50) == \"Bob\"\n assert candidate(x = 25,y = 20) == \"Alice\"\n assert candidate(x = 50,y = 30) == \"Alice\"\n assert candidate(x = 5,y = 15) == \"Alice\"\n assert candidate(x = 3,y = 25) == \"Alice\"\n assert candidate(x = 10,y = 75) == \"Bob\"\n assert candidate(x = 50,y = 100) == \"Alice\"\n assert candidate(x = 42,y = 13) == \"Alice\"\n assert candidate(x = 50,y = 5) == \"Alice\"\n assert candidate(x = 75,y = 10) == \"Bob\"\n assert candidate(x = 15,y = 40) == \"Bob\"\n assert candidate(x = 3,y = 8) == \"Bob\"\n assert candidate(x = 80,y = 30) == \"Alice\"\n assert candidate(x = 8,y = 3) == \"Bob\"\n assert candidate(x = 20,y = 50) == \"Bob\"\n assert candidate(x = 30,y = 5) == \"Alice\"\n assert candidate(x = 10,y = 2) == \"Bob\"\n assert candidate(x = 15,y = 0) == \"Bob\"\n assert candidate(x = 6,y = 2) == \"Bob\"\n assert candidate(x = 10,y = 20) == \"Alice\"\n assert candidate(x = 7,y = 6) == \"Alice\"\n assert candidate(x = 7,y = 2) == \"Bob\"\n assert candidate(x = 20,y = 10) == \"Bob\"\n assert candidate(x = 8,y = 15) == \"Alice\"\n assert candidate(x = 5,y = 3) == \"Bob\"\n assert candidate(x = 3,y = 10) == \"Bob\"\n assert candidate(x = 9,y = 12) == \"Alice\"\n assert candidate(x = 50,y = 25) == \"Bob\"\n assert candidate(x = 1,y = 20) == \"Alice\"\n assert candidate(x = 7,y = 7) == \"Alice\"\n assert candidate(x = 9,y = 9) == \"Bob\"\n assert candidate(x = 75,y = 11) == \"Bob\"\n assert candidate(x = 6,y = 3) == \"Bob\"\n assert candidate(x = 8,y = 2) == \"Bob\"\n assert candidate(x = 50,y = 20) == \"Alice\"\n assert candidate(x = 8,y = 5) == \"Alice\"\n assert candidate(x = 6,y = 8) == \"Bob\"\n assert candidate(x = 1,y = 15) == \"Alice\"\n assert candidate(x = 0,y = 15) == \"Bob\"\n assert candidate(x = 6,y = 9) == \"Bob\"\n assert candidate(x = 6,y = 6) == \"Alice\"\n assert candidate(x = 3,y = 3) == \"Bob\"\n assert candidate(x = 8,y = 8) == \"Bob\"\n assert candidate(x = 20,y = 20) == \"Alice\"\n"}, "metadata": {"canonical_parameter_names": ["x", "y"], "leetcode_dataset_entry_point": "Solution().winningPlayer", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string winningPlayer(int x, int y) {", "container": "Solution", "callable": "winningPlayer", "parameters": [{"name": "x", "type": "int"}, {"name": "y", "type": "int"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3223, "task_id": "minimum-length-of-string-after-operations", "difficulty": "Medium", "problem_description": "You are given a string s.\nYou can perform the following process on s any number of times:\n\nChoose an index i in the string such that there is at least one character to the left of index i that is equal to s[i], and at least one character to the right that is also equal to s[i].\nDelete the closest occurrence of s[i] located to the left of i.\nDelete the closest occurrence of s[i] located to the right of i.\n\nReturn the minimum length of the final string s that you can achieve.\n \nExample 1:\n\nInput: s = \"abaacbcbb\"\nOutput: 5\nExplanation:\nWe do the following operations:\n\nChoose index 2, then remove the characters at indices 0 and 3. The resulting string is s = \"bacbcbb\".\nChoose index 3, then remove the characters at indices 0 and 5. The resulting string is s = \"acbcb\".\n\n\nExample 2:\n\nInput: s = \"aa\"\nOutput: 2\nExplanation:\nWe cannot perform any operations, so we return the length of the original string.\n\n \nConstraints:\n\n1 <= s.length <= 2 * 105\ns consists only of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"zzzzyzyzyyzzyzz\") == 3\n assert candidate(s = \"abcba\") == 5\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 26\n assert candidate(s = \"abaacbcbb\") == 5\n assert candidate(s = \"aabbaa\") == 4\n assert candidate(s = \"aabbccddeeeedddccbaa\") == 8\n assert candidate(s = \"abababab\") == 4\n assert candidate(s = \"a\") == 1\n assert candidate(s = \"abacabadabacaba\") == 7\n assert candidate(s = \"abcabcabc\") == 3\n assert candidate(s = \"abcabcabcabc\") == 6\n assert candidate(s = \"aa\") == 2\n assert candidate(s = \"abcddcba\") == 8\n assert candidate(s = \"zzzzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzzzz\") == 3\n assert candidate(s = \"abcde\") == 5\n assert candidate(s = \"aabb\") == 4\n assert candidate(s = \"aabbccddeeeedddccba\") == 7\n assert candidate(s = \"abcdeedcba\") == 10\n assert candidate(s = \"zzzzzzzzzz\") == 2\n assert candidate(s = \"abcdefgfedcba\") == 13\n assert candidate(s = \"abcdabcdabcd\") == 4\n assert candidate(s = \"zzzyzzyyzzyyzzzzzyyzyzyzyz\") == 4\n assert candidate(s = \"abacabad\") == 6\n assert candidate(s = \"aabbaaabbbaaa\") == 3\n assert candidate(s = \"abcd\") == 4\n assert candidate(s = \"aabbccddeeff\") == 12\n assert candidate(s = \"aabbcc\") == 6\n assert candidate(s = \"mississippi\") == 7\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 52\n assert candidate(s = \"aabbccddeeffgghhiijj\") == 20\n assert candidate(s = \"aabbccddeeaabbccddeeff\") == 12\n assert candidate(s = \"aabbccdd\") == 8\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 52\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 2\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmnbvcxzlkjhgfdsapoiuytrewqqwertyuiopasdfghjklzxcvbnm\") == 27\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzxyz\") == 49\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 26\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzyxwvutsrqponmlkjihgfedcba\") == 26\n assert candidate(s = \"abababababababababababababababababababababababababababababababababababababababab\") == 4\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 1\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba\") == 51\n assert candidate(s = \"xyzzyxzyzxzyzyzyzyz\") == 3\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 4\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\") == 26\n assert candidate(s = \"aaabbbbccccddddeeeeefffffggggghhhhhiiiiijjjjjkkkkklllllmmmmmnnnnnooooo\") == 18\n assert candidate(s = \"aaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaab\") == 3\n assert candidate(s = \"aabbaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 52\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().minimumLength", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumLength(string s) {", "container": "Solution", "callable": "minimumLength", "parameters": [{"name": "s", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3224, "task_id": "minimum-array-changes-to-make-differences-equal", "difficulty": "Medium", "problem_description": "You are given an integer array nums of size n where n is even, and an integer k.\nYou can perform some changes on the array, where in one change you can replace any element in the array with any integer in the range from 0 to k.\nYou need to perform some changes (possibly none) such that the final array satisfies the following condition:\n\nThere exists an integer X such that abs(a[i] - a[n - i - 1]) = X for all (0 <= i < n).\n\nReturn the minimum number of changes required to satisfy the above condition.\n \nExample 1:\n\nInput: nums = [1,0,1,2,4,3], k = 4\nOutput: 2\nExplanation:\nWe can perform the following changes:\n\nReplace nums[1] by 2. The resulting array is nums = [1,2,1,2,4,3].\nReplace nums[3] by 3. The resulting array is nums = [1,2,1,3,4,3].\n\nThe integer X will be 2.\n\nExample 2:\n\nInput: nums = [0,1,2,3,3,6,5,4], k = 6\nOutput: 2\nExplanation:\nWe can perform the following operations:\n\nReplace nums[3] by 0. The resulting array is nums = [0,1,2,0,3,6,5,4].\nReplace nums[4] by 4. The resulting array is nums = [0,1,2,0,4,6,5,4].\n\nThe integer X will be 4.\n\n \nConstraints:\n\n2 <= n == nums.length <= 105\nn is even.\n0 <= nums[i] <= k <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995],k = 100000) == 2\n assert candidate(nums = [10, 9, 8, 7, 6, 5],k = 10) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8],k = 8) == 3\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15],k = 15) == 3\n assert candidate(nums = [1, 0, 1, 2, 4, 3],k = 4) == 2\n assert candidate(nums = [5, 5, 5, 5],k = 5) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 4\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0],k = 0) == 0\n assert candidate(nums = [0, 2, 4, 6, 8, 10],k = 10) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 5],k = 5) == 0\n assert candidate(nums = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59],k = 100) == 4\n assert candidate(nums = [0, 1, 2, 3, 3, 6, 5, 4],k = 6) == 2\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1],k = 1) == 0\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2],k = 2) == 0\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 10) == 0\n assert candidate(nums = [0, 2, 4, 6, 8, 10, 12, 14],k = 14) == 3\n assert candidate(nums = [100000, 0, 100000, 0, 100000, 0, 100000, 0],k = 100000) == 0\n assert candidate(nums = [1, 3, 1, 3, 1, 3, 1, 3],k = 3) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 9) == 0\n assert candidate(nums = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992],k = 99999) == 3\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 1) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 15) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 0\n assert candidate(nums = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992],k = 100000) == 3\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 20) == 9\n assert candidate(nums = [50000, 0, 49999, 1, 49998, 2, 49997, 3, 49996, 4, 49995, 5, 49994, 6, 49993, 7],k = 100000) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 0\n assert candidate(nums = [30, 20, 10, 0, 10, 20, 30, 40, 50, 60, 70, 80],k = 100) == 2\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160],k = 160) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 30) == 14\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 9) == 4\n assert candidate(nums = [1, 3, 2, 4, 5, 7, 8, 6],k = 8) == 1\n assert candidate(nums = [99999, 0, 99999, 0, 99999, 0, 99999, 0, 99999, 0],k = 100000) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],k = 16) == 7\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200],k = 1200) == 5\n assert candidate(nums = [0, 1, 0, 3, 0, 5, 0, 7, 0, 9],k = 10) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],k = 12) == 5\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 0\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],k = 20) == 9\n assert candidate(nums = [99999, 1, 99999, 1, 99999, 1, 99999, 1],k = 100000) == 0\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144, 152, 160, 168, 176, 184, 192, 200, 208, 216, 224, 232, 240],k = 240) == 14\n assert candidate(nums = [0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55],k = 55) == 5\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6],k = 6) == 7\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],k = 11) == 5\n assert candidate(nums = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 30) == 7\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991],k = 100000) == 4\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 50, 40, 30, 20, 10, 0],k = 100) == 0\n assert candidate(nums = [100000, 100000, 100000, 100000, 0, 0, 0, 0, 100000, 100000, 100000, 100000],k = 100000) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],k = 8) == 6\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 5) == 0\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40],k = 40) == 3\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 2) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 500, 400, 300, 200, 100, 0],k = 1000) == 0\n assert candidate(nums = [50000, 0, 50000, 0, 50000, 0, 50000, 0, 50000, 0],k = 100000) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 20) == 9\n assert candidate(nums = [10000, 20000, 30000, 40000, 50000, 40000, 30000, 20000, 10000, 0],k = 50000) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 10) == 4\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2],k = 10) == 0\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 2) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 4\n assert candidate(nums = [1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14],k = 15) == 7\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 5) == 0\n assert candidate(nums = [30000, 20000, 10000, 0, 10000, 20000, 30000, 40000, 50000, 60000, 50000, 40000, 30000, 20000, 10000, 0],k = 60000) == 3\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 2) == 0\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112],k = 112) == 7\n assert candidate(nums = [99999, 0, 99999, 0, 99999, 0, 99999, 0, 99999, 0, 99999, 0, 99999, 0, 99999, 0],k = 100000) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],k = 59) == 14\n assert candidate(nums = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4],k = 4) == 4\n assert candidate(nums = [42, 24, 42, 24, 42, 24, 42, 24, 42, 24, 42, 24],k = 100) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 100) == 4\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 19) == 4\n assert candidate(nums = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 30) == 7\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 100) == 4\n assert candidate(nums = [5, 10, 5, 15, 5, 20, 5, 25, 5, 30],k = 30) == 4\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 4000, 3000, 2000, 1000, 0],k = 5000) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == 0\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 0) == 0\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5],k = 9) == 5\n assert candidate(nums = [0, 1, 2, 3, 0, 1, 2, 3, 0, 1],k = 3) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 500, 400, 300, 200, 100],k = 500) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 20) == 4\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23],k = 23) == 5\n assert candidate(nums = [1, 3, 2, 3, 4, 5, 3, 2, 5, 4],k = 5) == 3\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 10) == 8\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == 0\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 20) == 4\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80],k = 80) == 7\n assert candidate(nums = [2, 1, 3, 4, 1, 0, 2, 3, 4, 1, 0, 2, 3, 4, 1, 0],k = 4) == 3\n assert candidate(nums = [5, 1, 3, 7, 9, 2, 8, 4, 6, 0],k = 10) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],k = 16) == 7\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],k = 31) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],k = 12) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],k = 20) == 7\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 50, 40, 30, 20, 10, 0],k = 60) == 0\n assert candidate(nums = [1, 3, 5, 2, 4, 6, 7, 8],k = 8) == 3\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4],k = 9) == 5\n assert candidate(nums = [99999, 0, 99999, 0, 99999, 0, 99999, 0, 99999, 0, 99999, 0, 99999, 0, 99999, 0],k = 99999) == 0\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 1) == 0\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().minChanges", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minChanges(vector& nums, int k) {", "container": "Solution", "callable": "minChanges", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3225, "task_id": "maximum-score-from-grid-operations", "difficulty": "Hard", "problem_description": "You are given a 2D matrix grid of size n x n. Initially, all cells of the grid are colored white. In one operation, you can select any cell of indices (i, j), and color black all the cells of the jth column starting from the top row down to the ith row.\nThe grid score is the sum of all grid[i][j] such that cell (i, j) is white and it has a horizontally adjacent black cell.\nReturn the maximum score that can be achieved after some number of operations.\n \nExample 1:\n\nInput: grid = [[0,0,0,0,0],[0,0,3,0,0],[0,1,0,0,0],[5,0,0,3,0],[0,0,0,0,2]]\nOutput: 11\nExplanation:\n\nIn the first operation, we color all cells in column 1 down to row 3, and in the second operation, we color all cells in column 4 down to the last row. The score of the resulting grid is grid[3][0] + grid[1][2] + grid[3][3] which is equal to 11.\n\nExample 2:\n\nInput: grid = [[10,9,0,0,15],[7,1,0,8,0],[5,20,0,11,0],[0,0,0,1,2],[8,12,1,10,3]]\nOutput: 94\nExplanation:\n\nWe perform operations on 1, 2, and 3 down to rows 1, 4, and 0, respectively. The score of the resulting grid is grid[0][0] + grid[1][0] + grid[2][1] + grid[4][1] + grid[1][3] + grid[2][3] + grid[3][3] + grid[4][3] + grid[0][4] which is equal to 94.\n\n \nConstraints:\n\n1 <= n == grid.length <= 100\nn == grid[i].length\n0 <= grid[i][j] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[0, 0, 0, 0, 0], [0, 0, 3, 0, 0], [0, 1, 0, 0, 0], [5, 0, 0, 3, 0], [0, 0, 0, 0, 2]]) == 11\n assert candidate(grid = [[10, 9, 0, 0, 15], [7, 1, 0, 8, 0], [5, 20, 0, 11, 0], [0, 0, 0, 1, 2], [8, 12, 1, 10, 3]]) == 94\n assert candidate(grid = [[0, 0], [0, 0]]) == 0\n assert candidate(grid = [[5, 5, 5], [5, 5, 5], [5, 5, 5]]) == 30\n assert candidate(grid = [[1, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1]]) == 4\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == 30\n assert candidate(grid = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]) == 2\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == 9\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15, 17], [17, 15, 13, 11, 9, 7, 5, 3, 1], [2, 4, 6, 8, 10, 12, 14, 16, 18], [18, 16, 14, 12, 10, 8, 6, 4, 2], [3, 6, 9, 12, 15, 18, 21, 24, 27], [27, 24, 21, 18, 15, 12, 9, 6, 3], [4, 8, 12, 16, 20, 24, 28, 32, 36]]) == 588\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 2, 0, 3, 0, 4, 0], [0, 5, 0, 6, 0, 7, 0, 8, 0], [0, 9, 0, 10, 0, 11, 0, 12, 0], [0, 13, 0, 14, 0, 15, 0, 16, 0], [0, 17, 0, 18, 0, 19, 0, 20, 0], [0, 21, 0, 22, 0, 23, 0, 24, 0], [0, 25, 0, 26, 0, 27, 0, 28, 0], [0, 29, 0, 30, 0, 31, 0, 32, 0]]) == 528\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 2, 0, 3, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 4, 0]]) == 10\n assert candidate(grid = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]) == 72\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11], [11, 9, 7, 5, 3, 1], [2, 4, 6, 8, 10, 12], [12, 10, 8, 6, 4, 2]]) == 132\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [10, 0, 0, 0, 0, 0], [10, 10, 0, 0, 0, 0], [10, 10, 10, 0, 0, 0], [10, 10, 10, 10, 0, 0], [10, 10, 10, 10, 10, 0]]) == 100\n assert candidate(grid = [[9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [0, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 0, 9, 8, 7, 6, 5, 4, 3, 2], [2, 1, 0, 9, 8, 7, 6, 5, 4, 3], [3, 2, 1, 0, 9, 8, 7, 6, 5, 4], [4, 3, 2, 1, 0, 9, 8, 7, 6, 5], [5, 4, 3, 2, 1, 0, 9, 8, 7, 6], [6, 5, 4, 3, 2, 1, 0, 9, 8, 7], [7, 6, 5, 4, 3, 2, 1, 0, 9, 8], [8, 7, 6, 5, 4, 3, 2, 1, 0, 9]]) == 277\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 1, 2, 3, 4, 5, 6], [0, 7, 8, 9, 10, 11, 12], [0, 13, 14, 15, 16, 17, 18], [0, 19, 20, 21, 22, 23, 24], [0, 25, 26, 27, 28, 29, 30], [0, 31, 32, 33, 34, 35, 36]]) == 444\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 7, 8, 9, 10, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 36\n assert candidate(grid = [[5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5]]) == 140\n assert candidate(grid = [[10, 0, 0, 0, 0], [0, 20, 0, 0, 0], [0, 0, 30, 0, 0], [0, 0, 0, 40, 0], [0, 0, 0, 0, 50]]) == 110\n assert candidate(grid = [[0, 0, 0, 0], [0, 100, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) == 100\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 36\n assert candidate(grid = [[9, 0, 5, 0, 0], [0, 0, 0, 0, 0], [3, 0, 0, 0, 0], [0, 8, 0, 0, 0], [0, 0, 0, 0, 7]]) == 27\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 2, 0, 0], [0, 0, 0, 0, 0, 3, 0], [0, 0, 0, 0, 0, 0, 4]]) == 7\n assert candidate(grid = [[9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 60\n assert candidate(grid = [[10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [0, 10, 20, 30, 40], [5, 15, 25, 35, 45], [0, 10, 20, 30, 40]]) == 410\n assert candidate(grid = [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8], [5, 6, 7, 8, 9]]) == 80\n assert candidate(grid = [[0, 2, 0, 0, 4, 0], [1, 0, 0, 0, 0, 0], [0, 3, 0, 0, 0, 0], [0, 0, 5, 0, 0, 0], [0, 0, 0, 6, 0, 0], [0, 0, 0, 0, 0, 7]]) == 23\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [1, 2, 3, 4, 5, 6], [2, 3, 4, 5, 6, 7], [3, 4, 5, 6, 7, 8], [4, 5, 6, 7, 8, 9], [5, 6, 7, 8, 9, 10]]) == 110\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1]]) == 28\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [9, 8, 7, 6, 5, 4, 3]]) == 26\n assert candidate(grid = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]]) == 7\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 3, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0]]) == 10\n assert candidate(grid = [[9, 0, 0, 0, 0, 0], [0, 8, 0, 0, 0, 0], [0, 0, 7, 0, 0, 0], [0, 0, 0, 6, 0, 0], [0, 0, 0, 0, 5, 0], [0, 0, 0, 0, 0, 4]]) == 35\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]) == 200\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [1, 0, 2, 0, 3, 0], [0, 4, 0, 5, 0, 6], [7, 0, 8, 0, 9, 0], [0, 10, 0, 11, 0, 12], [13, 0, 14, 0, 15, 0]]) == 79\n assert candidate(grid = [[0, 1, 2, 3, 4, 5, 6], [7, 6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 7, 8], [8, 7, 6, 5, 4, 3, 2], [3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3], [4, 5, 6, 7, 8, 9, 10]]) == 146\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 15\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 1, 0, 2, 0, 3], [0, 4, 0, 5, 0, 6], [0, 7, 0, 8, 0, 9], [0, 10, 0, 11, 0, 12], [0, 13, 0, 14, 0, 15]]) == 120\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 1, 0, 2, 0, 0], [0, 0, 0, 0, 3, 0], [4, 0, 0, 0, 0, 5], [0, 0, 6, 0, 0, 0], [0, 0, 0, 7, 0, 0]]) == 24\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 1, 2, 3, 4, 5], [5, 4, 3, 2, 1, 0], [1, 2, 3, 4, 5, 0], [0, 0, 0, 0, 0, 6], [1, 1, 1, 1, 1, 1]]) == 38\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60], [61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80], [81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 1380\n assert candidate(grid = [[9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]) == 271\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 13, 14], [15, 16, 17, 18, 19, 20, 21], [22, 23, 24, 25, 26, 27, 28], [29, 30, 31, 32, 33, 34, 35], [36, 37, 38, 39, 40, 41, 42], [43, 44, 45, 46, 47, 48, 49]]) == 714\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 1]]) == 6\n assert candidate(grid = [[1000000000, 0, 0, 0, 0], [0, 1000000000, 0, 0, 0], [0, 0, 1000000000, 0, 0], [0, 0, 0, 1000000000, 0], [0, 0, 0, 0, 1000000000]]) == 4000000000\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0], [0, 0, 0, 4, 0, 0], [0, 0, 0, 0, 5, 0]]) == 15\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [0, 0, 0, 0, 0, 0], [7, 8, 9, 10, 11, 12], [12, 11, 10, 9, 8, 7]]) == 104\n assert candidate(grid = [[1000000000, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1000000000]]) == 2000000000\n assert candidate(grid = [[50, 0, 0, 0, 0], [0, 50, 0, 0, 0], [0, 0, 50, 0, 0], [0, 0, 0, 50, 0], [0, 0, 0, 0, 50]]) == 200\n assert candidate(grid = [[10, 10, 10, 10, 10], [10, 9, 8, 7, 6], [10, 8, 6, 4, 2], [10, 7, 5, 3, 1], [10, 6, 4, 2, 0]]) == 109\n assert candidate(grid = [[1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1]]) == 5\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 60\n assert candidate(grid = [[10, 0, 0, 0], [0, 20, 0, 0], [0, 0, 30, 0], [0, 0, 0, 40]]) == 70\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [1, 2, 3, 4, 5, 6], [0, 0, 0, 0, 0, 0], [7, 8, 9, 10, 11, 12], [0, 0, 0, 0, 0, 0], [13, 14, 15, 16, 17, 18]]) == 114\n assert candidate(grid = [[100, 0, 0, 0, 0], [0, 100, 0, 0, 0], [0, 0, 100, 0, 0], [0, 0, 0, 100, 0], [0, 0, 0, 0, 100]]) == 400\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 3, 4, 5, 6], [6, 5, 4, 3, 2], [3, 4, 5, 6, 7]]) == 58\n assert candidate(grid = [[10, 0, 20, 0, 30], [0, 40, 0, 50, 0], [60, 0, 70, 0, 80], [0, 90, 0, 100, 0], [110, 0, 120, 0, 130]]) == 630\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[5, 0, 0, 0, 0], [0, 0, 5, 0, 0], [0, 5, 0, 5, 0], [0, 0, 5, 0, 5], [5, 0, 0, 5, 0]]) == 30\n assert candidate(grid = [[20, 19, 18, 17, 16], [15, 14, 13, 12, 11], [10, 9, 8, 7, 6], [5, 4, 3, 2, 1], [0, 0, 0, 0, 0]]) == 130\n assert candidate(grid = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [0, 2, 4, 6, 8, 10, 12, 14, 16, 18], [18, 16, 14, 12, 10, 8, 6, 4, 2, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 3, 6, 9, 12, 15, 18, 21, 24, 27], [27, 24, 21, 18, 15, 12, 9, 6, 3, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 339\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15, 2, 4, 6, 8, 10, 12, 14], [14, 12, 10, 8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15], [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]]) == 97\n assert candidate(grid = [[1, 2, 0, 0, 0], [0, 3, 4, 0, 0], [0, 0, 5, 6, 0], [0, 0, 0, 7, 8], [0, 0, 0, 0, 9]]) == 31\n assert candidate(grid = [[1000000000, 0, 0, 0, 0], [0, 1000000000, 0, 0, 0], [0, 0, 1000000000, 0, 0], [0, 0, 0, 1000000000, 0], [0, 0, 0, 0, 1000000000]]) == 4000000000\n assert candidate(grid = [[9, 0, 0, 0, 0], [8, 0, 0, 0, 0], [7, 0, 0, 0, 0], [6, 0, 0, 0, 0], [5, 0, 0, 0, 0]]) == 35\n assert candidate(grid = [[10, 20, 30, 40, 50, 60], [60, 50, 40, 30, 20, 10], [10, 30, 50, 70, 90, 110], [110, 90, 70, 50, 30, 10], [20, 40, 60, 80, 100, 120], [120, 100, 80, 60, 40, 20]]) == 1320\n assert candidate(grid = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[0, 0, 0, 0, 0], [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]]) == 130\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [0, 0, 0, 0, 0, 0], [6, 5, 4, 3, 2, 1], [0, 0, 0, 0, 0, 0], [7, 8, 9, 10, 11, 12], [12, 11, 10, 9, 8, 7]]) == 104\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 13, 14], [15, 16, 17, 18, 19, 20, 21], [22, 23, 24, 25, 26, 27, 28], [29, 30, 31, 32, 33, 34, 35], [36, 37, 38, 39, 40, 41, 42], [43, 44, 45, 46, 47, 48, 49]]) == 714\n assert candidate(grid = [[1000000000, 0, 0, 0, 0, 0], [0, 1000000000, 0, 0, 0, 0], [0, 0, 1000000000, 0, 0, 0], [0, 0, 0, 1000000000, 0, 0], [0, 0, 0, 0, 1000000000, 0], [0, 0, 0, 0, 0, 1000000000]]) == 5000000000\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]]) == 50\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 2, 0, 3, 0, 4], [0, 5, 0, 6, 0, 7, 0, 8], [0, 9, 0, 10, 0, 11, 0, 12], [0, 13, 0, 14, 0, 15, 0, 16], [0, 17, 0, 18, 0, 19, 0, 20], [0, 21, 0, 22, 0, 23, 0, 24], [0, 25, 0, 26, 0, 27, 0, 28]]) == 406\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 1, 0, 2, 0, 0], [0, 0, 0, 0, 0, 3], [0, 0, 4, 0, 5, 0], [0, 6, 0, 0, 0, 0], [0, 0, 0, 7, 0, 0]]) == 22\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0], [0, 0, 3, 0, 0, 0, 0], [0, 0, 0, 4, 0, 0, 0], [0, 0, 0, 0, 5, 0, 0], [0, 0, 0, 0, 0, 6, 0], [0, 0, 0, 0, 0, 0, 7]]) == 22\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().maximumScore", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "long long maximumScore(vector>& grid) {", "container": "Solution", "callable": "maximumScore", "parameters": [{"name": "grid", "type": "vector>&"}], "return_type": "long long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3226, "task_id": "number-of-bit-changes-to-make-two-integers-equal", "difficulty": "Easy", "problem_description": "You are given two positive integers n and k.\nYou can choose any bit in the binary representation of n that is equal to 1 and change it to 0.\nReturn the number of changes needed to make n equal to k. If it is impossible, return -1.\n \nExample 1:\n\nInput: n = 13, k = 4\nOutput: 2\nExplanation:\nInitially, the binary representations of n and k are n = (1101)2 and k = (0100)2.\nWe can change the first and fourth bits of n. The resulting integer is n = (0100)2 = k.\n\nExample 2:\n\nInput: n = 21, k = 21\nOutput: 0\nExplanation:\nn and k are already equal, so no changes are needed.\n\nExample 3:\n\nInput: n = 14, k = 13\nOutput: -1\nExplanation:\nIt is not possible to make n equal to k.\n\n \nConstraints:\n\n1 <= n, k <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 1,k = 2) == -1\n assert candidate(n = 31,k = 1) == 4\n assert candidate(n = 15,k = 9) == 2\n assert candidate(n = 8,k = 8) == 0\n assert candidate(n = 1000000,k = 999999) == -1\n assert candidate(n = 7,k = 11) == -1\n assert candidate(n = 7,k = 3) == 1\n assert candidate(n = 5,k = 3) == -1\n assert candidate(n = 9,k = 8) == 1\n assert candidate(n = 6,k = 5) == -1\n assert candidate(n = 31,k = 15) == 1\n assert candidate(n = 1023,k = 512) == 9\n assert candidate(n = 21,k = 21) == 0\n assert candidate(n = 13,k = 4) == 2\n assert candidate(n = 14,k = 13) == -1\n assert candidate(n = 1023,k = 511) == 1\n assert candidate(n = 1000000,k = 500000) == -1\n assert candidate(n = 1047552,k = 523776) == -1\n assert candidate(n = 32767,k = 16384) == 14\n assert candidate(n = 999999,k = 1000000) == -1\n assert candidate(n = 65535,k = 32767) == 1\n assert candidate(n = 111111,k = 222222) == -1\n assert candidate(n = 524287,k = 524288) == -1\n assert candidate(n = 8388607,k = 4194304) == 22\n assert candidate(n = 8191,k = 4096) == 12\n assert candidate(n = 1000000,k = 1) == -1\n assert candidate(n = 255,k = 128) == 7\n assert candidate(n = 123456,k = 65536) == 5\n assert candidate(n = 983040,k = 524288) == 3\n assert candidate(n = 777777,k = 777777) == 0\n assert candidate(n = 1048576,k = 1048576) == 0\n assert candidate(n = 8191,k = 8191) == 0\n assert candidate(n = 1048575,k = 1) == 19\n assert candidate(n = 2,k = 1) == -1\n assert candidate(n = 123456,k = 123455) == -1\n assert candidate(n = 524287,k = 524286) == 1\n assert candidate(n = 8388607,k = 4194303) == 1\n assert candidate(n = 1048574,k = 1048573) == -1\n assert candidate(n = 123456,k = 123456) == 0\n assert candidate(n = 786432,k = 393216) == -1\n assert candidate(n = 777777,k = 888888) == -1\n assert candidate(n = 1048575,k = 524288) == 19\n assert candidate(n = 888888,k = 999999) == -1\n assert candidate(n = 65535,k = 65534) == 1\n assert candidate(n = 1,k = 1048575) == -1\n assert candidate(n = 2097151,k = 1048576) == 20\n assert candidate(n = 16777215,k = 16777214) == 1\n assert candidate(n = 131071,k = 65535) == 1\n assert candidate(n = 999999,k = 1) == 11\n assert candidate(n = 8388607,k = 8388607) == 0\n assert candidate(n = 1234567,k = 1234566) == 1\n assert candidate(n = 983041,k = 262144) == 4\n assert candidate(n = 555555,k = 555554) == 1\n assert candidate(n = 987654,k = 123456) == -1\n assert candidate(n = 1234567,k = 1234568) == -1\n assert candidate(n = 123456,k = 654321) == -1\n assert candidate(n = 1234567,k = 7654321) == -1\n assert candidate(n = 8191,k = 4095) == 1\n assert candidate(n = 1024,k = 1023) == -1\n assert candidate(n = 1001,k = 1000) == 1\n assert candidate(n = 524287,k = 262143) == 1\n assert candidate(n = 1000000,k = 1000001) == -1\n assert candidate(n = 888888,k = 888880) == 1\n assert candidate(n = 65535,k = 4095) == 4\n assert candidate(n = 1023,k = 0) == 10\n assert candidate(n = 333333,k = 666666) == -1\n assert candidate(n = 524287,k = 262144) == 18\n assert candidate(n = 524287,k = 1) == 18\n assert candidate(n = 131071,k = 131072) == -1\n assert candidate(n = 16777215,k = 8388608) == 23\n assert candidate(n = 65535,k = 1) == 15\n assert candidate(n = 524287,k = 524287) == 0\n assert candidate(n = 987654,k = 987653) == -1\n assert candidate(n = 897531,k = 897532) == -1\n assert candidate(n = 9876543,k = 9876542) == 1\n assert candidate(n = 777777,k = 666666) == -1\n assert candidate(n = 32768,k = 16384) == -1\n assert candidate(n = 987654,k = 987655) == -1\n assert candidate(n = 8192,k = 4096) == -1\n assert candidate(n = 65535,k = 32768) == 15\n assert candidate(n = 8388608,k = 4194304) == -1\n assert candidate(n = 1048575,k = 524287) == 1\n assert candidate(n = 983040,k = 491520) == -1\n assert candidate(n = 131071,k = 262142) == -1\n assert candidate(n = 6143,k = 1024) == 11\n assert candidate(n = 1048575,k = 0) == 20\n assert candidate(n = 131071,k = 1) == 16\n assert candidate(n = 4194303,k = 2097152) == 21\n assert candidate(n = 262144,k = 131072) == -1\n assert candidate(n = 4095,k = 1023) == 2\n assert candidate(n = 7,k = 0) == 3\n"}, "metadata": {"canonical_parameter_names": ["n", "k"], "leetcode_dataset_entry_point": "Solution().minChanges", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minChanges(int n, int k) {", "container": "Solution", "callable": "minChanges", "parameters": [{"name": "n", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3227, "task_id": "vowels-game-in-a-string", "difficulty": "Medium", "problem_description": "Alice and Bob are playing a game on a string.\nYou are given a string s, Alice and Bob will take turns playing the following game where Alice starts first:\n\nOn Alice's turn, she has to remove any non-empty substring from s that contains an odd number of vowels.\nOn Bob's turn, he has to remove any non-empty substring from s that contains an even number of vowels.\n\nThe first player who cannot make a move on their turn loses the game. We assume that both Alice and Bob play optimally.\nReturn true if Alice wins the game, and false otherwise.\nThe English vowels are: a, e, i, o, and u.\n \nExample 1:\n\nInput: s = \"leetcoder\"\nOutput: true\nExplanation:\nAlice can win the game as follows:\n\nAlice plays first, she can delete the underlined substring in s = \"leetcoder\" which contains 3 vowels. The resulting string is s = \"der\".\nBob plays second, he can delete the underlined substring in s = \"der\" which contains 0 vowels. The resulting string is s = \"er\".\nAlice plays third, she can delete the whole string s = \"er\" which contains 1 vowel.\nBob plays fourth, since the string is empty, there is no valid play for Bob. So Alice wins the game.\n\n\nExample 2:\n\nInput: s = \"bbcd\"\nOutput: false\nExplanation:\nThere is no valid play for Alice in her first turn, so Alice loses the game.\n\n \nConstraints:\n\n1 <= s.length <= 105\ns consists only of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"b\") == False\n assert candidate(s = \"bcbcbc\") == False\n assert candidate(s = \"leetcodeisfun\") == True\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(s = \"uoiea\") == True\n assert candidate(s = \"aeiou\") == True\n assert candidate(s = \"a\") == True\n assert candidate(s = \"bbaebebebe\") == True\n assert candidate(s = \"ae\") == True\n assert candidate(s = \"bcdfe\") == True\n assert candidate(s = \"aeiaaioaaaaeiiiiouuuooaauuaeiu\") == True\n assert candidate(s = \"\") == False\n assert candidate(s = \"xyz\") == False\n assert candidate(s = \"bcdf\") == False\n assert candidate(s = \"bbcd\") == False\n assert candidate(s = \"abcdefgh\") == True\n assert candidate(s = \"abcd\") == True\n assert candidate(s = \"bcbcbcbcbcbcbc\") == False\n assert candidate(s = \"abecidofug\") == True\n assert candidate(s = \"aeaaaeaa\") == True\n assert candidate(s = \"uuuuuu\") == True\n assert candidate(s = \"vozxqwx\") == True\n assert candidate(s = \"aabbccddeeff\") == True\n assert candidate(s = \"aabbcc\") == True\n assert candidate(s = \"bvdfndkvflspvlvhlmvfyckqjgnvjcjgvdpelbvclvsgjgygsvjvlp\") == True\n assert candidate(s = \"leetcoder\") == True\n assert candidate(s = \"aeiaeiaeiaeia\") == True\n assert candidate(s = \"aabbccdd\") == True\n assert candidate(s = \"bcdfg\") == False\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(s = \"bcd\") == False\n assert candidate(s = \"bababababababababa\") == True\n assert candidate(s = \"aabbccddeeefffrrtgyhyuujuyuyuyukjhjhgfdszxcvbnmaaeiou\") == True\n assert candidate(s = \"bbbbbaaaaaaaaa\") == True\n assert candidate(s = \"bbbbbaaaaabbbbbbbaaaaaaabbbbaaaaabbbbbaaaaaaabbbbbaaaaaaabbbbbaaaaaa\") == True\n assert candidate(s = \"anagram\") == True\n assert candidate(s = \"thisstringhasmanyvowelsaeiouanothersequenceofvowelsaeiou\") == True\n assert candidate(s = \"leetcodeiscrazyandfun\") == True\n assert candidate(s = \"aabbccddeeefffrrtgyhyuujuyuyuyukjhjhgfdszxcvbnm\") == True\n assert candidate(s = \"aliceandbobareplayingagame\") == True\n assert candidate(s = \"bbbbbbaaaaaabbbbbbaaaaaabbbbbbaaaaaabbbbbbaaaaaabbbbbbaaaaaabbbbbbaaaaaa\") == True\n assert candidate(s = \"leetcodedebuggingisfun\") == True\n assert candidate(s = \"vwxyz\") == False\n assert candidate(s = \"abacadaeafagahaiajakalamanaoapaqarasatauavawaxayaza\") == True\n assert candidate(s = \"consonant\") == True\n assert candidate(s = \"aoeuiuiaoeuiuiaoeuiuiaoeuiuiaoeuiuiaoeuiuiaoeuiuiaoeuiuiaoeuiuiaoeuiuiaoeuiuiaoeuiui\") == True\n assert candidate(s = \"aeiaaioaaaaeiiiiouuuooaauuaeiuzyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(s = \"vozdfvoazefovoziaovozifvoaeiofvaeivoaeiofvaeivoaeiofvaeivoaeiofvaeivoaeiof\") == True\n assert candidate(s = \"zzzaaaiiiooouuuummmllooonnngggfffddeeerrrtttyy\") == True\n assert candidate(s = \"aebcideofuigohukimouoeqirouusotovowuy\") == True\n assert candidate(s = \"aeiouaeiouaeiouaeiouaeiou\") == True\n assert candidate(s = \"thisisaverylongstringwithseveralvowels\") == True\n assert candidate(s = \"bcdfghjklmnpqrstvwxyzaeiouaeiouaeiouaeiouaeiou\") == True\n assert candidate(s = \"optimallyplayingthegamewithvowels\") == True\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\") == True\n assert candidate(s = \"evennumberofvowels\") == True\n assert candidate(s = \"bbaaaacceeeeeddooouuuiiiaaaa\") == True\n assert candidate(s = \"aaaaaaaaaaabbbbbbbbbbccccccccccdddddddddd\") == True\n assert candidate(s = \"abcdefghijkllllllllllmnopqrstuvwxyz\") == True\n assert candidate(s = \"aeiaaioaaaaeiiiiouuuooaauuaeiuuuuuuuuuuuuuuuuuuuuuuu\") == True\n assert candidate(s = \"aeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiou\") == True\n assert candidate(s = \"bcaovkyutrfghjnmlopaeiouaeiouaeiou\") == True\n assert candidate(s = \"programmingisfun\") == True\n assert candidate(s = \"leetcodelovebaboon\") == True\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == True\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzaeiouabcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(s = \"leetcodeleetcode\") == True\n assert candidate(s = \"aeioubcdfghjklmnpqrstvwxyz\") == True\n assert candidate(s = \"aeiouaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == True\n assert candidate(s = \"leetcodeword\") == True\n assert candidate(s = \"aeiouaeiouaeiouaeiou\") == True\n assert candidate(s = \"aeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiou\") == True\n assert candidate(s = \"abcdefghijklnmopqrstuvwxyz\") == True\n assert candidate(s = \"abcdefghijkloiuytrpqweoiuytrewqoiuytrewq\") == True\n assert candidate(s = \"leetcoderbbaaaabbaaabbbaaaabbaaabbbaaaabbaaabbbaaaab\") == True\n assert candidate(s = \"aeiouzyxwvutsrqponmlkjihgfedcb\") == True\n assert candidate(s = \"aeiouaeiouaeiouaeiouaeiouaeiouaeiou\") == True\n assert candidate(s = \"aeioubcdfghjklmnpqrstvwxyzaeioubcdfghjklmnpqrstvwxyzaeioubcdfghjklmnpqrstvwxyz\") == True\n assert candidate(s = \"thisisalongstringwithmanyvowelsoooeiuaeiou\") == True\n assert candidate(s = \"uuuuuaaaaaeeeeeooooouuuuuaaaaa\") == True\n assert candidate(s = \"vowel\") == True\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(s = \"aeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiou\") == True\n assert candidate(s = \"aevbocudifoguhoeaio\") == True\n assert candidate(s = \"babababababababababababababababababababababababababababababababababa\") == True\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzabcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(s = \"bbaaaacccceeeeedddd\") == True\n assert candidate(s = \"aevbocudifoguhoeaioaaaaeeeeeooooouuuuu\") == True\n assert candidate(s = \"eiouaeiouaeiou\") == True\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == False\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == False\n assert candidate(s = \"bcdfghjklmnpqrstvwxyz\") == False\n assert candidate(s = \"vowelsareimportantinthisgame\") == True\n assert candidate(s = \"aabbccddeeffgg\") == True\n assert candidate(s = \"bbbbbaaaaabbbbbbaaaaabbbbbaaaa\") == True\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzaeiouaeiouaeiouaeiouaeiouaeiou\") == True\n assert candidate(s = \"leetcodeisreallyfun\") == True\n assert candidate(s = \"abcdefghij\") == True\n assert candidate(s = \"aeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiou\") == True\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == True\n assert candidate(s = \"zxcvbnmlkjhgfdsapoiuytrewq\") == True\n assert candidate(s = \"sequencepalindrome\") == True\n assert candidate(s = \"zaeiouzaeiouzaeiouzaeiou\") == True\n assert candidate(s = \"zxcvbnmasdfghjklqwertyuiopmnbvcxzlkjhgfdsapoiuytrewqmnbvcxzlkjhgfdsapoiuytrew\") == True\n assert candidate(s = \"lkjihgfedcbponmlkjihgfedcba\") == True\n assert candidate(s = \"abcdefgheijouaeiouxyz\") == True\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzaeiou\") == True\n assert candidate(s = \"aaabbbcccdddaabbccddeee\") == True\n assert candidate(s = \"vowelsareaeiou\") == True\n assert candidate(s = \"complexsubstringwithvariousvowels\") == True\n assert candidate(s = \"aeiaaioaaaaeiiiiouuuooaauuaeiuzyxwvutsrqponmlkjihgfedcbaaabbccddeeefffrrtgyhyuujuyuyuyukjhjhgfdszxcvbnmaaeiou\") == True\n assert candidate(s = \"consonantsnvbnmnbmhngftrds\") == True\n assert candidate(s = \"bbaaaabbaaabbbaaaabbaaabbbaaaabbaaabbbaaaab\") == True\n assert candidate(s = \"bcaovkyutrfghjnmlop\") == True\n assert candidate(s = \"aabbccddeeefffagggihiiiijjjjkkkkllllmmmmnnnnooooo\") == True\n assert candidate(s = \"aaaaabbbbbcccccdddddaaaaabbbbb\") == True\n assert candidate(s = \"oddnumberofvowels\") == True\n assert candidate(s = \"bbbaaaacceeeeeddooouuuiiiaaaabbbccc\") == True\n assert candidate(s = \"aebcdeoiufghijklmnoptqrstuwyxz\") == True\n assert candidate(s = \"aeiouvwxyzaeiouvwxyzaeiouvwxyz\") == True\n assert candidate(s = \"aliceandbob\") == True\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().doesAliceWin", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool doesAliceWin(string s) {", "container": "Solution", "callable": "doesAliceWin", "parameters": [{"name": "s", "type": "string"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3228, "task_id": "maximum-number-of-operations-to-move-ones-to-the-end", "difficulty": "Medium", "problem_description": "You are given a binary string s.\nYou can perform the following operation on the string any number of times:\n\nChoose any index i from the string where i + 1 < s.length such that s[i] == '1' and s[i + 1] == '0'.\nMove the character s[i] to the right until it reaches the end of the string or another '1'. For example, for s = \"010010\", if we choose i = 1, the resulting string will be s = \"000110\".\n\nReturn the maximum number of operations that you can perform.\n \nExample 1:\n\nInput: s = \"1001101\"\nOutput: 4\nExplanation:\nWe can perform the following operations:\n\nChoose index i = 0. The resulting string is s = \"0011101\".\nChoose index i = 4. The resulting string is s = \"0011011\".\nChoose index i = 3. The resulting string is s = \"0010111\".\nChoose index i = 2. The resulting string is s = \"0001111\".\n\n\nExample 2:\n\nInput: s = \"00111\"\nOutput: 0\n\n \nConstraints:\n\n1 <= s.length <= 105\ns[i] is either '0' or '1'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"00111\") == 0\n assert candidate(s = \"101100110\") == 9\n assert candidate(s = \"000111000\") == 3\n assert candidate(s = \"11110000\") == 4\n assert candidate(s = \"010101010\") == 10\n assert candidate(s = \"1001001001001\") == 10\n assert candidate(s = \"100001110\") == 5\n assert candidate(s = \"1111111111\") == 0\n assert candidate(s = \"1010101\") == 6\n assert candidate(s = \"1000000000\") == 1\n assert candidate(s = \"00001111\") == 0\n assert candidate(s = \"10001\") == 1\n assert candidate(s = \"00000000\") == 0\n assert candidate(s = \"11111\") == 0\n assert candidate(s = \"1001001001\") == 6\n assert candidate(s = \"11111111\") == 0\n assert candidate(s = \"110001101\") == 6\n assert candidate(s = \"1001101\") == 4\n assert candidate(s = \"1010101010\") == 15\n assert candidate(s = \"1100011\") == 2\n assert candidate(s = \"1100110011\") == 6\n assert candidate(s = \"101000101\") == 6\n assert candidate(s = \"1101001\") == 5\n assert candidate(s = \"101010\") == 6\n assert candidate(s = \"0101010101\") == 10\n assert candidate(s = \"110000011\") == 2\n assert candidate(s = \"00000\") == 0\n assert candidate(s = \"100010001\") == 3\n assert candidate(s = \"11010000011100000111\") == 11\n assert candidate(s = \"111111111111111111111111111111111111111111111111\") == 0\n assert candidate(s = \"11001011001011001011\") == 33\n assert candidate(s = \"00000000000000000000000000000000\") == 0\n assert candidate(s = \"110010010101001\") == 20\n assert candidate(s = \"100001000010000100001\") == 10\n assert candidate(s = \"1010101010101010101\") == 45\n assert candidate(s = \"0110011001100110011001100110011001100110011001100110011001\") == 210\n assert candidate(s = \"10010010010010010010010010010010010010010010010010\") == 153\n assert candidate(s = \"00001111000011110000\") == 12\n assert candidate(s = \"111000111000111\") == 9\n assert candidate(s = \"000111000111000111\") == 9\n assert candidate(s = \"10101010101010101010101010101010101010101010101\") == 276\n assert candidate(s = \"0000000000000000000000000000000000000000000000000001\") == 0\n assert candidate(s = \"1111111111111111111111111111111111111\") == 0\n assert candidate(s = \"1010101010101010101010101010101010101010101010101\") == 300\n assert candidate(s = \"110000000000000000000000000000000000000000000000000000000000000000\") == 2\n assert candidate(s = \"110011001100\") == 12\n assert candidate(s = \"101010101010101010101010101010101010101010101\") == 253\n assert candidate(s = \"111100001111000011110000\") == 24\n assert candidate(s = \"00011110001111000111100011110001111000111100011110\") == 112\n assert candidate(s = \"0011001100110011\") == 12\n assert candidate(s = \"000000111111\") == 0\n assert candidate(s = \"01001001001001001001001001001001001001001001001001\") == 136\n assert candidate(s = \"10101010101010101010101\") == 66\n assert candidate(s = \"000011110000111100001111000011110000\") == 40\n assert candidate(s = \"0000111100001111000011110000\") == 24\n assert candidate(s = \"0000000000000000000000000000000000000000\") == 0\n assert candidate(s = \"1001001001001001001001001001001\") == 55\n assert candidate(s = \"100000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000\") == 3\n assert candidate(s = \"01010101010101010101010101010101010101010101010101\") == 300\n assert candidate(s = \"100000000000000000000000000000000000000000000000000000000000000001\") == 1\n assert candidate(s = \"10000000000000000000000000000000000000000000000000001\") == 1\n assert candidate(s = \"1000000001000000010000000100000001\") == 10\n assert candidate(s = \"111000111000111000111000111000111000111000\") == 84\n assert candidate(s = \"00000000001111111111\") == 0\n assert candidate(s = \"10000000100000001000000010000000\") == 10\n assert candidate(s = \"00000111110000011111\") == 5\n assert candidate(s = \"111000111000111000111\") == 18\n assert candidate(s = \"1000000000000000000000000000000000000000000000000000\") == 1\n assert candidate(s = \"11111111110000000000\") == 10\n assert candidate(s = \"01010101010101010101010101010101\") == 120\n assert candidate(s = \"0101010101010101010101010101010101010101\") == 190\n assert candidate(s = \"1010101010101010101010101010\") == 105\n assert candidate(s = \"100000000000000000000000000000000000000000000000\") == 1\n assert candidate(s = \"00000000000000000000000000000000000000000000000000000000000\") == 0\n assert candidate(s = \"1111111100000000\") == 8\n assert candidate(s = \"111000111000111000111000111000111000111000111000111000111000111\") == 165\n assert candidate(s = \"11110000111100001111000011110000\") == 40\n assert candidate(s = \"1111111111111111111111111111111111111111111111111111000000000000000000000000000000000000000000000000\") == 52\n assert candidate(s = \"1101101101101101101101101101101101101101\") == 182\n assert candidate(s = \"0101010101010101\") == 28\n assert candidate(s = \"11111111111111111111111111111111\") == 0\n assert candidate(s = \"1010101010101010101010101010101010101010101010101010101010\") == 435\n assert candidate(s = \"000000000000000000000000000000000000000000000000000000000000000001\") == 0\n assert candidate(s = \"11111000001111100000111110000011111000001111100000\") == 75\n assert candidate(s = \"1001001001001001001\") == 21\n assert candidate(s = \"1001001001001001001001001001001001001001\") == 91\n assert candidate(s = \"11111110000000\") == 7\n assert candidate(s = \"100000010000001\") == 3\n assert candidate(s = \"00001111000011110000111100001111\") == 24\n assert candidate(s = \"1111111111111111111111111111111111111111\") == 0\n assert candidate(s = \"111000011100001110000111\") == 18\n assert candidate(s = \"1111000011110000\") == 12\n assert candidate(s = \"10101010101010101010101010101010\") == 136\n assert candidate(s = \"0000000011111111\") == 0\n assert candidate(s = \"1001100110011001100110011001100110011001100110011001100110\") == 225\n assert candidate(s = \"1100010010011010\") == 22\n assert candidate(s = \"0100101001010010100101001010010100101001\") == 120\n assert candidate(s = \"1100000011110000001111000000\") == 18\n assert candidate(s = \"1010101010101010101010101010101010101010\") == 210\n assert candidate(s = \"0000111100001111000011110000111100001111\") == 40\n assert candidate(s = \"01010101010101010101\") == 45\n assert candidate(s = \"010101010101010101010101010101010101010101010101010101010101010101\") == 528\n assert candidate(s = \"0000000000000000000000000000000000000\") == 0\n assert candidate(s = \"10101010101010101010\") == 55\n assert candidate(s = \"00011110000111100001111\") == 12\n assert candidate(s = \"1111111111111111111111111111111111111111111111111111111111\") == 0\n assert candidate(s = \"0000111100001111\") == 4\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().maxOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxOperations(string s) {", "container": "Solution", "callable": "maxOperations", "parameters": [{"name": "s", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3229, "task_id": "minimum-operations-to-make-array-equal-to-target", "difficulty": "Hard", "problem_description": "You are given two positive integer arrays nums and target, of the same length.\nIn a single operation, you can select any subarray of nums and increment each element within that subarray by 1 or decrement each element within that subarray by 1.\nReturn the minimum number of operations required to make nums equal to the array target.\n \nExample 1:\n\nInput: nums = [3,5,1,2], target = [4,6,2,4]\nOutput: 2\nExplanation:\nWe will perform the following operations to make nums equal to target:\n- Increment nums[0..3] by 1, nums = [4,6,2,3].\n- Increment nums[3..3] by 1, nums = [4,6,2,4].\n\nExample 2:\n\nInput: nums = [1,3,2], target = [2,1,4]\nOutput: 5\nExplanation:\nWe will perform the following operations to make nums equal to target:\n- Increment nums[0..0] by 1, nums = [2,3,2].\n- Decrement nums[1..1] by 1, nums = [2,2,2].\n- Decrement nums[1..1] by 1, nums = [2,1,2].\n- Increment nums[2..2] by 1, nums = [2,1,3].\n- Increment nums[2..2] by 1, nums = [2,1,4].\n\n \nConstraints:\n\n1 <= nums.length == target.length <= 105\n1 <= nums[i], target[i] <= 108\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 100000000, 1],target = [100000000, 1, 100000000]) == 299999997\n assert candidate(nums = [1, 3, 2],target = [2, 1, 4]) == 5\n assert candidate(nums = [3, 5, 1, 2],target = [4, 6, 2, 4]) == 2\n assert candidate(nums = [100000000, 100000000, 100000000],target = [1, 1, 1]) == 99999999\n assert candidate(nums = [1, 1, 1, 1],target = [2, 2, 2, 2]) == 1\n assert candidate(nums = [10, 20, 30],target = [15, 25, 25]) == 10\n assert candidate(nums = [10, 20, 30],target = [15, 25, 35]) == 5\n assert candidate(nums = [1, 2, 3],target = [4, 5, 6]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 18\n assert candidate(nums = [5, 5, 5, 5, 5],target = [5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5],target = [3, 4, 5, 6, 7]) == 4\n assert candidate(nums = [1, 2, 3],target = [4, 5, 6]) == 3\n assert candidate(nums = [5, 5, 5, 5, 5],target = [1, 1, 1, 1, 1]) == 4\n assert candidate(nums = [1, 1, 1, 1],target = [1, 1, 1, 1]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 1\n assert candidate(nums = [100000000],target = [100000000]) == 0\n assert candidate(nums = [100, 200, 300, 400],target = [400, 300, 200, 100]) == 600\n assert candidate(nums = [100000000, 100000000],target = [1, 1]) == 99999999\n assert candidate(nums = [1, 2, 3, 4, 5],target = [5, 4, 3, 2, 1]) == 8\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],target = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 8\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 180\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 36\n assert candidate(nums = [1, 2, 3, 4, 5],target = [2, 3, 4, 5, 6]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 38\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6]) == 8\n assert candidate(nums = [1, 1, 1, 1, 1],target = [2, 2, 2, 2, 2]) == 1\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],target = [31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == 44\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 99\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 9\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = [10, 30, 50, 70, 90, 110, 130, 150, 170, 190]) == 90\n assert candidate(nums = [1, 1, 2, 2, 3, 3],target = [3, 3, 2, 2, 1, 1]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5],target = [5, 1, 5, 1, 5]) == 10\n assert candidate(nums = [1, 3, 5, 7, 9],target = [2, 4, 6, 8, 10]) == 1\n assert candidate(nums = [1, 10, 100, 1000, 10000],target = [10000, 1000, 100, 10, 1]) == 19998\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],target = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2]) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 10\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 19\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 28\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1],target = [9, 8, 7, 6, 5, 6, 7, 8, 9]) == 16\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 5\n assert candidate(nums = [10, 10, 10, 10, 10],target = [1, 2, 3, 4, 5]) == 9\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1],target = [1, 1, 1, 1, 100000000]) == 99999999\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [1, 1, 1, 1, 1, 10, 10, 10, 10, 10]) == 8\n assert candidate(nums = [5, 4, 3, 2, 1],target = [1, 2, 3, 4, 5]) == 8\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == 1800\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4],target = [4, 4, 3, 3, 2, 2, 1, 1]) == 6\n assert candidate(nums = [1, 3, 5, 7, 9],target = [9, 7, 5, 3, 1]) == 16\n assert candidate(nums = [1, 10, 100, 1000, 10000],target = [10000, 1000, 100, 10, 1]) == 19998\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 18\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],target = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 30]) == 29\n assert candidate(nums = [10, 20, 30, 40, 50],target = [1, 2, 3, 4, 5]) == 45\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 1\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],target = [4, 4, 4, 4, 3, 3, 3, 2, 2, 1]) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 38\n assert candidate(nums = [1, 100, 10000, 1000000],target = [1000000, 10000, 100, 1]) == 1999998\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [10, 20, 30, 40, 50],target = [50, 40, 30, 20, 10]) == 80\n assert candidate(nums = [100000000, 99999999, 99999998, 99999997, 99999996],target = [1, 2, 3, 4, 5]) == 99999999\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4],target = [4, 4, 3, 3, 2, 2, 1, 1]) == 6\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 18\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],target = [5, 6, 7, 8, 9, 10, 9, 8, 7, 6]) == 9\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5],target = [10, 10, 10, 10, 10]) == 9\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 4\n assert candidate(nums = [1, 1, 1, 1, 1],target = [10, 10, 10, 10, 10]) == 9\n assert candidate(nums = [9, 9, 9, 9, 9],target = [1, 2, 3, 4, 5]) == 8\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = [100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000]) == 99999999\n assert candidate(nums = [2, 4, 6, 8, 10],target = [1, 3, 5, 7, 9]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == 19\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 90\n assert candidate(nums = [10, 20, 30, 40, 50],target = [50, 40, 30, 20, 10]) == 80\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9],target = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 18\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],target = [50, 45, 40, 35, 30, 25, 20, 15, 10, 5]) == 90\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 10\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3],target = [3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1]) == 4\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 900\n assert candidate(nums = [3, 5, 2, 8, 4],target = [6, 8, 7, 4, 3]) == 9\n assert candidate(nums = [100, 200, 300, 400, 500],target = [500, 400, 300, 200, 100]) == 800\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 18\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 9\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],target = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 0\n assert candidate(nums = [5, 10, 15, 20, 25],target = [25, 20, 15, 10, 5]) == 40\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [10, 1, 10, 1, 10, 1, 10, 1, 10, 1]) == 50\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],target = [4, 4, 4, 4, 3, 3, 3, 2, 2, 1]) == 6\n assert candidate(nums = [10, 20, 30, 40, 50],target = [15, 25, 35, 45, 55]) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 9\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 9\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 4\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],target = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 16\n assert candidate(nums = [10, 10, 10, 10, 10],target = [1, 1, 1, 1, 1]) == 9\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 9\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 18\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 4\n assert candidate(nums = [1, 3, 5, 7, 9],target = [9, 7, 5, 3, 1]) == 16\n assert candidate(nums = [100000000, 90000000, 80000000, 70000000, 60000000],target = [10000000, 20000000, 30000000, 40000000, 50000000]) == 90000000\n assert candidate(nums = [5, 5, 5, 5, 5],target = [10, 9, 8, 7, 6]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 9\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 5\n assert candidate(nums = [5, 5, 5, 5, 5],target = [10, 5, 10, 5, 10]) == 15\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13],target = [13, 11, 9, 7, 5, 3, 1]) == 24\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 36\n assert candidate(nums = [10, 20, 30, 40, 50],target = [5, 15, 25, 35, 45]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [10, 9, 8, 7, 6, 5, 4, 3, 2, 100000000]) == 100000006\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],target = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 8\n"}, "metadata": {"canonical_parameter_names": ["nums", "target"], "leetcode_dataset_entry_point": "Solution().minimumOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "long long minimumOperations(vector& nums, vector& target) {", "container": "Solution", "callable": "minimumOperations", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "target", "type": "vector&"}], "return_type": "long long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3232, "task_id": "find-if-digit-game-can-be-won", "difficulty": "Easy", "problem_description": "You are given an array of positive integers nums.\nAlice and Bob are playing a game. In the game, Alice can choose either all single-digit numbers or all double-digit numbers from nums, and the rest of the numbers are given to Bob. Alice wins if the sum of her numbers is strictly greater than the sum of Bob's numbers.\nReturn true if Alice can win this game, otherwise, return false.\n \nExample 1:\n\nInput: nums = [1,2,3,4,10]\nOutput: false\nExplanation:\nAlice cannot win by choosing either single-digit or double-digit numbers.\n\nExample 2:\n\nInput: nums = [1,2,3,4,5,14]\nOutput: true\nExplanation:\nAlice can win by choosing single-digit numbers which have a sum equal to 15.\n\nExample 3:\n\nInput: nums = [5,5,5,25]\nOutput: true\nExplanation:\nAlice can win by choosing double-digit numbers which have a sum equal to 25.\n\n \nConstraints:\n\n1 <= nums.length <= 100\n1 <= nums[i] <= 99\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 11, 12, 13, 14, 15]) == True\n assert candidate(nums = [9, 9, 9, 10, 10]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 14]) == True\n assert candidate(nums = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == True\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(nums = [1, 11, 111, 1111, 11111]) == True\n assert candidate(nums = [50, 25, 10, 5, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == True\n assert candidate(nums = [1, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == True\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == True\n assert candidate(nums = [5, 5, 5, 25]) == True\n assert candidate(nums = [1, 11, 22, 33, 44, 55, 66, 77, 88, 99]) == True\n assert candidate(nums = [45, 46, 47, 48, 49, 50, 51, 52, 53, 54]) == True\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == True\n assert candidate(nums = [1, 2, 3, 4, 10]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(nums = [10, 20, 30, 40, 5]) == True\n assert candidate(nums = [50, 50, 50, 50, 50, 50]) == True\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10]) == True\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == True\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == True\n assert candidate(nums = [10, 10, 10, 1, 1]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == True\n assert candidate(nums = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25]) == True\n assert candidate(nums = [9, 9, 9, 9, 9, 10, 10, 10]) == True\n assert candidate(nums = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 99]) == True\n assert candidate(nums = [10, 20, 30, 40]) == True\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == True\n assert candidate(nums = [10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48]) == True\n assert candidate(nums = [9, 99, 8, 88, 7, 77, 6, 66, 5, 55, 4, 44, 3, 33, 2, 22, 1, 11]) == True\n assert candidate(nums = [9, 19, 29, 39, 49, 59, 69, 79, 89, 99, 1, 11, 21, 31, 41]) == True\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(nums = [55, 44, 33, 22, 11, 99, 88, 77, 66, 55, 44, 33]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 22, 33, 44, 55, 66, 77, 88, 99, 10, 20, 30, 40, 50, 60, 70, 80, 90]) == True\n assert candidate(nums = [9, 12, 15, 20, 25, 30, 35, 40, 45, 50]) == True\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == True\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(nums = [10, 20, 30, 40, 5, 15, 25, 35, 45, 55]) == True\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 99]) == True\n assert candidate(nums = [9, 19, 29, 39, 49, 59, 69, 79, 89, 99, 1, 11, 21, 31, 41, 51, 61, 71, 81, 91, 2, 22, 32, 42, 52, 62, 72, 82, 92, 3, 33, 43, 53, 63, 73, 83, 93, 4, 44, 54, 64, 74, 84, 94, 5, 55, 65, 75, 85, 95, 6, 66, 76, 86, 96, 7, 77, 87, 97, 8, 88, 98, 9, 99, 10, 20, 30, 40, 50, 60, 70, 80, 90]) == True\n assert candidate(nums = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 84, 88, 92, 96, 1, 2, 3, 5, 6, 7, 9, 10, 11, 13, 14, 15, 17, 18, 19, 21, 22, 23, 25, 26, 27, 29, 30, 31, 33, 34, 35, 37, 38, 39, 41, 42, 43, 45, 46, 47, 49, 50, 51, 53, 54, 55, 57, 58, 59, 61, 62, 63, 65, 66, 67, 69, 70, 71, 73, 74, 75, 77, 78, 79, 81, 82, 83, 85, 86, 87, 89, 90, 91, 93, 94, 95, 97, 98, 99]) == True\n assert candidate(nums = [10, 21, 32, 43, 54, 65, 76, 87, 98, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 21, 32, 43, 54, 65, 76, 87, 98, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 21, 32, 43, 54, 65, 76, 87, 98, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 21, 32, 43, 54, 65, 76, 87, 98, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(nums = [8, 18, 28, 38, 48, 58, 68, 78, 88, 98, 9, 19, 29, 39, 49]) == True\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59]) == True\n assert candidate(nums = [88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(nums = [10, 20, 30, 40, 50, 1, 2, 3, 4, 5]) == True\n assert candidate(nums = [98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70]) == True\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90]) == True\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 1, 2, 3, 4, 5, 6, 7, 8, 9, 55]) == True\n assert candidate(nums = [1, 20, 3, 40, 5, 60, 7, 80, 9, 10]) == True\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 99]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 11, 22, 33, 44, 55, 66, 77, 88, 99, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == True\n assert candidate(nums = [10, 20, 30, 40, 50, 5, 15, 25, 35, 45]) == True\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 1, 11, 22, 33, 44]) == True\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == True\n assert candidate(nums = [1, 10, 100, 2, 20, 3, 30, 4, 40, 5, 50, 6, 60, 7, 70, 8, 80, 9, 90]) == True\n assert candidate(nums = [99, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == True\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 1, 2, 3, 4, 5]) == True\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == True\n assert candidate(nums = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == True\n assert candidate(nums = [9, 19, 29, 39, 49, 59, 69, 79, 89, 99, 1, 2, 3, 4, 5]) == True\n assert candidate(nums = [45, 55, 65, 75, 85, 95, 5, 15, 25, 35, 45]) == True\n assert candidate(nums = [45, 55, 65, 75, 85, 95, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50]) == True\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95, 5, 10, 15, 20, 25, 30]) == True\n assert candidate(nums = [9, 19, 29, 39, 49, 59, 69, 79, 89, 99, 10, 20, 30, 40, 50, 60, 70, 80, 90]) == True\n assert candidate(nums = [12, 23, 34, 45, 56, 67, 78, 89, 90, 11]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == True\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15]) == True\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98]) == True\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 10, 20, 30, 40, 50]) == True\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99]) == True\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99]) == True\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41]) == True\n assert candidate(nums = [1, 11, 2, 22, 3, 33, 4, 44, 5, 55, 6, 66, 7, 77, 8, 88, 9, 99]) == True\n assert candidate(nums = [50, 40, 30, 20, 10, 1, 11, 21, 31, 41, 51, 61, 71, 81, 91]) == True\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == True\n assert candidate(nums = [99, 88, 77, 66, 55, 44, 33, 22, 11, 1, 2, 3, 4, 5]) == True\n assert candidate(nums = [45, 54, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 1, 2, 3, 4, 6, 7, 8, 9]) == True\n assert candidate(nums = [41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60]) == True\n assert candidate(nums = [5, 15, 25, 35, 45, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == True\n assert candidate(nums = [9, 19, 29, 39, 49, 59, 69, 79, 89, 99, 1, 11, 21, 31, 41, 51, 61, 71, 81, 91, 2, 12, 22, 32, 42, 52, 62, 72, 82, 92]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == True\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 10, 20, 30, 40, 50, 60, 70, 80, 90, 10, 20, 30, 40, 50, 60, 70, 80, 90, 10, 20, 30, 40, 50, 60, 70, 80, 90]) == True\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 99, 88, 77, 66, 55, 44, 33, 22, 11]) == True\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == True\n assert candidate(nums = [10, 20, 30, 40, 50, 1, 2, 3, 4, 5, 6, 7, 8, 9, 60, 70, 80, 90, 5]) == True\n assert candidate(nums = [8, 17, 26, 35, 44, 53, 62, 71, 80, 89, 10, 19, 28, 37, 46]) == True\n assert candidate(nums = [1, 12, 23, 34, 45, 56, 67, 78, 89, 90]) == True\n assert candidate(nums = [99, 88, 77, 66, 55, 44, 33, 22, 11, 1]) == True\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 10, 20, 30, 40, 50]) == True\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 50, 60, 70, 80, 90, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 1, 2]) == True\n assert candidate(nums = [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == True\n assert candidate(nums = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65]) == True\n assert candidate(nums = [1, 10, 2, 20, 3, 30, 4, 40, 5, 50, 6, 60, 7, 70, 8, 80, 9, 90]) == True\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 1, 2, 3, 4, 5]) == True\n assert candidate(nums = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(nums = [45, 55, 65, 75, 85, 95, 10, 20, 30, 40, 50, 60, 70, 80, 90]) == True\n assert candidate(nums = [5, 5, 5, 5, 5, 15, 15, 15, 15, 15]) == True\n assert candidate(nums = [1, 12, 3, 45, 6, 78, 9, 10, 11, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 24, 25, 26, 27, 28, 29, 31, 32, 33, 34, 35, 36, 37, 38, 39, 41, 42, 43, 44, 46, 47, 48, 49, 51, 52, 53, 54, 56, 57, 58, 59, 61, 62, 63, 64, 66, 67, 68, 69, 71, 72, 73, 74, 76, 77, 78, 79, 81, 82, 83, 84, 86, 87, 88, 89, 91, 92, 93, 94, 96, 97, 98, 99]) == True\n assert candidate(nums = [1, 10, 100, 1000, 10000, 2, 20, 200, 2000, 20000]) == True\n assert candidate(nums = [1, 10, 100, 1000, 5, 50, 500, 5000, 9, 90, 900, 9000]) == True\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 1, 2, 3, 4, 5]) == True\n assert candidate(nums = [99, 1, 98, 2, 97, 3, 96, 4, 95, 5, 94, 6, 93, 7, 92, 8, 91, 9, 90]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99]) == True\n assert candidate(nums = [1, 12, 3, 14, 5, 16, 7, 18, 9, 10]) == True\n assert candidate(nums = [1, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == True\n assert candidate(nums = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34]) == True\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 90, 81, 72, 63, 54, 45]) == True\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 99, 1, 2, 3, 4, 5]) == True\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 1, 2, 3, 4, 6, 7, 8, 9]) == True\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().canAliceWin", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool canAliceWin(vector& nums) {", "container": "Solution", "callable": "canAliceWin", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3233, "task_id": "find-the-count-of-numbers-which-are-not-special", "difficulty": "Medium", "problem_description": "You are given 2 positive integers l and r. For any number x, all positive divisors of x except x are called the proper divisors of x.\nA number is called special if it has exactly 2 proper divisors. For example:\n\nThe number 4 is special because it has proper divisors 1 and 2.\nThe number 6 is not special because it has proper divisors 1, 2, and 3.\n\nReturn the count of numbers in the range [l, r] that are not special.\n \nExample 1:\n\nInput: l = 5, r = 7\nOutput: 3\nExplanation:\nThere are no special numbers in the range [5, 7].\n\nExample 2:\n\nInput: l = 4, r = 16\nOutput: 11\nExplanation:\nThe special numbers in the range [4, 16] are 4 and 9.\n\n \nConstraints:\n\n1 <= l <= r <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(l = 100,r = 200) == 99\n assert candidate(l = 5,r = 7) == 3\n assert candidate(l = 20,r = 50) == 29\n assert candidate(l = 1,r = 10) == 8\n assert candidate(l = 100,r = 150) == 50\n assert candidate(l = 4,r = 16) == 11\n assert candidate(l = 10,r = 20) == 11\n assert candidate(l = 1000,r = 10000) == 8987\n assert candidate(l = 25,r = 25) == 0\n assert candidate(l = 100000,r = 200000) == 99980\n assert candidate(l = 250000,r = 250100) == 101\n assert candidate(l = 1000000,r = 1000010) == 11\n assert candidate(l = 999999999,r = 1000000000) == 2\n assert candidate(l = 1,r = 100000000) == 99998771\n assert candidate(l = 100000,r = 150000) == 49990\n assert candidate(l = 1000000000,r = 1000000000) == 1\n assert candidate(l = 500000,r = 501000) == 1001\n assert candidate(l = 3,r = 3) == 1\n assert candidate(l = 1,r = 1000000) == 999832\n assert candidate(l = 5000,r = 6000) == 999\n assert candidate(l = 10000,r = 11000) == 999\n assert candidate(l = 2,r = 2) == 1\n assert candidate(l = 5000,r = 7000) == 1997\n assert candidate(l = 1000000,r = 1500000) == 499969\n assert candidate(l = 8,r = 8) == 1\n assert candidate(l = 1000000,r = 10000000) == 8999723\n assert candidate(l = 300000000,r = 400000000) == 99999729\n assert candidate(l = 500000,r = 1000000) == 499959\n assert candidate(l = 4,r = 1000000) == 999829\n assert candidate(l = 10000000,r = 10001000) == 1001\n assert candidate(l = 25,r = 50) == 24\n assert candidate(l = 1,r = 3) == 3\n assert candidate(l = 999999,r = 1000000) == 2\n assert candidate(l = 999900,r = 1000000) == 101\n assert candidate(l = 50,r = 100) == 51\n assert candidate(l = 8,r = 100) == 90\n assert candidate(l = 16,r = 25) == 9\n assert candidate(l = 1000000,r = 1001000) == 1001\n assert candidate(l = 16,r = 256) == 237\n assert candidate(l = 999,r = 1001) == 3\n assert candidate(l = 123456,r = 789012) == 665473\n assert candidate(l = 10000,r = 10100) == 101\n assert candidate(l = 999999950,r = 1000000000) == 51\n assert candidate(l = 50000,r = 60000) == 9996\n assert candidate(l = 123456,r = 123486) == 31\n assert candidate(l = 49,r = 50) == 1\n assert candidate(l = 97,r = 101) == 5\n assert candidate(l = 10000,r = 100000) == 89961\n assert candidate(l = 3000000,r = 3000100) == 101\n assert candidate(l = 500,r = 500) == 1\n assert candidate(l = 100000000,r = 100010000) == 10001\n assert candidate(l = 1234567,r = 8765432) == 7530626\n assert candidate(l = 150,r = 250) == 100\n assert candidate(l = 2,r = 3) == 2\n assert candidate(l = 8000000,r = 8000100) == 101\n assert candidate(l = 25,r = 36) == 11\n assert candidate(l = 987654,r = 987674) == 21\n assert candidate(l = 500,r = 1500) == 997\n assert candidate(l = 5000,r = 50000) == 44972\n assert candidate(l = 2000000,r = 2000050) == 51\n assert candidate(l = 500000,r = 500010) == 11\n assert candidate(l = 1,r = 100) == 96\n assert candidate(l = 500000,r = 600000) == 99990\n assert candidate(l = 1,r = 1000) == 989\n assert candidate(l = 1000,r = 2000) == 998\n assert candidate(l = 14,r = 28) == 14\n assert candidate(l = 100000000,r = 1000000000) == 899997829\n assert candidate(l = 1000000,r = 1000100) == 101\n assert candidate(l = 500000000,r = 600000000) == 99999786\n assert candidate(l = 101,r = 200) == 98\n assert candidate(l = 100,r = 1000) == 894\n assert candidate(l = 81,r = 81) == 1\n assert candidate(l = 49,r = 64) == 15\n assert candidate(l = 8,r = 25) == 16\n assert candidate(l = 5000,r = 7500) == 2497\n assert candidate(l = 25,r = 49) == 23\n assert candidate(l = 1000,r = 1500) == 500\n"}, "metadata": {"canonical_parameter_names": ["l", "r"], "leetcode_dataset_entry_point": "Solution().nonSpecialCount", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int nonSpecialCount(int l, int r) {", "container": "Solution", "callable": "nonSpecialCount", "parameters": [{"name": "l", "type": "int"}, {"name": "r", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3234, "task_id": "count-the-number-of-substrings-with-dominant-ones", "difficulty": "Medium", "problem_description": "You are given a binary string s.\nReturn the number of substrings with dominant ones.\nA string has dominant ones if the number of ones in the string is greater than or equal to the square of the number of zeros in the string.\n \nExample 1:\n\nInput: s = \"00011\"\nOutput: 5\nExplanation:\nThe substrings with dominant ones are shown in the table below.\n\n\n\n\ni\nj\ns[i..j]\nNumber of Zeros\nNumber of Ones\n\n\n\n\n3\n3\n1\n0\n1\n\n\n4\n4\n1\n0\n1\n\n\n2\n3\n01\n1\n1\n\n\n3\n4\n11\n0\n2\n\n\n2\n4\n011\n1\n2\n\n\n\nExample 2:\n\nInput: s = \"101101\"\nOutput: 16\nExplanation:\nThe substrings with non-dominant ones are shown in the table below.\nSince there are 21 substrings total and 5 of them have non-dominant ones, it follows that there are 16 substrings with dominant ones.\n\n\n\n\ni\nj\ns[i..j]\nNumber of Zeros\nNumber of Ones\n\n\n\n\n1\n1\n0\n1\n0\n\n\n4\n4\n0\n1\n0\n\n\n1\n4\n0110\n2\n2\n\n\n0\n4\n10110\n2\n3\n\n\n1\n5\n01101\n2\n3\n\n\n\n \nConstraints:\n\n1 <= s.length <= 4 * 104\ns consists only of characters '0' and '1'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"1111\") == 10\n assert candidate(s = \"100100100\") == 8\n assert candidate(s = \"1111010101\") == 33\n assert candidate(s = \"000111000\") == 12\n assert candidate(s = \"11110000\") == 15\n assert candidate(s = \"0000\") == 0\n assert candidate(s = \"111000\") == 9\n assert candidate(s = \"01010101111\") == 34\n assert candidate(s = \"0011110011\") == 31\n assert candidate(s = \"0000101010\") == 11\n assert candidate(s = \"00001111\") == 15\n assert candidate(s = \"000111\") == 9\n assert candidate(s = \"1001001001\") == 10\n assert candidate(s = \"11111\") == 15\n assert candidate(s = \"01010101\") == 14\n assert candidate(s = \"11010101\") == 18\n assert candidate(s = \"10101010\") == 14\n assert candidate(s = \"1010100000\") == 10\n assert candidate(s = \"010101\") == 10\n assert candidate(s = \"1100111100\") == 31\n assert candidate(s = \"101010\") == 10\n assert candidate(s = \"00011\") == 5\n assert candidate(s = \"11001100\") == 13\n assert candidate(s = \"101101\") == 16\n assert candidate(s = \"111000111\") == 18\n assert candidate(s = \"1010101010101010\") == 30\n assert candidate(s = \"00000\") == 0\n assert candidate(s = \"10010010\") == 8\n assert candidate(s = \"000111000111000111000\") == 36\n assert candidate(s = \"111111111111111111111111\") == 300\n assert candidate(s = \"000011000110001100011000\") == 28\n assert candidate(s = \"1111110000000011\") == 35\n assert candidate(s = \"111000111000111000\") == 33\n assert candidate(s = \"1111000000000011111\") == 37\n assert candidate(s = \"000000111111000000111111\") == 70\n assert candidate(s = \"0110110110110110110\") == 88\n assert candidate(s = \"1101010101010101\") == 34\n assert candidate(s = \"111111111100000000000000000000\") == 74\n assert candidate(s = \"10101010101010101010101010101010101010101010101010\") == 98\n assert candidate(s = \"11000000001111111111\") == 79\n assert candidate(s = \"00111111001111110011111100111111001111110011111100111111001111110011\") == 657\n assert candidate(s = \"11110000000000000000000000000000000\") == 15\n assert candidate(s = \"111110000011111000001111100000\") == 82\n assert candidate(s = \"1100110011001100\") == 29\n assert candidate(s = \"00000000000000000000000000001111111\") == 39\n assert candidate(s = \"010101010101010101010101\") == 46\n assert candidate(s = \"1100110011001100110011001100110011001100110011001100110011001100110\") == 133\n assert candidate(s = \"0001110001110001\") == 26\n assert candidate(s = \"1001001001001001001001001001001001001001001001001001001001001001\") == 64\n assert candidate(s = \"000111000111000111\") == 33\n assert candidate(s = \"101010101010101010101010\") == 46\n assert candidate(s = \"1100000000000011\") == 10\n assert candidate(s = \"1000000000001000\") == 5\n assert candidate(s = \"111111111111111111111111111100000000000000000000\") == 496\n assert candidate(s = \"1000000000000011\") == 7\n assert candidate(s = \"010101010101010101\") == 34\n assert candidate(s = \"1000000000000000000000000000\") == 2\n assert candidate(s = \"111000111000111000111000111000\") == 57\n assert candidate(s = \"1111111000000000000\") == 39\n assert candidate(s = \"0000000000000000\") == 0\n assert candidate(s = \"11111000001111100000111110000011111\") == 104\n assert candidate(s = \"101010101010101010101010101010\") == 58\n assert candidate(s = \"0100111101110010\") == 60\n assert candidate(s = \"100100100100100100100\") == 20\n assert candidate(s = \"111100001111000011110000\") == 57\n assert candidate(s = \"0000000001111111110000000000\") == 80\n assert candidate(s = \"0011001100110011\") == 29\n assert candidate(s = \"11000011000011000011000011\") == 31\n assert candidate(s = \"0000111100001111000011110000\") == 63\n assert candidate(s = \"1000000010000000100000001\") == 10\n assert candidate(s = \"0000000000000000000000000000000000000000000000000000000000000000\") == 0\n assert candidate(s = \"11111000000000001111111111\") == 96\n assert candidate(s = \"000000010000000100000001\") == 8\n assert candidate(s = \"100010001000100010001000\") == 17\n assert candidate(s = \"11111111111111111111000000000000\") == 264\n assert candidate(s = \"1001001001001001001001001001001\") == 31\n assert candidate(s = \"0000000000000000000000000000000000000000\") == 0\n assert candidate(s = \"11110000111100001111\") == 51\n assert candidate(s = \"1111111110000000000000000000\") == 61\n assert candidate(s = \"010101010101010101010101010101010101010101010101\") == 94\n assert candidate(s = \"11111000001111100000111110000011111000001111100000111110000011111\") == 194\n assert candidate(s = \"111111111100000000001111111111\") == 148\n assert candidate(s = \"01010101010101010101010101010101010101010101010101\") == 98\n assert candidate(s = \"000000000000000000000000000000001111111111111111111111111111111\") == 601\n assert candidate(s = \"111000011111000\") == 39\n assert candidate(s = \"11111111111111111111\") == 210\n assert candidate(s = \"1001001001001001001001001001001001001001001001001001\") == 52\n assert candidate(s = \"0000000000000000000000000000001111111111111111111111111111111\") == 601\n assert candidate(s = \"1111111111111111\") == 136\n assert candidate(s = \"1111111111111111111111111111111111111111111111111111111111111111\") == 2080\n assert candidate(s = \"0000000111111111111\") == 103\n assert candidate(s = \"0101010111111111\") == 96\n assert candidate(s = \"00000000000000000000000000000000111111111111111111111111111111111\") == 676\n assert candidate(s = \"111111000000111111000000111111\") == 100\n assert candidate(s = \"0000000001111111\") == 39\n assert candidate(s = \"0001010101101011\") == 37\n assert candidate(s = \"00000000001111111111\") == 74\n assert candidate(s = \"0011001100110011001100110011001100110011001100110011001100110011001\") == 129\n assert candidate(s = \"1111100000111110000011111\") == 74\n assert candidate(s = \"111000111000111000111\") == 42\n assert candidate(s = \"1001001001001001\") == 16\n assert candidate(s = \"11001100110011001100\") == 37\n assert candidate(s = \"01010101010101010101010101010101\") == 62\n assert candidate(s = \"1110010001100011110\") == 40\n assert candidate(s = \"1111000000000000000000000000000000000000\") == 15\n assert candidate(s = \"00000000000000000000000000000000000000000000000000\") == 0\n assert candidate(s = \"1001001001001001001001\") == 22\n assert candidate(s = \"111000111000111000111000111\") == 54\n assert candidate(s = \"0000111111110000\") == 63\n assert candidate(s = \"0011110011110011\") == 65\n assert candidate(s = \"1111111100000000\") == 49\n assert candidate(s = \"1111000011110000111100001111000011110000\") == 99\n assert candidate(s = \"11100111001110011100111001110011100111001110011100\") == 171\n assert candidate(s = \"111110000111100001111\") == 58\n assert candidate(s = \"110000110000110000110000110000\") == 33\n assert candidate(s = \"0101010101010101\") == 30\n assert candidate(s = \"000000000000000000000000\") == 0\n assert candidate(s = \"111000111000111000111000111000111000111000111000\") == 93\n assert candidate(s = \"00000000000000000000000000000000000111111111111111\") == 154\n assert candidate(s = \"0000011111111100000\") == 80\n assert candidate(s = \"0000111111111111\") == 103\n assert candidate(s = \"000111000111000111000111000111\") == 57\n assert candidate(s = \"1000100010001000100\") == 14\n assert candidate(s = \"1001001001001001001\") == 19\n assert candidate(s = \"0110011001100110011001\") == 41\n assert candidate(s = \"11111111111111111000000000000000000000000000000000000000000000011\") == 200\n assert candidate(s = \"0010110101101011\") == 46\n assert candidate(s = \"000000000011111111110000000000\") == 96\n assert candidate(s = \"00000111110000011111000001111100000111110000011111000001111100000\") == 180\n assert candidate(s = \"11111111111111111111111111111111111111111111111111\") == 1275\n assert candidate(s = \"11011011011011011011011011011011011\") == 184\n assert candidate(s = \"1110001110001110\") == 33\n assert candidate(s = \"10010010010010010010010010010010\") == 32\n assert candidate(s = \"1110011100011100011\") == 44\n assert candidate(s = \"00000000000000000000\") == 0\n assert candidate(s = \"1111000011110000\") == 36\n assert candidate(s = \"10101010101010101010101010101010\") == 62\n assert candidate(s = \"01001001001001001001001\") == 23\n assert candidate(s = \"1111111111000000\") == 74\n assert candidate(s = \"0000000011111111\") == 49\n assert candidate(s = \"1111000000001111\") == 30\n assert candidate(s = \"01001001001001001001001001001001\") == 32\n assert candidate(s = \"1000001111110000\") == 42\n assert candidate(s = \"000000000011111111111111111111\") == 264\n assert candidate(s = \"1100001100001100\") == 19\n assert candidate(s = \"1111111111\") == 55\n assert candidate(s = \"1010101010101010101010101010101010101010\") == 78\n assert candidate(s = \"0110011001100110\") == 31\n assert candidate(s = \"1111000000000000111111111111\") == 118\n assert candidate(s = \"1111000011110000111100001111\") == 72\n assert candidate(s = \"00000000000000000001\") == 2\n assert candidate(s = \"0000000000111111\") == 30\n assert candidate(s = \"0011001100110011001100110011\") == 53\n assert candidate(s = \"01010101010101010101\") == 38\n assert candidate(s = \"111110111110111110111110111110\") == 453\n assert candidate(s = \"111110000000\") == 22\n assert candidate(s = \"1111111101010101\") == 84\n assert candidate(s = \"1101001010010100\") == 24\n assert candidate(s = \"1111010101010101\") == 45\n assert candidate(s = \"000001111100000111110000011111\") == 82\n assert candidate(s = \"0000000000000000000000000001\") == 2\n assert candidate(s = \"10101010101010101010\") == 38\n assert candidate(s = \"0110110110110110110110110110110\") == 156\n assert candidate(s = \"11111111111111110000000000\") == 174\n assert candidate(s = \"0000111100001111\") == 36\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().numberOfSubstrings", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int numberOfSubstrings(string s) {", "container": "Solution", "callable": "numberOfSubstrings", "parameters": [{"name": "s", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3235, "task_id": "check-if-the-rectangle-corner-is-reachable", "difficulty": "Hard", "problem_description": "You are given two positive integers xCorner and yCorner, and a 2D array circles, where circles[i] = [xi, yi, ri] denotes a circle with center at (xi, yi) and radius ri.\nThere is a rectangle in the coordinate plane with its bottom left corner at the origin and top right corner at the coordinate (xCorner, yCorner). You need to check whether there is a path from the bottom left corner to the top right corner such that the entire path lies inside the rectangle, does not touch or lie inside any circle, and touches the rectangle only at the two corners.\nReturn true if such a path exists, and false otherwise.\n \nExample 1:\n\nInput: xCorner = 3, yCorner = 4, circles = [[2,1,1]]\nOutput: true\nExplanation:\n\nThe black curve shows a possible path between (0, 0) and (3, 4).\n\nExample 2:\n\nInput: xCorner = 3, yCorner = 3, circles = [[1,1,2]]\nOutput: false\nExplanation:\n\nNo path exists from (0, 0) to (3, 3).\n\nExample 3:\n\nInput: xCorner = 3, yCorner = 3, circles = [[2,1,1],[1,2,1]]\nOutput: false\nExplanation:\n\nNo path exists from (0, 0) to (3, 3).\n\nExample 4:\n\nInput: xCorner = 4, yCorner = 4, circles = [[5,5,1]]\nOutput: true\nExplanation:\n\n\n \nConstraints:\n\n3 <= xCorner, yCorner <= 109\n1 <= circles.length <= 1000\ncircles[i].length == 3\n1 <= xi, yi, ri <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(xCorner = 10,yCorner = 10,circles = [[1, 1, 1], [9, 9, 1]]) == False\n assert candidate(xCorner = 1000000000,yCorner = 1000000000,circles = [[500000000, 500000000, 499999999]]) == True\n assert candidate(xCorner = 5,yCorner = 5,circles = [[1, 1, 1], [4, 4, 1], [2, 2, 1]]) == False\n assert candidate(xCorner = 1000000000,yCorner = 1000000000,circles = [[500000000, 500000000, 100000000]]) == True\n assert candidate(xCorner = 10,yCorner = 10,circles = [[5, 5, 2], [2, 2, 1]]) == True\n assert candidate(xCorner = 5,yCorner = 5,circles = [[2, 2, 1], [3, 3, 1]]) == True\n assert candidate(xCorner = 5,yCorner = 5,circles = [[1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1]]) == False\n assert candidate(xCorner = 1000000000,yCorner = 1000000000,circles = [[500000000, 500000000, 500000000]]) == False\n assert candidate(xCorner = 1000000000,yCorner = 1000000000,circles = [[500000000, 500000000, 1]]) == True\n assert candidate(xCorner = 3,yCorner = 3,circles = [[2, 1, 1], [1, 2, 1]]) == False\n assert candidate(xCorner = 3,yCorner = 4,circles = [[2, 1, 1]]) == True\n assert candidate(xCorner = 4,yCorner = 4,circles = [[5, 5, 1]]) == True\n assert candidate(xCorner = 10,yCorner = 10,circles = [[5, 5, 1], [3, 3, 2]]) == True\n assert candidate(xCorner = 3,yCorner = 3,circles = [[1, 1, 2]]) == False\n assert candidate(xCorner = 15,yCorner = 15,circles = [[3, 3, 3], [12, 12, 3], [7, 7, 2], [9, 9, 1]]) == False\n assert candidate(xCorner = 1000000000,yCorner = 1000000000,circles = [[500000000, 500000000, 500000000]]) == False\n assert candidate(xCorner = 20,yCorner = 20,circles = [[10, 10, 5], [15, 15, 3], [5, 5, 2], [18, 2, 1], [2, 18, 1]]) == True\n assert candidate(xCorner = 25,yCorner = 25,circles = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5]]) == False\n assert candidate(xCorner = 8,yCorner = 8,circles = [[2, 2, 3], [6, 6, 3]]) == False\n assert candidate(xCorner = 10,yCorner = 10,circles = [[5, 5, 2], [2, 2, 3], [8, 8, 3]]) == False\n assert candidate(xCorner = 10,yCorner = 10,circles = [[1, 5, 1], [9, 5, 1], [5, 1, 1], [5, 9, 1], [2, 2, 2], [8, 2, 2], [2, 8, 2], [8, 8, 2]]) == False\n assert candidate(xCorner = 8,yCorner = 8,circles = [[4, 4, 2], [2, 2, 1], [6, 6, 1], [1, 7, 2], [7, 1, 2]]) == True\n assert candidate(xCorner = 1000000,yCorner = 1000000,circles = [[500000, 500000, 300000], [300000, 300000, 100000], [700000, 700000, 100000], [100000, 100000, 50000], [900000, 900000, 50000], [100000, 900000, 50000], [900000, 100000, 50000], [500000, 100000, 200000], [500000, 900000, 200000]]) == False\n assert candidate(xCorner = 15,yCorner = 15,circles = [[1, 1, 1], [14, 14, 1], [7, 7, 5]]) == False\n assert candidate(xCorner = 7,yCorner = 7,circles = [[3, 3, 1], [4, 3, 1], [3, 4, 1], [4, 4, 1], [2, 2, 1], [2, 3, 1], [3, 2, 1], [2, 4, 1], [4, 2, 1]]) == True\n assert candidate(xCorner = 30,yCorner = 30,circles = [[1, 1, 1], [29, 29, 1], [15, 15, 10], [15, 15, 5]]) == False\n assert candidate(xCorner = 9,yCorner = 9,circles = [[1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1], [6, 6, 1], [7, 7, 1], [8, 8, 1]]) == False\n assert candidate(xCorner = 10,yCorner = 10,circles = [[5, 5, 4], [2, 2, 1], [8, 8, 1], [1, 1, 1], [9, 9, 1], [4, 1, 1], [1, 4, 1], [8, 4, 1], [4, 8, 1]]) == False\n assert candidate(xCorner = 3,yCorner = 10,circles = [[2, 5, 1], [1, 3, 1], [2, 8, 1], [1, 7, 1], [2, 2, 1], [1, 1, 1], [2, 9, 1], [1, 9, 1]]) == False\n assert candidate(xCorner = 10,yCorner = 10,circles = [[1, 5, 2], [5, 1, 2], [5, 9, 2], [9, 5, 2]]) == True\n assert candidate(xCorner = 15,yCorner = 15,circles = [[1, 1, 1], [15, 15, 1], [1, 15, 1], [15, 1, 1], [8, 8, 3], [7, 7, 2], [9, 9, 2]]) == False\n assert candidate(xCorner = 20,yCorner = 20,circles = [[1, 1, 1], [1, 20, 1], [20, 1, 1], [20, 20, 1], [10, 10, 5]]) == False\n assert candidate(xCorner = 1000000000,yCorner = 1000000000,circles = [[999999999, 999999999, 1], [500000000, 500000000, 500000000]]) == False\n assert candidate(xCorner = 9,yCorner = 9,circles = [[1, 1, 2], [2, 2, 2], [3, 3, 2], [4, 4, 2], [5, 5, 2], [6, 6, 2], [7, 7, 2], [8, 8, 2], [9, 9, 2], [1, 9, 2], [9, 1, 2], [4.5, 4.5, 3]]) == False\n assert candidate(xCorner = 50,yCorner = 50,circles = [[5, 5, 5], [45, 45, 5], [25, 25, 10], [15, 15, 3], [35, 35, 3]]) == False\n assert candidate(xCorner = 150,yCorner = 150,circles = [[10, 10, 10], [20, 20, 10], [30, 30, 10], [40, 40, 10], [50, 50, 10], [60, 60, 10], [70, 70, 10], [80, 80, 10], [90, 90, 10], [100, 100, 10], [110, 110, 10], [120, 120, 10], [130, 130, 10], [140, 140, 10], [150, 150, 10]]) == False\n assert candidate(xCorner = 20,yCorner = 15,circles = [[10, 10, 5], [15, 15, 3], [5, 5, 4]]) == True\n assert candidate(xCorner = 15,yCorner = 20,circles = [[1, 1, 1], [14, 19, 1], [8, 10, 2], [7, 8, 2], [9, 8, 2], [8, 7, 2], [8, 9, 2]]) == False\n assert candidate(xCorner = 100,yCorner = 100,circles = [[50, 25, 20], [50, 75, 20], [25, 50, 20], [75, 50, 20]]) == True\n assert candidate(xCorner = 500,yCorner = 500,circles = [[100, 100, 50], [400, 400, 50], [250, 250, 150], [250, 250, 100]]) == True\n assert candidate(xCorner = 999999999,yCorner = 999999999,circles = [[500000000, 500000000, 100000000], [900000000, 900000000, 100000000], [100000000, 100000000, 100000000]]) == False\n assert candidate(xCorner = 500,yCorner = 500,circles = [[250, 250, 150], [100, 100, 50], [400, 400, 50], [50, 50, 20], [450, 450, 20], [100, 450, 20], [450, 100, 20], [250, 50, 100], [250, 450, 100]]) == False\n assert candidate(xCorner = 10,yCorner = 10,circles = [[5, 5, 2], [5, 5, 1]]) == True\n assert candidate(xCorner = 10,yCorner = 10,circles = [[3, 3, 1], [6, 6, 1], [2, 8, 2], [8, 2, 2]]) == True\n assert candidate(xCorner = 1000,yCorner = 1000,circles = [[500, 500, 300], [300, 300, 100], [700, 700, 100], [100, 100, 50], [900, 900, 50], [100, 900, 50], [900, 100, 50], [500, 100, 200], [500, 900, 200]]) == False\n assert candidate(xCorner = 6,yCorner = 8,circles = [[1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1], [6, 6, 1], [1, 8, 1], [6, 1, 1]]) == False\n assert candidate(xCorner = 10,yCorner = 10,circles = [[1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1], [6, 6, 1], [7, 7, 1], [8, 8, 1], [9, 9, 1]]) == False\n assert candidate(xCorner = 100,yCorner = 100,circles = [[25, 25, 20], [75, 75, 20], [50, 50, 20], [25, 75, 20], [75, 25, 20]]) == True\n assert candidate(xCorner = 9,yCorner = 9,circles = [[2, 2, 2], [2, 6, 2], [6, 2, 2], [6, 6, 2], [5, 5, 1]]) == False\n assert candidate(xCorner = 7,yCorner = 7,circles = [[2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1], [6, 6, 1], [7, 7, 1]]) == False\n assert candidate(xCorner = 1000000,yCorner = 1000000,circles = [[100000, 100000, 50000], [900000, 900000, 50000], [500000, 500000, 150000], [500000, 500000, 100000]]) == True\n assert candidate(xCorner = 7,yCorner = 7,circles = [[1, 6, 1], [2, 5, 1], [3, 4, 1], [4, 3, 1], [5, 2, 1], [6, 1, 1], [7, 7, 1], [7, 6, 1], [7, 5, 1], [7, 4, 1], [7, 3, 1], [7, 2, 1], [7, 1, 1]]) == False\n assert candidate(xCorner = 30,yCorner = 40,circles = [[15, 20, 5], [10, 25, 6], [20, 10, 4], [5, 30, 3], [25, 5, 2]]) == True\n assert candidate(xCorner = 100,yCorner = 100,circles = [[50, 50, 30], [70, 70, 20], [30, 30, 25], [10, 10, 10], [90, 90, 10]]) == False\n assert candidate(xCorner = 12,yCorner = 12,circles = [[1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1], [6, 6, 1], [7, 7, 1], [8, 8, 1], [9, 9, 1], [10, 10, 1], [11, 11, 1], [12, 12, 1], [1, 12, 1], [12, 1, 1]]) == False\n assert candidate(xCorner = 12,yCorner = 12,circles = [[1, 1, 2], [2, 2, 2], [3, 3, 2], [4, 4, 2], [5, 5, 2], [6, 6, 2], [7, 7, 2], [8, 8, 2], [9, 9, 2], [10, 10, 2], [11, 11, 2]]) == False\n assert candidate(xCorner = 20,yCorner = 20,circles = [[5, 10, 3], [10, 5, 3], [10, 15, 3], [15, 10, 3], [10, 10, 5]]) == True\n assert candidate(xCorner = 8,yCorner = 8,circles = [[1, 8, 1], [8, 1, 1], [4, 4, 2], [2, 2, 1], [6, 6, 1], [5, 5, 1], [3, 3, 1], [7, 7, 1]]) == False\n assert candidate(xCorner = 10,yCorner = 3,circles = [[5, 2, 1], [4, 2, 1], [6, 2, 1], [3, 2, 1], [7, 2, 1], [2, 2, 1], [8, 2, 1], [5, 1, 1]]) == False\n assert candidate(xCorner = 20,yCorner = 20,circles = [[1, 1, 1], [20, 20, 1], [10, 10, 5], [15, 5, 3]]) == False\n assert candidate(xCorner = 25,yCorner = 25,circles = [[5, 10, 5], [10, 5, 5], [20, 20, 5], [15, 15, 5], [25, 5, 5], [5, 25, 5]]) == False\n assert candidate(xCorner = 50,yCorner = 50,circles = [[1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1], [45, 45, 1], [46, 46, 1], [47, 47, 1], [48, 48, 1], [49, 49, 1]]) == False\n assert candidate(xCorner = 10,yCorner = 10,circles = [[1, 1, 1], [9, 9, 1], [5, 5, 2], [3, 3, 1], [7, 7, 1]]) == False\n assert candidate(xCorner = 15,yCorner = 15,circles = [[8, 8, 3], [7, 7, 2], [6, 6, 1], [9, 9, 2], [10, 10, 3], [11, 11, 4]]) == False\n assert candidate(xCorner = 50,yCorner = 50,circles = [[10, 10, 5], [20, 20, 5], [30, 30, 5], [40, 40, 5], [50, 50, 5]]) == False\n assert candidate(xCorner = 80,yCorner = 60,circles = [[10, 10, 10], [20, 20, 10], [30, 30, 10], [40, 40, 10], [50, 50, 10], [60, 60, 10], [70, 70, 10]]) == False\n assert candidate(xCorner = 10000,yCorner = 10000,circles = [[1000, 1000, 500], [9000, 9000, 500], [5000, 5000, 1500], [5000, 5000, 1000]]) == True\n assert candidate(xCorner = 7,yCorner = 7,circles = [[1, 1, 1], [1, 7, 1], [7, 1, 1], [7, 7, 1], [3, 4, 1], [4, 3, 1], [4, 5, 1], [5, 4, 1]]) == False\n assert candidate(xCorner = 9,yCorner = 9,circles = [[1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1], [6, 6, 1], [7, 7, 1], [8, 8, 1], [9, 9, 1]]) == False\n assert candidate(xCorner = 30,yCorner = 40,circles = [[10, 10, 5], [20, 20, 10], [5, 5, 2], [25, 25, 4]]) == True\n assert candidate(xCorner = 50,yCorner = 50,circles = [[25, 25, 10], [30, 30, 15], [20, 20, 5], [10, 40, 5]]) == True\n assert candidate(xCorner = 100000,yCorner = 100000,circles = [[10000, 10000, 5000], [90000, 90000, 5000], [50000, 50000, 15000], [50000, 50000, 10000]]) == True\n assert candidate(xCorner = 100,yCorner = 100,circles = [[50, 50, 20], [30, 30, 5], [70, 70, 5], [10, 10, 2], [90, 90, 2], [10, 90, 2], [90, 10, 2], [50, 10, 10], [50, 90, 10]]) == True\n assert candidate(xCorner = 500000000,yCorner = 500000000,circles = [[250000000, 250000000, 100000000], [300000000, 300000000, 150000000]]) == True\n assert candidate(xCorner = 100,yCorner = 100,circles = [[10, 10, 5], [90, 90, 5], [50, 50, 20], [50, 50, 10]]) == True\n assert candidate(xCorner = 1000,yCorner = 1000,circles = [[100, 100, 100], [900, 900, 100], [500, 500, 500], [300, 700, 200], [700, 300, 200]]) == False\n assert candidate(xCorner = 1000000000,yCorner = 1000000000,circles = [[500000000, 500000000, 500000000], [1000000000, 1000000000, 1]]) == False\n assert candidate(xCorner = 1000,yCorner = 1000,circles = [[1, 1, 1], [1000, 1000, 1], [500, 500, 100], [900, 900, 50]]) == False\n assert candidate(xCorner = 1000000000,yCorner = 1000000000,circles = [[500000000, 500000000, 499999999], [1000000000, 1000000000, 1]]) == False\n assert candidate(xCorner = 9,yCorner = 9,circles = [[3, 3, 2], [6, 6, 2], [4, 4, 1], [5, 5, 1]]) == True\n assert candidate(xCorner = 50,yCorner = 50,circles = [[25, 25, 10], [10, 10, 5], [40, 40, 5], [5, 5, 2], [45, 45, 2], [10, 40, 2], [40, 10, 2]]) == True\n assert candidate(xCorner = 100,yCorner = 100,circles = [[50, 50, 10], [40, 40, 10], [60, 60, 10], [50, 30, 10], [50, 70, 10]]) == True\n assert candidate(xCorner = 10,yCorner = 10,circles = [[1, 1, 1], [9, 9, 1], [5, 5, 2], [2, 5, 1], [5, 2, 1]]) == False\n assert candidate(xCorner = 50,yCorner = 50,circles = [[10, 10, 5], [20, 20, 5], [30, 30, 5], [40, 40, 5]]) == True\n assert candidate(xCorner = 1000,yCorner = 1000,circles = [[100, 100, 100], [900, 900, 100], [500, 500, 300], [500, 500, 200]]) == False\n assert candidate(xCorner = 25,yCorner = 25,circles = [[5, 5, 4], [20, 20, 4], [15, 15, 4], [10, 10, 3], [25, 25, 1]]) == False\n assert candidate(xCorner = 20,yCorner = 20,circles = [[5, 5, 4], [15, 15, 4], [10, 10, 6]]) == True\n assert candidate(xCorner = 100,yCorner = 100,circles = [[50, 50, 10], [20, 20, 5], [80, 80, 5], [10, 10, 2], [90, 90, 2], [10, 90, 2], [90, 10, 2], [50, 10, 5], [50, 90, 5], [10, 50, 5], [90, 50, 5]]) == True\n assert candidate(xCorner = 10,yCorner = 10,circles = [[1, 1, 2], [9, 9, 2], [5, 5, 3]]) == False\n assert candidate(xCorner = 50,yCorner = 50,circles = [[10, 10, 5], [40, 40, 5], [10, 40, 5], [40, 10, 5], [25, 25, 10]]) == True\n assert candidate(xCorner = 10,yCorner = 10,circles = [[2, 2, 2], [3, 3, 1], [4, 4, 2], [5, 5, 1], [6, 6, 2], [7, 7, 1], [8, 8, 2]]) == False\n assert candidate(xCorner = 100,yCorner = 50,circles = [[25, 25, 15], [75, 25, 15], [50, 45, 10]]) == True\n assert candidate(xCorner = 15,yCorner = 15,circles = [[1, 1, 2], [2, 2, 2], [3, 3, 2], [4, 4, 2], [5, 5, 2], [6, 6, 2], [7, 7, 2], [8, 8, 2], [9, 9, 2], [10, 10, 2], [11, 11, 2], [12, 12, 2], [13, 13, 2], [14, 14, 2]]) == False\n assert candidate(xCorner = 25,yCorner = 25,circles = [[5, 5, 1], [6, 6, 1], [7, 7, 1], [8, 8, 1], [9, 9, 1], [10, 10, 1], [11, 11, 1], [12, 12, 1], [13, 13, 1], [14, 14, 1], [15, 15, 1], [16, 16, 1], [17, 17, 1], [18, 18, 1], [19, 19, 1], [20, 20, 1], [21, 21, 1], [22, 22, 1], [23, 23, 1], [24, 24, 1], [25, 25, 1], [1, 1, 12], [25, 25, 12]]) == False\n assert candidate(xCorner = 100,yCorner = 100,circles = [[25, 25, 20], [75, 75, 20], [50, 50, 10], [10, 90, 10], [90, 10, 10]]) == True\n assert candidate(xCorner = 999999999,yCorner = 999999999,circles = [[499999999, 499999999, 100000000], [500000000, 500000000, 200000000]]) == True\n assert candidate(xCorner = 999999999,yCorner = 999999999,circles = [[999999999, 999999999, 10], [1, 1, 100], [500000000, 500000000, 1000000]]) == False\n assert candidate(xCorner = 18,yCorner = 18,circles = [[1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1], [6, 6, 1], [7, 7, 1], [8, 8, 1], [9, 9, 1], [10, 10, 1], [11, 11, 1], [12, 12, 1], [13, 13, 1], [14, 14, 1], [15, 15, 1], [16, 16, 1], [17, 17, 1], [18, 18, 1], [9, 9, 5]]) == False\n assert candidate(xCorner = 100,yCorner = 100,circles = [[50, 50, 20], [30, 70, 15], [70, 30, 15], [10, 10, 5], [90, 90, 5], [20, 20, 3], [80, 80, 3]]) == True\n assert candidate(xCorner = 12,yCorner = 12,circles = [[6, 6, 3], [3, 3, 2], [9, 9, 2], [1, 1, 1], [11, 11, 1]]) == False\n assert candidate(xCorner = 18,yCorner = 18,circles = [[9, 9, 5], [1, 1, 1], [17, 17, 1], [1, 17, 1], [17, 1, 1], [5, 5, 1], [13, 13, 1], [7, 13, 1], [13, 7, 1]]) == False\n assert candidate(xCorner = 20,yCorner = 20,circles = [[5, 5, 3], [10, 10, 3], [15, 15, 3], [2, 2, 1], [18, 18, 1]]) == True\n assert candidate(xCorner = 10,yCorner = 10,circles = [[3, 3, 2], [7, 7, 2], [5, 5, 1]]) == True\n assert candidate(xCorner = 100,yCorner = 100,circles = [[50, 50, 40], [70, 30, 20], [30, 70, 25], [10, 10, 5], [90, 90, 5]]) == True\n assert candidate(xCorner = 20,yCorner = 20,circles = [[5, 5, 1], [15, 15, 1], [10, 10, 5], [5, 15, 1], [15, 5, 1]]) == True\n"}, "metadata": {"canonical_parameter_names": ["xCorner", "yCorner", "circles"], "leetcode_dataset_entry_point": "Solution().canReachCorner", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool canReachCorner(int xCorner, int yCorner, vector>& circles) {", "container": "Solution", "callable": "canReachCorner", "parameters": [{"name": "xCorner", "type": "int"}, {"name": "yCorner", "type": "int"}, {"name": "circles", "type": "vector>&"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3238, "task_id": "find-the-number-of-winning-players", "difficulty": "Easy", "problem_description": "You are given an integer n representing the number of players in a game and a 2D array pick where pick[i] = [xi, yi] represents that the player xi picked a ball of color yi.\nPlayer i wins the game if they pick strictly more than i balls of the same color. In other words,\n\nPlayer 0 wins if they pick any ball.\nPlayer 1 wins if they pick at least two balls of the same color.\n...\nPlayer i wins if they pick at leasti + 1 balls of the same color.\n\nReturn the number of players who win the game.\nNote that multiple players can win the game.\n \nExample 1:\n\nInput: n = 4, pick = [[0,0],[1,0],[1,0],[2,1],[2,1],[2,0]]\nOutput: 2\nExplanation:\nPlayer 0 and player 1 win the game, while players 2 and 3 do not win.\n\nExample 2:\n\nInput: n = 5, pick = [[1,1],[1,2],[1,3],[1,4]]\nOutput: 0\nExplanation:\nNo player wins the game.\n\nExample 3:\n\nInput: n = 5, pick = [[1,1],[2,4],[2,4],[2,4]]\nOutput: 1\nExplanation:\nPlayer 2 wins the game by picking 3 balls with color 4.\n\n \nConstraints:\n\n2 <= n <= 10\n1 <= pick.length <= 100\npick[i].length == 2\n0 <= xi <= n - 1 \n0 <= yi <= 10\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 10,pick = [[0, 0], [1, 1], [1, 1], [2, 2], [2, 2], [2, 2], [3, 3], [3, 3], [3, 3], [3, 3]]) == 4\n assert candidate(n = 10,pick = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 1\n assert candidate(n = 3,pick = [[0, 0], [1, 0], [1, 0], [1, 0]]) == 2\n assert candidate(n = 5,pick = [[1, 1], [2, 4], [2, 4], [2, 4]]) == 1\n assert candidate(n = 2,pick = [[0, 0], [1, 1], [1, 1]]) == 2\n assert candidate(n = 5,pick = [[1, 1], [1, 2], [1, 3], [1, 4]]) == 0\n assert candidate(n = 2,pick = [[0, 0], [1, 0], [1, 0], [1, 0]]) == 2\n assert candidate(n = 4,pick = [[0, 0], [1, 0], [1, 0], [2, 1], [2, 1], [2, 0]]) == 2\n assert candidate(n = 3,pick = [[0, 0], [1, 1], [1, 1], [2, 2], [2, 2], [2, 2]]) == 3\n assert candidate(n = 4,pick = [[0, 1], [0, 2], [0, 3], [1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3], [0, 1], [0, 2], [0, 3], [1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3]]) == 2\n assert candidate(n = 10,pick = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0], [0, 0], [1, 1], [1, 1], [2, 2], [2, 2], [2, 2], [3, 3], [3, 3], [3, 3], [3, 3], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4]]) == 5\n assert candidate(n = 4,pick = [[0, 1], [1, 1], [1, 2], [2, 2], [2, 2], [2, 2], [3, 2], [3, 2], [3, 2], [3, 2], [3, 2], [3, 2], [3, 2], [3, 2], [3, 2], [3, 2]]) == 3\n assert candidate(n = 5,pick = [[0, 1], [1, 1], [1, 2], [2, 2], [2, 2], [2, 3], [2, 3], [3, 3], [3, 3], [3, 4], [3, 4], [4, 4], [4, 5], [4, 5], [4, 6]]) == 1\n assert candidate(n = 6,pick = [[0, 0], [1, 1], [1, 1], [1, 2], [2, 2], [2, 2], [2, 2], [2, 3], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5]]) == 6\n assert candidate(n = 10,pick = [[0, 0], [1, 0], [1, 0], [2, 0], [2, 0], [2, 0], [2, 1], [3, 0], [3, 1], [3, 2], [3, 2], [3, 2], [4, 0], [4, 1], [4, 2], [4, 3], [4, 3], [4, 3], [4, 3], [5, 0], [5, 1], [5, 2], [5, 3], [5, 4], [5, 4], [5, 4], [6, 0], [6, 1], [6, 2], [6, 3], [6, 4], [6, 5], [6, 5], [6, 5], [7, 0], [7, 1], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [7, 6], [7, 6], [8, 0], [8, 1], [8, 2], [8, 3], [8, 4], [8, 5], [8, 6], [8, 7], [8, 7], [8, 7], [9, 0], [9, 1], [9, 2], [9, 3], [9, 4], [9, 5], [9, 6], [9, 7], [9, 8], [9, 8], [9, 8]]) == 3\n assert candidate(n = 7,pick = [[0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [3, 4], [3, 4], [3, 4], [3, 4], [4, 5], [4, 5], [4, 5], [4, 5], [5, 6], [5, 6], [5, 6], [5, 6], [6, 7], [6, 7], [6, 7], [6, 7], [6, 7], [6, 7], [6, 7]]) == 5\n assert candidate(n = 3,pick = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2], [2, 0], [2, 1], [2, 2], [2, 0], [2, 1], [2, 2], [2, 0], [2, 1], [2, 2]]) == 3\n assert candidate(n = 4,pick = [[0, 1], [0, 2], [0, 3], [1, 1], [1, 1], [1, 2], [2, 1], [2, 2], [2, 2], [3, 1], [3, 2], [3, 3], [3, 3], [3, 3]]) == 2\n assert candidate(n = 6,pick = [[0, 0], [1, 0], [1, 0], [1, 1], [2, 0], [2, 1], [2, 2], [3, 0], [3, 1], [3, 2], [3, 3], [4, 0], [4, 1], [4, 2], [4, 3], [4, 4], [5, 0], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5]]) == 2\n assert candidate(n = 7,pick = [[0, 0], [1, 0], [1, 1], [2, 1], [2, 2], [2, 2], [3, 2], [3, 3], [3, 3], [3, 3], [4, 3], [4, 4], [4, 4], [4, 4], [5, 4], [5, 4], [5, 5], [5, 5], [5, 5], [5, 5], [6, 5], [6, 5], [6, 5], [6, 6], [6, 6]]) == 1\n assert candidate(n = 3,pick = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2], [0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2], [2, 0], [2, 1], [2, 2]]) == 2\n assert candidate(n = 5,pick = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == 2\n assert candidate(n = 5,pick = [[0, 0], [0, 0], [0, 0], [0, 0], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4]]) == 5\n assert candidate(n = 8,pick = [[0, 0], [0, 0], [0, 0], [1, 0], [1, 0], [1, 0], [1, 1], [1, 1], [2, 0], [2, 0], [2, 0], [2, 1], [2, 1], [2, 2], [2, 2], [3, 0], [3, 0], [3, 0], [3, 1], [3, 1], [3, 1], [3, 2], [3, 2], [3, 2], [3, 3], [3, 3], [4, 0], [4, 0], [4, 0], [4, 0], [4, 1], [4, 1], [4, 1], [4, 1], [4, 2], [4, 2], [4, 2], [4, 2], [4, 3], [4, 3], [4, 3], [4, 3], [4, 4], [4, 4], [4, 4]]) == 3\n assert candidate(n = 7,pick = [[0, 1], [0, 2], [0, 3], [1, 1], [1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3], [4, 1], [4, 2], [4, 3], [4, 4], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [6, 1], [6, 2], [6, 3], [6, 4], [6, 5], [6, 6]]) == 2\n assert candidate(n = 5,pick = [[0, 0], [1, 1], [1, 1], [2, 2], [2, 2], [2, 2], [3, 3], [3, 3], [3, 3], [3, 3]]) == 4\n assert candidate(n = 6,pick = [[0, 0], [1, 0], [1, 0], [1, 0], [2, 0], [2, 0], [2, 0], [2, 0], [3, 0], [3, 0], [3, 0], [3, 0], [3, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [5, 0], [5, 0], [5, 0], [5, 0], [5, 0], [5, 0]]) == 6\n assert candidate(n = 5,pick = [[0, 0], [0, 1], [1, 0], [1, 0], [1, 1], [2, 1], [2, 1], [2, 1], [3, 2], [3, 2], [3, 2], [3, 2]]) == 4\n assert candidate(n = 10,pick = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [0, 2], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2], [8, 2], [9, 2]]) == 1\n assert candidate(n = 7,pick = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6]]) == 4\n assert candidate(n = 6,pick = [[0, 0], [0, 0], [1, 1], [1, 1], [1, 1], [1, 2], [1, 2], [2, 2], [2, 2], [2, 2], [2, 3], [2, 3], [2, 3], [3, 3], [3, 3], [3, 3], [3, 3], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5]]) == 6\n assert candidate(n = 10,pick = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1]]) == 1\n assert candidate(n = 5,pick = [[0, 0], [1, 0], [1, 1], [2, 1], [2, 2], [2, 2], [3, 2], [3, 2], [3, 3], [4, 3], [4, 4], [4, 4], [4, 4]]) == 1\n assert candidate(n = 4,pick = [[0, 0], [0, 0], [0, 0], [1, 1], [1, 1], [1, 1], [1, 1], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3]]) == 4\n assert candidate(n = 7,pick = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [0, 0], [1, 1], [2, 2]]) == 3\n assert candidate(n = 5,pick = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [1, 0], [1, 1], [1, 2], [1, 3], [1, 4], [2, 0], [2, 1], [2, 2], [2, 3], [2, 4], [3, 0], [3, 1], [3, 2], [3, 3], [3, 4], [4, 0], [4, 1], [4, 2], [4, 3], [4, 4]]) == 1\n assert candidate(n = 6,pick = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1]]) == 1\n assert candidate(n = 4,pick = [[0, 1], [0, 1], [0, 1], [1, 1], [1, 1], [1, 1], [1, 1], [2, 1], [2, 1], [2, 1], [2, 1], [3, 1], [3, 1], [3, 1], [3, 1], [3, 1]]) == 4\n assert candidate(n = 8,pick = [[0, 0], [0, 0], [0, 0], [1, 1], [1, 1], [1, 1], [1, 1], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3]]) == 4\n assert candidate(n = 5,pick = [[0, 0], [1, 0], [1, 1], [2, 0], [2, 1], [2, 2], [3, 0], [3, 1], [3, 2], [3, 3], [4, 0], [4, 1], [4, 2], [4, 3], [4, 4]]) == 1\n assert candidate(n = 5,pick = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4]]) == 4\n assert candidate(n = 5,pick = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [1, 0], [1, 0], [1, 1], [1, 1], [1, 2], [1, 2], [2, 0], [2, 0], [2, 1], [2, 2], [3, 0], [3, 0], [3, 0], [4, 0]]) == 2\n assert candidate(n = 10,pick = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [9, 0], [9, 0], [9, 0], [9, 0]]) == 1\n assert candidate(n = 10,pick = [[0, 0], [0, 0], [0, 0], [1, 0], [1, 0], [1, 0], [1, 1], [1, 1], [2, 0], [2, 0], [2, 0], [2, 1], [2, 1], [2, 2], [2, 2], [3, 0], [3, 0], [3, 0], [3, 1], [3, 1], [3, 1], [3, 2], [3, 2], [3, 2], [3, 3], [3, 3], [4, 0], [4, 0], [4, 0], [4, 0], [4, 1], [4, 1], [4, 1], [4, 1], [4, 2], [4, 2], [4, 2], [4, 2], [4, 3], [4, 3], [4, 3], [4, 3], [4, 4], [4, 4], [4, 4], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [6, 6], [6, 6], [6, 6], [6, 6], [6, 6], [6, 6], [6, 6], [7, 7], [7, 7], [7, 7], [7, 7], [7, 7], [7, 7], [7, 7], [7, 7], [8, 8], [8, 8], [8, 8], [8, 8], [8, 8], [8, 8], [8, 8], [8, 8], [8, 8], [9, 9], [9, 9], [9, 9], [9, 9], [9, 9], [9, 9], [9, 9], [9, 9], [9, 9], [9, 9]]) == 8\n assert candidate(n = 6,pick = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == 5\n assert candidate(n = 6,pick = [[0, 1], [0, 1], [1, 2], [1, 2], [1, 2], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [3, 4], [3, 4], [3, 4], [4, 5], [4, 5], [5, 6]]) == 3\n assert candidate(n = 10,pick = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0], [0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1]]) == 1\n assert candidate(n = 5,pick = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7]]) == 1\n assert candidate(n = 5,pick = [[0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [3, 4], [3, 4], [3, 4], [3, 4], [3, 4], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5]]) == 5\n assert candidate(n = 10,pick = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 4\n assert candidate(n = 4,pick = [[0, 0], [0, 1], [1, 0], [1, 1], [1, 0], [1, 1], [1, 0], [1, 1], [1, 0], [1, 1], [2, 0], [2, 0], [2, 1], [2, 1], [2, 1], [2, 1], [2, 1], [2, 1], [3, 0], [3, 1], [3, 2], [3, 0], [3, 1], [3, 2], [3, 0], [3, 1], [3, 2], [3, 0], [3, 1], [3, 2]]) == 4\n assert candidate(n = 5,pick = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4]]) == 5\n assert candidate(n = 10,pick = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 3\n assert candidate(n = 6,pick = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [0, 1], [0, 1], [1, 2], [1, 2], [2, 3], [2, 3], [3, 4], [3, 4], [4, 5], [4, 5], [5, 6], [5, 6], [0, 1], [0, 1], [0, 1], [1, 2], [1, 2], [1, 2], [1, 2], [2, 3], [2, 3], [2, 3], [2, 3], [3, 4], [3, 4], [3, 4], [3, 4], [3, 4], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [5, 6], [5, 6], [5, 6], [5, 6], [5, 6], [5, 6], [5, 6]]) == 6\n assert candidate(n = 4,pick = [[0, 1], [1, 2], [2, 3], [3, 4], [0, 1], [1, 2], [2, 3], [3, 4], [0, 1], [1, 2]]) == 2\n assert candidate(n = 7,pick = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [3, 1], [4, 1], [5, 1], [6, 1], [4, 1], [5, 1], [6, 1], [5, 1], [6, 1], [6, 1]]) == 7\n assert candidate(n = 9,pick = [[0, 0], [1, 0], [1, 1], [2, 0], [2, 1], [2, 2], [3, 0], [3, 1], [3, 2], [3, 3], [4, 0], [4, 1], [4, 2], [4, 3], [4, 4], [5, 0], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [6, 0], [6, 1], [6, 2], [6, 3], [6, 4], [6, 5], [6, 6], [7, 0], [7, 1], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [7, 7], [8, 0], [8, 1], [8, 2], [8, 3], [8, 4], [8, 5], [8, 6], [8, 7], [8, 8]]) == 1\n assert candidate(n = 6,pick = [[0, 0], [0, 1], [1, 1], [1, 1], [2, 2], [2, 2], [2, 2], [3, 3], [3, 3], [3, 3], [3, 3], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4]]) == 5\n assert candidate(n = 5,pick = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [1, 0], [1, 1], [1, 2], [1, 3], [2, 0], [2, 1], [2, 2], [3, 0], [3, 1], [4, 0]]) == 1\n assert candidate(n = 5,pick = [[0, 0], [1, 1], [1, 2], [2, 2], [2, 3], [3, 3], [3, 3], [3, 4], [4, 0], [4, 1], [4, 1]]) == 1\n assert candidate(n = 10,pick = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [0, 1], [0, 1], [1, 2], [1, 2], [1, 2], [2, 3], [2, 3], [2, 3], [2, 3], [3, 4], [3, 4], [3, 4], [3, 4], [3, 4]]) == 4\n assert candidate(n = 5,pick = [[0, 0], [1, 0], [1, 1], [2, 1], [2, 2], [2, 2], [3, 2], [3, 3], [3, 3], [3, 3]]) == 1\n assert candidate(n = 5,pick = [[0, 1], [1, 1], [1, 2], [2, 2], [2, 3], [2, 3], [3, 3], [3, 4], [3, 4], [3, 4], [4, 4]]) == 1\n assert candidate(n = 10,pick = [[0, 0], [1, 0], [1, 1], [2, 1], [2, 2], [2, 2], [3, 2], [3, 3], [3, 3], [3, 3], [4, 3], [4, 4], [4, 4], [4, 4], [5, 4], [5, 4], [5, 5], [5, 5], [5, 5], [5, 5], [6, 5], [6, 5], [6, 5], [6, 6], [6, 6], [7, 6], [7, 6], [7, 6], [7, 6], [7, 7], [8, 7], [8, 7], [8, 7], [8, 7], [8, 8], [8, 8], [9, 8], [9, 8], [9, 8], [9, 8], [9, 9], [9, 9], [9, 9], [9, 9]]) == 1\n assert candidate(n = 6,pick = [[0, 0], [0, 0], [0, 0], [0, 0], [1, 1], [1, 1], [1, 1], [2, 2], [2, 2], [2, 2], [3, 3], [3, 3], [4, 4], [4, 4], [4, 4], [4, 4], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5]]) == 4\n assert candidate(n = 6,pick = [[0, 0], [1, 0], [1, 1], [2, 1], [2, 2], [2, 2], [3, 2], [3, 3], [3, 3], [3, 3], [4, 3], [4, 4], [4, 4], [4, 4], [5, 4], [5, 4], [5, 5], [5, 5], [5, 5], [5, 5]]) == 1\n assert candidate(n = 5,pick = [[0, 1], [1, 1], [1, 1], [1, 1], [1, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3]]) == 3\n assert candidate(n = 7,pick = [[0, 0], [1, 0], [1, 1], [2, 0], [2, 1], [2, 2], [3, 0], [3, 1], [3, 2], [3, 3], [4, 0], [4, 1], [4, 2], [4, 3], [4, 4], [5, 0], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [6, 0], [6, 0], [6, 1], [6, 1], [6, 2], [6, 2], [6, 3], [6, 3], [6, 4], [6, 4], [6, 5], [6, 5]]) == 1\n assert candidate(n = 5,pick = [[0, 0], [1, 0], [1, 0], [1, 0], [2, 1], [2, 1], [2, 1], [2, 1], [2, 1], [3, 2], [3, 2], [3, 2], [3, 2], [3, 2], [3, 2], [3, 2], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3]]) == 5\n"}, "metadata": {"canonical_parameter_names": ["n", "pick"], "leetcode_dataset_entry_point": "Solution().winningPlayerCount", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int winningPlayerCount(int n, vector>& pick) {", "container": "Solution", "callable": "winningPlayerCount", "parameters": [{"name": "n", "type": "int"}, {"name": "pick", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3239, "task_id": "minimum-number-of-flips-to-make-binary-grid-palindromic-i", "difficulty": "Medium", "problem_description": "You are given an m x n binary matrix grid.\nA row or column is considered palindromic if its values read the same forward and backward.\nYou can flip any number of cells in grid from 0 to 1, or from 1 to 0.\nReturn the minimum number of cells that need to be flipped to make either all rows palindromic or all columns palindromic.\n \nExample 1:\n\nInput: grid = [[1,0,0],[0,0,0],[0,0,1]]\nOutput: 2\nExplanation:\n\nFlipping the highlighted cells makes all the rows palindromic.\n\nExample 2:\n\nInput: grid = [[0,1],[0,1],[0,0]]\nOutput: 1\nExplanation:\n\nFlipping the highlighted cell makes all the columns palindromic.\n\nExample 3:\n\nInput: grid = [[1],[0]]\nOutput: 0\nExplanation:\nAll rows are already palindromic.\n\n \nConstraints:\n\nm == grid.length\nn == grid[i].length\n1 <= m * n <= 2 * 105\n0 <= grid[i][j] <= 1\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[0, 0, 1, 1], [1, 1, 0, 0], [1, 0, 1, 0]]) == 2\n assert candidate(grid = [[1], [0]]) == 0\n assert candidate(grid = [[0, 1], [0, 1], [0, 0]]) == 1\n assert candidate(grid = [[1, 1, 0], [0, 1, 0], [0, 1, 1]]) == 2\n assert candidate(grid = [[1, 1, 1], [1, 0, 1], [1, 1, 1]]) == 0\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[1, 0, 0], [0, 0, 0], [0, 0, 1]]) == 2\n assert candidate(grid = [[0, 0, 1, 1], [1, 1, 0, 0], [1, 1, 0, 0]]) == 4\n assert candidate(grid = [[0, 0, 1, 0, 0, 0, 1, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[0, 1, 1, 0, 0], [1, 1, 1, 1, 1], [0, 0, 0, 1, 1], [1, 0, 1, 0, 0], [0, 0, 1, 1, 1]]) == 6\n assert candidate(grid = [[0, 0, 0, 1, 0, 1], [1, 1, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1]]) == 2\n assert candidate(grid = [[1, 1, 1, 1], [0, 0, 0, 0], [1, 1, 1, 1], [0, 0, 0, 0], [1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 0, 0, 0, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 0, 0, 0, 0, 0, 1, 1], [1, 0, 1, 0, 0, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 0], [0, 1, 1, 0, 1], [1, 0, 0, 1, 1], [0, 1, 1, 0, 1]]) == 6\n assert candidate(grid = [[0, 1, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0], [0, 1, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0]]) == 4\n assert candidate(grid = [[1, 1, 1, 0, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 0, 1, 1, 1]]) == 0\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 0, 1, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 0, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 0, 0, 1], [0, 0, 1, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 1, 0, 0, 1]]) == 2\n assert candidate(grid = [[0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0], [1, 1, 1, 0, 0, 1, 1, 1], [1, 1, 1, 0, 0, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 0, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 1, 0, 0, 1]]) == 0\n assert candidate(grid = [[0, 1, 1, 0, 1, 1], [1, 1, 1, 1, 0, 0], [1, 0, 0, 0, 1, 0], [0, 0, 1, 0, 1, 0]]) == 6\n assert candidate(grid = [[0, 1, 1, 0, 0, 1, 1, 0, 0, 1], [1, 0, 0, 1, 1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1, 1, 0, 0, 1], [1, 0, 0, 1, 1, 0, 0, 1, 1, 0]]) == 20\n assert candidate(grid = [[0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0]]) == 12\n assert candidate(grid = [[1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 1], [0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0]]) == 6\n assert candidate(grid = [[0, 0, 0, 0, 1, 1, 1, 1], [0, 0, 0, 1, 0, 0, 1, 1], [0, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]]) == 8\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 24\n assert candidate(grid = [[1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1]]) == 12\n assert candidate(grid = [[0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0]]) == 16\n assert candidate(grid = [[0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1], [0, 0, 0, 1, 1, 1], [1, 1, 1, 0, 0, 0]]) == 6\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[0, 1, 1, 0, 0, 1], [1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1], [1, 0, 0, 1, 1, 0]]) == 12\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 5\n assert candidate(grid = [[0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0]]) == 0\n assert candidate(grid = [[1, 1, 1, 0, 0, 0, 1, 1, 1], [1, 1, 0, 0, 0, 0, 0, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[1, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 0, 0, 1, 1, 0], [0, 0, 1, 1, 0, 0, 1], [1, 0, 1, 1, 1, 0, 1], [0, 1, 0, 0, 0, 1, 0]]) == 4\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[0, 1, 1, 0], [1, 0, 0, 1], [0, 1, 1, 0], [1, 0, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[1, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0], [1, 0, 1, 1, 0, 1], [1, 1, 0, 0, 1, 1], [0, 1, 0, 1, 0, 1]]) == 3\n assert candidate(grid = [[1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1]]) == 16\n assert candidate(grid = [[0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]]) == 0\n assert candidate(grid = [[0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0]]) == 0\n assert candidate(grid = [[0, 1, 1, 1, 0, 0, 0], [1, 1, 0, 0, 1, 1, 0], [0, 1, 1, 1, 0, 1, 1], [1, 1, 1, 1, 1, 1, 1]]) == 6\n assert candidate(grid = [[1, 0, 1, 1, 0, 1, 0], [0, 1, 0, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]]) == 6\n assert candidate(grid = [[1, 0, 0, 1, 0, 1], [0, 1, 1, 0, 1, 0], [0, 1, 1, 0, 1, 0], [1, 0, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[0, 1, 0, 0, 1, 0, 0, 1, 0], [1, 0, 1, 0, 0, 1, 0, 1, 1], [0, 1, 0, 1, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 7\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0]]) == 9\n assert candidate(grid = [[0, 0, 0, 0, 1, 1, 1, 1], [1, 1, 1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 0, 0]]) == 4\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0], [0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1], [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0], [0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1]]) == 16\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 20\n assert candidate(grid = [[1, 1, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1]]) == 3\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]]) == 0\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]]) == 0\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 20\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 0, 1, 1, 1, 1, 0, 1], [0, 0, 1, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0, 0, 1, 0], [1, 1, 0, 1, 1, 1, 1, 0, 1]]) == 0\n assert candidate(grid = [[1, 0, 0, 1, 0, 0, 1, 0, 0, 1], [0, 1, 0, 0, 1, 0, 0, 1, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == 2\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]]) == 16\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[0, 0, 1, 0, 1, 0, 1, 0, 0], [1, 0, 0, 1, 0, 1, 0, 0, 1], [0, 1, 0, 0, 1, 0, 0, 1, 0], [1, 0, 1, 0, 0, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[0, 0, 1, 1, 0, 0], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0]]) == 3\n assert candidate(grid = [[1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0]]) == 0\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().minFlips", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minFlips(vector>& grid) {", "container": "Solution", "callable": "minFlips", "parameters": [{"name": "grid", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3240, "task_id": "minimum-number-of-flips-to-make-binary-grid-palindromic-ii", "difficulty": "Medium", "problem_description": "You are given an m x n binary matrix grid.\nA row or column is considered palindromic if its values read the same forward and backward.\nYou can flip any number of cells in grid from 0 to 1, or from 1 to 0.\nReturn the minimum number of cells that need to be flipped to make all rows and columns palindromic, and the total number of 1's in grid divisible by 4.\n \nExample 1:\n\nInput: grid = [[1,0,0],[0,1,0],[0,0,1]]\nOutput: 3\nExplanation:\n\n\nExample 2:\n\nInput: grid = [[0,1],[0,1],[0,0]]\nOutput: 2\nExplanation:\n\n\nExample 3:\n\nInput: grid = [[1],[1]]\nOutput: 2\nExplanation:\n\n\n \nConstraints:\n\nm == grid.length\nn == grid[i].length\n1 <= m * n <= 2 * 105\n0 <= grid[i][j] <= 1\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 1, 1, 1], [1, 0, 0, 1], [1, 0, 0, 1], [1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]) == 3\n assert candidate(grid = [[1, 0, 1], [0, 1, 0], [1, 0, 1]]) == 1\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 1\n assert candidate(grid = [[0, 1], [0, 1], [0, 0]]) == 2\n assert candidate(grid = [[0, 1, 1, 0], [1, 0, 0, 1], [1, 0, 0, 1], [0, 1, 1, 0]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == 2\n assert candidate(grid = [[1, 1, 0, 0, 1], [1, 1, 0, 0, 1], [0, 0, 1, 1, 0]]) == 6\n assert candidate(grid = [[1], [1]]) == 2\n assert candidate(grid = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) == 0\n assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 0], [0, 1], [1, 0]]) == 3\n assert candidate(grid = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(grid = [[1, 1, 0, 0], [0, 0, 1, 1], [1, 1, 0, 0], [0, 0, 1, 1]]) == 8\n assert candidate(grid = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1]]) == 8\n assert candidate(grid = [[0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1]]) == 6\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[0, 1, 0], [1, 0, 1], [0, 1, 0]]) == 0\n assert candidate(grid = [[1, 0], [0, 1], [1, 0], [0, 1]]) == 4\n assert candidate(grid = [[1, 1, 1, 1], [0, 0, 0, 0], [1, 0, 1, 0]]) == 2\n assert candidate(grid = [[1, 0, 0, 1, 0, 0, 1], [0, 1, 0, 0, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1], [0, 1, 0, 0, 1, 0, 0], [1, 0, 0, 1, 0, 0, 1]]) == 7\n assert candidate(grid = [[1, 0, 0, 0, 1], [0, 1, 1, 1, 0], [0, 1, 0, 1, 0], [0, 1, 1, 1, 0], [1, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[1, 0, 0, 1, 0, 1], [0, 1, 1, 0, 1, 0], [1, 0, 1, 0, 0, 1], [0, 1, 0, 1, 1, 0]]) == 12\n assert candidate(grid = [[1, 1, 0, 1], [0, 0, 0, 0], [1, 0, 0, 1], [1, 1, 1, 1]]) == 3\n assert candidate(grid = [[1, 1, 0, 1], [1, 1, 0, 1], [0, 0, 1, 0], [0, 0, 1, 0], [1, 1, 0, 1], [1, 1, 0, 1]]) == 6\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]]) == 1\n assert candidate(grid = [[1, 0, 1, 1, 0, 1], [0, 1, 0, 0, 1, 0], [1, 1, 0, 0, 0, 1], [0, 0, 1, 1, 0, 0], [1, 0, 0, 1, 0, 1]]) == 6\n assert candidate(grid = [[1, 0, 1], [0, 1, 0], [1, 0, 1], [0, 1, 0]]) == 6\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]]) == 10\n assert candidate(grid = [[1, 1, 0, 0], [0, 0, 1, 1], [1, 1, 0, 0], [0, 0, 1, 1]]) == 8\n assert candidate(grid = [[0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1]]) == 14\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 18\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]]) == 1\n assert candidate(grid = [[1, 0, 0, 0, 1, 0, 0, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 0, 1, 0, 1, 0, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0]]) == 12\n assert candidate(grid = [[1, 0, 1, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 1, 0, 1]]) == 6\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 1, 1, 1, 0], [1, 0, 1, 0, 1], [0, 1, 1, 1, 0]]) == 8\n assert candidate(grid = [[1, 1, 1, 0, 0, 0, 1, 1], [0, 0, 1, 1, 1, 0, 0, 1], [1, 1, 0, 0, 0, 1, 1, 0], [0, 0, 1, 1, 1, 0, 0, 1]]) == 15\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 0], [0, 1, 0, 0, 1, 0], [0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]]) == 2\n assert candidate(grid = [[1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1]]) == 12\n assert candidate(grid = [[1, 0, 0, 1, 0, 1, 0], [0, 1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 0, 1, 0], [0, 1, 0, 1, 1, 0, 1]]) == 12\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[1, 1, 1, 1], [0, 0, 0, 0], [1, 1, 1, 1], [0, 0, 0, 0], [1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 0, 1, 1, 0, 1, 0, 1], [0, 1, 0, 0, 1, 0, 1, 0], [1, 0, 1, 0, 0, 1, 0, 1], [1, 0, 1, 0, 0, 1, 0, 1], [0, 1, 0, 0, 1, 0, 1, 0], [1, 0, 1, 1, 0, 1, 0, 1]]) == 4\n assert candidate(grid = [[0, 1, 1, 1, 1, 1, 1, 0], [1, 0, 1, 1, 1, 1, 0, 1], [1, 1, 0, 1, 1, 0, 1, 1], [1, 1, 1, 0, 0, 1, 1, 1], [1, 1, 0, 1, 1, 0, 1, 1], [1, 0, 1, 1, 1, 1, 0, 1], [0, 1, 1, 1, 1, 1, 1, 0]]) == 2\n assert candidate(grid = [[1, 1, 0, 0, 1], [0, 0, 1, 1, 0], [1, 1, 0, 0, 1]]) == 4\n assert candidate(grid = [[1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0]]) == 15\n assert candidate(grid = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1]]) == 8\n assert candidate(grid = [[1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1], [1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1]]) == 12\n assert candidate(grid = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0]]) == 10\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 1, 1, 1, 0], [1, 0, 1, 0, 1]]) == 1\n assert candidate(grid = [[1, 1, 1, 0, 0, 1, 0], [0, 0, 0, 1, 1, 0, 1], [1, 1, 1, 0, 0, 1, 0], [0, 0, 0, 1, 1, 0, 1]]) == 14\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1]]) == 16\n assert candidate(grid = [[1, 0, 0, 0, 1, 1], [0, 1, 1, 1, 0, 0], [0, 1, 1, 1, 0, 0], [1, 0, 0, 0, 1, 1]]) == 4\n assert candidate(grid = [[1, 1, 0, 0, 1], [0, 1, 1, 1, 0], [1, 0, 1, 0, 1], [0, 1, 1, 1, 0], [1, 1, 0, 0, 1]]) == 3\n assert candidate(grid = [[1, 0, 1], [0, 1, 0], [1, 0, 1], [0, 1, 0], [1, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 0, 0], [0, 0, 0, 1, 1], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 1, 1, 0, 0]]) == 7\n assert candidate(grid = [[1, 0, 0, 0, 0, 1], [0, 1, 0, 0, 1, 0], [0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0], [0, 1, 0, 0, 1, 0], [1, 0, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1, 0, 0, 0], [1, 1, 1, 0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1, 0, 0, 0]]) == 18\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 0], [0, 1, 0, 1, 0, 1, 0], [0, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0]]) == 1\n assert candidate(grid = [[1, 0, 1, 1, 0, 1, 0], [0, 1, 0, 0, 1, 0, 1], [1, 1, 0, 1, 0, 1, 0], [0, 0, 1, 0, 1, 0, 1]]) == 10\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 20\n assert candidate(grid = [[1, 1, 0, 0, 1, 1, 1], [0, 0, 1, 1, 0, 0, 1], [1, 0, 0, 1, 0, 0, 1], [0, 1, 1, 1, 1, 1, 0], [1, 0, 0, 1, 0, 0, 1], [0, 0, 1, 1, 0, 0, 1], [1, 1, 0, 0, 1, 1, 1]]) == 7\n assert candidate(grid = [[0, 0, 1, 1, 0, 0], [0, 1, 1, 1, 1, 0], [1, 1, 0, 0, 1, 1], [0, 1, 1, 1, 1, 0], [0, 0, 1, 1, 0, 0]]) == 0\n assert candidate(grid = [[1, 0, 0, 1, 0, 0, 1], [0, 1, 1, 0, 1, 1, 0], [1, 0, 0, 1, 0, 0, 1], [0, 1, 1, 0, 1, 1, 0]]) == 14\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]]) == 14\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]]) == 10\n assert candidate(grid = [[0, 0, 1, 0, 1, 0], [1, 0, 1, 1, 0, 1], [0, 1, 0, 1, 0, 0], [0, 0, 1, 0, 1, 0]]) == 8\n assert candidate(grid = [[1, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 35\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 50\n assert candidate(grid = [[0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1]]) == 9\n assert candidate(grid = [[1, 0, 0, 0, 1], [0, 1, 1, 1, 0], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 1, 1, 0]]) == 9\n assert candidate(grid = [[1, 1, 0, 1, 1, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0], [1, 1, 0, 1, 1, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0], [1, 1, 0, 1, 1, 0, 1, 1]]) == 10\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == 1\n assert candidate(grid = [[1, 0, 1, 1, 0], [0, 1, 1, 1, 0], [1, 1, 1, 1, 1], [0, 1, 1, 1, 0], [1, 0, 1, 1, 0]]) == 5\n assert candidate(grid = [[0, 1, 0, 0, 1, 0], [1, 0, 1, 1, 0, 1], [0, 1, 0, 0, 1, 0], [1, 0, 1, 1, 0, 1]]) == 12\n assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0]]) == 12\n assert candidate(grid = [[0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1]]) == 14\n assert candidate(grid = [[1, 0, 0, 1], [0, 1, 1, 0], [0, 1, 1, 0], [1, 0, 0, 1]]) == 0\n assert candidate(grid = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == 10\n assert candidate(grid = [[1, 1, 1, 0, 0, 0, 1, 1, 1], [1, 0, 0, 1, 1, 1, 0, 0, 1], [1, 0, 0, 1, 1, 1, 0, 0, 1], [1, 1, 1, 0, 0, 0, 1, 1, 1]]) == 2\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 0, 0, 0, 1, 1, 1], [1, 1, 0, 0, 0, 0, 0, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 1, 1, 1, 1, 0, 0], [0, 0, 0, 1, 1, 1, 1, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 0, 0, 0, 0, 0, 1, 1], [1, 1, 1, 0, 0, 0, 1, 1, 1]]) == 4\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 22\n assert candidate(grid = [[1, 0, 1, 1, 0, 1], [0, 1, 0, 0, 1, 0], [1, 0, 1, 1, 0, 1], [0, 1, 0, 0, 1, 0], [1, 0, 1, 1, 0, 1]]) == 0\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().minFlips", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minFlips(vector>& grid) {", "container": "Solution", "callable": "minFlips", "parameters": [{"name": "grid", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} -{"question_id": 3241, "task_id": "time-taken-to-mark-all-nodes", "difficulty": "Hard", "problem_description": "There exists an undirected tree with n nodes numbered 0 to n - 1. You are given a 2D integer array edges of length n - 1, where edges[i] = [ui, vi] indicates that there is an edge between nodes ui and vi in the tree.\nInitially, all nodes are unmarked. For each node i:\n\nIf i is odd, the node will get marked at time x if there is at least one node adjacent to it which was marked at time x - 1.\nIf i is even, the node will get marked at time x if there is at least one node adjacent to it which was marked at time x - 2.\n\nReturn an array times where times[i] is the time when all nodes get marked in the tree, if you mark node i at time t = 0.\nNote that the answer for each times[i] is independent, i.e. when you mark node i all other nodes are unmarked.\n \nExample 1:\n\nInput: edges = [[0,1],[0,2]]\nOutput: [2,4,3]\nExplanation:\n\n\nFor i = 0:\n\n\t\nNode 1 is marked at t = 1, and Node 2 at t = 2.\n\n\nFor i = 1:\n\t\nNode 0 is marked at t = 2, and Node 2 at t = 4.\n\n\nFor i = 2:\n\t\nNode 0 is marked at t = 2, and Node 1 at t = 3.\n\n\n\n\nExample 2:\n\nInput: edges = [[0,1]]\nOutput: [1,2]\nExplanation:\n\n\nFor i = 0:\n\n\t\nNode 1 is marked at t = 1.\n\n\nFor i = 1:\n\t\nNode 0 is marked at t = 2.\n\n\n\n\nExample 3:\n\nInput: edges = [[2,4],[0,1],[2,3],[0,2]]\nOutput: [4,6,3,5,5]\nExplanation:\n\n\n \nConstraints:\n\n2 <= n <= 105\nedges.length == n - 1\nedges[i].length == 2\n0 <= edges[i][0], edges[i][1] <= n - 1\nThe input is generated such that edges represents a valid tree.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(edges = [[0, 1], [0, 2]]) == [2, 4, 3]\n assert candidate(edges = [[3, 1], [3, 0], [1, 2]]) == [4, 3, 4, 3]\n assert candidate(edges = [[1, 0], [2, 0], [3, 0], [4, 1], [5, 2]]) == [3, 5, 5, 5, 6, 7]\n assert candidate(edges = [[0, 3], [1, 2], [2, 3], [3, 4]]) == [4, 5, 3, 3, 4]\n assert candidate(edges = [[3, 1], [3, 0], [3, 2], [5, 3], [4, 3]]) == [3, 3, 3, 2, 3, 3]\n assert candidate(edges = [[0, 3], [1, 2], [1, 3], [4, 3]]) == [4, 3, 4, 3, 4]\n assert candidate(edges = [[3, 1], [3, 2], [3, 0]]) == [3, 3, 3, 2]\n assert candidate(edges = [[2, 4], [0, 1], [2, 3], [0, 2]]) == [4, 6, 3, 5, 5]\n assert candidate(edges = [[0, 1]]) == [1, 2]\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30]]) == [45, 44, 42, 41, 39, 38, 36, 35, 33, 32, 30, 29, 27, 26, 24, 23, 24, 26, 27, 29, 30, 32, 33, 35, 36, 38, 39, 41, 42, 44, 45]\n assert candidate(edges = [[22, 12], [22, 10], [22, 13], [22, 11], [22, 14], [22, 9], [22, 8], [22, 7], [22, 6], [22, 5], [22, 4], [22, 3], [22, 2], [22, 1], [22, 0], [22, 15], [22, 16], [22, 17], [22, 18], [22, 19], [22, 20], [22, 21]]) == [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2]\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26], [13, 27], [13, 28], [14, 29], [14, 30]]) == [8, 10, 9, 11, 11, 11, 11, 12, 12, 13, 13, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 13, 13, 14, 14, 14, 14, 15, 15]\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]]) == [5, 6, 7, 7, 7, 9, 9, 8, 8, 9, 9]\n assert candidate(edges = [[0, 10], [0, 11], [0, 12], [10, 1], [11, 2], [12, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9]]) == [6, 10, 9, 10, 11, 11, 11, 13, 12, 13, 8, 8, 8]\n assert candidate(edges = [[0, 1], [0, 2], [2, 3], [2, 4], [4, 5], [4, 6], [6, 7], [6, 8], [8, 9], [8, 10], [10, 11], [10, 12], [12, 13], [12, 14], [14, 15], [14, 16], [16, 17], [16, 18], [18, 19], [18, 20], [20, 21], [20, 22], [22, 23], [22, 24], [24, 25], [24, 26], [26, 27], [26, 28], [28, 29], [28, 30]]) == [30, 32, 28, 30, 26, 28, 24, 26, 22, 24, 20, 22, 18, 20, 16, 18, 17, 19, 19, 21, 21, 23, 23, 25, 25, 27, 27, 29, 29, 31, 31]\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26], [13, 27], [13, 28], [14, 29], [14, 30]]) == [8, 10, 9, 11, 11, 11, 11, 12, 12, 13, 13, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 13, 13, 14, 14, 14, 14, 15, 15]\n assert candidate(edges = [[0, 1], [1, 2], [1, 3], [3, 4], [4, 5], [4, 6], [6, 7], [7, 8], [7, 9]]) == [9, 8, 9, 7, 5, 7, 6, 8, 9, 9]\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [0, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]]) == [9, 11, 12, 14, 11, 13, 14, 16, 17, 19, 11, 13, 14, 16, 17, 19]\n assert candidate(edges = [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [6, 2], [7, 3], [8, 3], [9, 4], [10, 4], [11, 5], [12, 5], [13, 6], [14, 6], [15, 7], [16, 7], [17, 8], [18, 8], [19, 9], [20, 9], [21, 10], [22, 10], [23, 11], [24, 11], [25, 12], [26, 12], [27, 13], [28, 13], [29, 14], [30, 14], [31, 15], [32, 15], [33, 16], [34, 16], [35, 17], [36, 17], [37, 18], [38, 18], [39, 19], [40, 19]]) == [8, 10, 10, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 13, 13, 14, 14, 14, 14, 15, 15, 14, 14, 15, 15, 15, 15, 16, 16, 14, 14, 15, 15, 15, 15, 16, 16, 15, 15]\n assert candidate(edges = [[7, 3], [3, 1], [3, 0], [3, 2], [5, 3], [4, 3], [6, 3]]) == [3, 3, 3, 2, 3, 3, 3, 3]\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]]) == [30, 29, 27, 26, 24, 23, 21, 20, 18, 17, 15, 17, 18, 20, 21, 23, 24, 26, 27, 29, 30]\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]]) == [22, 21, 19, 18, 16, 15, 13, 12, 12, 14, 15, 17, 18, 20, 21, 23]\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13]]) == [6, 8, 6, 9, 9, 8, 8, 10, 10, 11, 9, 9, 10, 10]\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19], [9, 20], [9, 21]]) == [6, 8, 7, 8, 9, 9, 9, 9, 9, 9, 11, 11, 10, 10, 11, 11, 10, 10, 11, 11, 10, 10]\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [3, 6], [4, 7], [4, 8], [5, 9], [5, 10], [6, 11], [6, 12], [7, 13], [7, 14], [8, 15], [8, 16], [9, 17], [9, 18], [10, 19], [10, 20], [11, 21], [11, 22], [12, 23], [12, 24], [13, 25], [13, 26], [14, 27], [14, 28], [15, 29], [15, 30], [16, 31], [16, 32], [17, 33], [17, 34], [18, 35], [18, 36], [19, 37], [19, 38], [20, 39], [20, 40]]) == [10, 12, 11, 13, 13, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 17, 17, 16, 16, 17, 17, 17, 17, 18, 18, 17, 17, 18, 18, 18, 18, 19, 19, 17, 17, 18, 18, 18, 18, 19, 19]\n assert candidate(edges = [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [6, 2], [7, 3], [8, 3], [9, 4], [10, 4], [11, 5], [12, 5], [13, 6], [14, 6], [15, 7], [16, 7], [17, 8], [18, 8], [19, 9], [20, 9], [21, 10], [22, 10], [23, 11], [24, 11], [25, 12], [26, 12], [27, 13], [28, 13], [29, 14], [30, 14]]) == [8, 10, 9, 11, 11, 11, 11, 12, 12, 13, 13, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 13, 13, 14, 14, 14, 14, 15, 15]\n assert candidate(edges = [[0, 1], [0, 2], [2, 3], [2, 4], [4, 5], [4, 6], [4, 7], [6, 8], [6, 9], [6, 10], [8, 11], [8, 12], [8, 13], [10, 14], [10, 15], [10, 16]]) == [10, 12, 8, 10, 6, 8, 7, 8, 9, 9, 9, 11, 11, 11, 11, 11, 11]\n assert candidate(edges = [[2, 3], [1, 2], [5, 3], [0, 5], [4, 5], [6, 5], [7, 6], [8, 7], [9, 8], [10, 9], [11, 10], [12, 11], [13, 12], [14, 13], [15, 14], [16, 15], [17, 16], [18, 17], [19, 18], [20, 19], [21, 20], [22, 21], [23, 22], [24, 23], [25, 24], [26, 25], [27, 26], [28, 27], [29, 28]]) == [37, 40, 38, 37, 37, 36, 34, 33, 31, 30, 28, 27, 25, 24, 22, 21, 20, 22, 23, 25, 26, 28, 29, 31, 32, 34, 35, 37, 38, 40]\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 31], [31, 32], [32, 33], [33, 34], [34, 35], [35, 36], [36, 37], [37, 38], [38, 39]]) == [58, 57, 55, 54, 52, 51, 49, 48, 46, 45, 43, 42, 40, 39, 37, 36, 34, 33, 31, 30, 30, 32, 33, 35, 36, 38, 39, 41, 42, 44, 45, 47, 48, 50, 51, 53, 54, 56, 57, 59]\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [0, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 10], [10, 11], [11, 12], [12, 13], [13, 14], [0, 15], [15, 16], [16, 17], [17, 18], [18, 19]]) == [8, 10, 11, 13, 14, 10, 11, 13, 14, 16, 9, 11, 12, 14, 15, 10, 11, 13, 14, 16]\n assert candidate(edges = [[0, 1], [1, 2], [0, 3], [3, 4], [4, 5], [0, 6], [6, 7], [7, 8], [8, 9]]) == [6, 8, 9, 8, 9, 11, 6, 8, 9, 11]\n assert candidate(edges = [[10, 0], [10, 1], [10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8], [10, 9], [10, 11], [10, 12], [10, 13], [10, 14], [10, 15], [10, 16], [10, 17], [10, 18], [10, 19]]) == [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4]\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == [13, 12, 10, 9, 7, 8, 9, 11, 12, 14]\n assert candidate(edges = [[1, 0], [2, 0], [3, 0], [4, 1], [5, 1], [6, 2], [7, 2], [8, 3], [9, 3], [10, 4], [11, 4], [12, 5], [13, 5], [14, 6], [15, 6], [16, 7], [17, 7], [18, 8], [19, 8], [20, 9], [21, 9]]) == [6, 8, 7, 8, 9, 9, 9, 9, 9, 9, 11, 11, 10, 10, 11, 11, 10, 10, 11, 11, 10, 10]\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19], [9, 20], [9, 21], [10, 22], [10, 23], [11, 24], [11, 25], [12, 26], [12, 27], [13, 28], [13, 29], [14, 30], [14, 31], [15, 32], [15, 33], [16, 34], [16, 35], [17, 36], [17, 37], [18, 38], [18, 39], [19, 40], [19, 41]]) == [8, 10, 9, 10, 11, 11, 11, 11, 11, 11, 13, 13, 12, 12, 13, 13, 12, 12, 13, 13, 12, 12, 15, 15, 14, 14, 14, 14, 13, 13, 15, 15, 14, 14, 14, 14, 13, 13, 15, 15, 14, 14]\n assert candidate(edges = [[8, 6], [8, 7], [0, 5], [0, 4], [0, 3], [0, 8], [0, 1], [0, 2]]) == [4, 6, 6, 6, 6, 6, 6, 6, 4]\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9]]) == [4, 6, 5, 6, 7, 7, 7, 7, 7, 7]\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]]) == [6, 8, 7, 9, 9, 9, 9, 10, 10, 11, 11, 10, 10, 11, 11]\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22]]) == [7, 8, 9, 9, 9, 11, 11, 10, 10, 11, 11, 12, 12, 13, 13, 11, 11, 12, 12, 12, 12, 13, 13]\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]]) == [5, 6, 7, 7, 7, 9, 9, 8, 8, 9, 9]\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == [13, 12, 10, 9, 7, 8, 9, 11, 12, 14]\n assert candidate(edges = [[10, 0], [10, 1], [10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8], [10, 9]]) == [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2]\n assert candidate(edges = [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [6, 2], [7, 3], [8, 3], [9, 4], [10, 4], [11, 5], [12, 5], [13, 6], [14, 6], [15, 7], [16, 7], [17, 8], [18, 8], [19, 9], [20, 9]]) == [6, 8, 8, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 11, 11, 12, 12, 12, 12]\n assert candidate(edges = [[1, 0], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13]]) == [19, 18, 16, 15, 13, 12, 10, 11, 12, 14, 15, 17, 18, 20]\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26]]) == [7, 9, 9, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12, 13, 13, 12, 12, 13, 13, 13, 13, 14, 14, 13, 13, 14, 14]\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == [10, 9, 7, 6, 6, 8, 9, 11]\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26], [13, 27], [13, 28], [14, 29], [14, 30], [15, 31], [15, 32], [16, 33], [16, 34], [17, 35], [17, 36], [18, 37], [18, 38], [19, 39], [19, 40], [20, 41], [20, 42], [21, 43], [21, 44], [22, 45], [22, 46], [23, 47], [23, 48], [24, 49], [24, 50]]) == [9, 10, 11, 11, 11, 13, 13, 12, 12, 13, 13, 14, 14, 15, 15, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 17, 17, 14, 14, 15, 15, 15, 15, 16, 16, 15, 15, 16, 16, 16, 16, 17, 17, 16, 16, 17, 17]\n assert candidate(edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23], [12, 24], [12, 25], [13, 26], [13, 27], [14, 28], [14, 29], [15, 30], [15, 31], [16, 32], [16, 33], [17, 34], [17, 35], [18, 36], [18, 37], [19, 38], [19, 39], [20, 40], [20, 41], [21, 42], [21, 43], [22, 44], [22, 45], [23, 46], [23, 47], [24, 48], [24, 49], [25, 50], [25, 51], [26, 52], [26, 53], [27, 54], [27, 55], [28, 56], [28, 57], [29, 58], [29, 59]]) == [11, 10, 10, 11, 12, 12, 12, 12, 14, 14, 13, 13, 14, 14, 13, 13, 16, 16, 15, 15, 15, 15, 14, 14, 16, 16, 15, 15, 15, 15, 14, 14, 18, 18, 17, 17, 17, 17, 16, 16, 17, 17, 16, 16, 16, 16, 15, 15, 18, 18, 17, 17, 17, 17, 16, 16, 17, 17, 16, 16]\n assert candidate(edges = [[15, 11], [15, 10], [15, 12], [15, 9], [15, 14], [15, 8], [15, 13], [15, 7], [15, 6], [15, 5], [15, 4], [15, 3], [15, 2], [15, 1], [15, 0]]) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2]\n assert candidate(edges = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5], [5, 6], [5, 7], [7, 8], [7, 9]]) == [6, 5, 6, 4, 5, 4, 5, 5, 6, 6]\n assert candidate(edges = [[6, 3], [6, 0], [6, 4], [1, 6], [2, 6], [5, 6]]) == [4, 4, 4, 4, 4, 4, 2]\n assert candidate(edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [5, 8], [5, 9]]) == [6, 5, 4, 6, 6, 6, 7, 7, 7, 7]\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [5, 9], [5, 10], [6, 11], [6, 12]]) == [6, 8, 6, 9, 9, 8, 8, 10, 10, 9, 9, 10, 10]\n assert candidate(edges = [[25, 18], [25, 24], [25, 19], [25, 20], [25, 21], [25, 22], [25, 23], [25, 2], [25, 0], [25, 1], [25, 10], [25, 11], [25, 12], [25, 13], [25, 14], [25, 15], [25, 16], [25, 17], [25, 3], [25, 4], [25, 5], [25, 6], [25, 7], [25, 8], [25, 9]]) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2]\n"}, "metadata": {"canonical_parameter_names": ["edges"], "leetcode_dataset_entry_point": "Solution().timeTaken", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector timeTaken(vector>& edges) {", "container": "Solution", "callable": "timeTaken", "parameters": [{"name": "edges", "type": "vector>&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}